eval() and run() in tensorflow

后端 未结 2 1941
轮回少年
轮回少年 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.

提交回复
热议问题