In a session, computes and returns the value of this variable. This is not a graph construction method, it does not add ops to the graph. This convenience method requires a session where the graph containing this variable has been launched. If no session is passed, the default sess
(self, session=None)
| 687 | raise NotImplementedError |
| 688 | |
| 689 | def eval(self, session=None): |
| 690 | """In a session, computes and returns the value of this variable. |
| 691 | |
| 692 | This is not a graph construction method, it does not add ops to the graph. |
| 693 | |
| 694 | This convenience method requires a session where the graph |
| 695 | containing this variable has been launched. If no session is |
| 696 | passed, the default session is used. See `tf.compat.v1.Session` for more |
| 697 | information on launching a graph and on sessions. |
| 698 | |
| 699 | ```python |
| 700 | v = tf.Variable([1, 2]) |
| 701 | init = tf.compat.v1.global_variables_initializer() |
| 702 | |
| 703 | with tf.compat.v1.Session() as sess: |
| 704 | sess.run(init) |
| 705 | # Usage passing the session explicitly. |
| 706 | print(v.eval(sess)) |
| 707 | # Usage with the default session. The 'with' block |
| 708 | # above makes 'sess' the default session. |
| 709 | print(v.eval()) |
| 710 | ``` |
| 711 | |
| 712 | Args: |
| 713 | session: The session to use to evaluate this variable. If none, the |
| 714 | default session is used. |
| 715 | |
| 716 | Returns: |
| 717 | A numpy `ndarray` with a copy of the value of this variable. |
| 718 | """ |
| 719 | raise NotImplementedError |
| 720 | |
| 721 | @deprecated( |
| 722 | None, "Use Variable.read_value. Variables in 2.X are initialized " |
no outgoing calls