Evaluation of loss with session.run([]) in TensorFlow

自古美人都是妖i 提交于 2021-02-19 05:26:41

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!