eval() and run() in tensorflow

后端 未结 2 1950
轮回少年
轮回少年 2021-01-01 20:22

I\'m referring to Deep MNIST for Experts tutorial given by the tensorflow. I have a problem in Train and Evaluate part of that tutorial. There they have giv

相关标签:
2条回答
  • 2021-01-01 21:02

    If you have only one default session, they are basically the same.

    From https://github.com/tensorflow/tensorflow/blob/v1.12.0/tensorflow/python/framework/ops.py#L2351:

    op.run() is a shortcut for calling tf.get_default_session().run(op)

    From https://github.com/tensorflow/tensorflow/blob/v1.12.0/tensorflow/python/framework/ops.py#L691:

    t.eval() is a shortcut for calling tf.get_default_session().run(t)

    Difference between Tensor and Operation:

    Tensor: https://www.tensorflow.org/api_docs/python/tf/Tensor

    Operation: https://www.tensorflow.org/api_docs/python/tf/Operation

    Note: the Tensor class will be replaced by Output in the future. Currently these two are aliases for each other.

    0 讨论(0)
  • 2021-01-01 21:16

    The difference is in Operations vs. Tensors. Operations use run() and Tensors use eval().

    There seems to be a reference to this question in TensorFlow FAQ: https://www.tensorflow.org/programmers_guide/faq#running_a_tensorflow_computation

    The section addresses the following question: What is the difference between Session.run() and Tensor.eval()?

    0 讨论(0)
提交回复
热议问题