question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Evaluate network in training=True configuration

See original GitHub issue

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version:

1.7.3

Browser version: Chrome

81.0.4044.113

Describe the problem or feature request:

I have trained a pix2pix network in python, and converted it to a tfjs graph model. In python, I can evaluate the network with the training=True flag, which is required in order for the batch normalization layers to use the sample mean and variance rather than the mean and variance from the training set. Is it possible to either call the model in a training configuration, or to modify the batchnorm layer to use sample statistics rather than training statistics?

There is a similar issue here: #562

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:19 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
B0RJAcommented, Sep 2, 2020

The solution is to use the apply method with the training kwarg set to true. Tested with TensorFlow.js 2.0.

const output = model.apply(input, {'training': true});

1reaction
AmitMYcommented, Jun 29, 2022

Works for me too 😃 I just hope that it does not “cost” more compute to run it in training mode

Now after evaluating the time:

model.apply(tensor, {training: true})

Takes 6-8ms for me, while

model.predict(tensor)

Takes 3-4ms to me (50%!)

While it is not a lot, (assuming that model inference takes 40ms~) It can make the difference from 24 to 25fps 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Training and evaluation with the built-in methods - TensorFlow
This guide covers training, evaluation, and prediction (inference) ... We specify the training configuration (optimizer, loss, metrics):.
Read more >
What does `training=True` mean when calling a TensorFlow ...
It says that training is a Boolean or boolean scalar tensor, indicating whether to run the Network in training mode or inference mode....
Read more >
Writing a training loop from scratch - Keras
Description: Complete guide to writing low-level training & evaluation loops. View in Colab • GitHub source. Setup. import tensorflow as ...
Read more >
Evaluate the Performance of Deep Learning Models in Keras
Empirically Evaluate Network Configurations. You must make a myriad of decisions when designing and configuring your deep learning models.
Read more >
End-to-end Learning with Autoencoders — Sionna ... - NVlabs
GPU Configuration and Imports ... SNR range for evaluation and training [dB] ... either for training ( training = True ) or evaluation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found