问题
For simple gradient descent, I am using this :
_, l, predictions = session.run([optimizer, loss, train_prediction])
where optimizer op minimizes loss.
But I am feeding loss after optimizer, so will the loss, be evaluated two times at each .run(), one using initial weight, and then using updated weights ?
回答1:
The order of elements in the list of fetched tensors doesn't matter (except for capturing the values on the Python side). They will all be executed during the same evaluation.
In your example, the loss will be evaluated only once and any computations that can be shared between the [optimizer, loss, train_prediction]
will be shared.
来源:https://stackoverflow.com/questions/35457879/evaluation-of-loss-with-session-run-in-tensorflow