I have been using the introductory example of matrix multiplication in TensorFlow.
matrix1 = tf.constant([[3., 3.]])
matrix2 = tf.constant([[2.],[2.]])
produ
tf.keras.backend.eval is useful for evaluating small expressions.
tf.keras.backend.eval(op)
TF 1.x and TF 2.0 compatible.
Minimal Verifiable Example
from tensorflow.keras.backend import eval
m1 = tf.constant([[3., 3.]])
m2 = tf.constant([[2.],[2.]])
eval(tf.matmul(m1, m2))
# array([[12.]], dtype=float32)
This is useful because you do not have to explicitly create a Session
or InteractiveSession
.