When writing machine learning models, I find myself needing to compute metrics, or run additional forward-passes in callbacks for visualization purposes. In PyTorch, I do this with torch.no_grad(), and this prevents gradients from being computed and these operations, therefore, do not influence the optimization.
- How does this mechanism work in TensorFlow/Keras?
- Keras models are callable. So, something like
model(x)is possible. But, it is also possible to saymodel.predict(x), which also seems to invoke thecall. Is there a difference between the two?