tf.keras.backend.eval

TensorFlow 1 version View source on GitHub

Evaluates the value of a variable.

tf.keras.backend.eval(x)

Arguments:

  • x: A variable.

Returns:

A Numpy array.

Examples:

<pre class="devsite-click-to-copy prettyprint lang-py">
<code class="devsite-terminal" data-terminal-prefix="&gt;&gt;&gt;">from keras import backend as K</code>
<code class="no-select nocode">    &gt;&gt;&gt; kvar = K.variable(np.array([[1, 2], [3, 4]]), dtype=&#39;float32&#39;)</code>
<code class="no-select nocode">    &gt;&gt;&gt; K.eval(kvar)</code>
<code class="no-select nocode">    array([[ 1.,  2.],</code>
<code class="no-select nocode">           [ 3.,  4.]], dtype=float32)</code>
</pre>

Compat aliases