tensorflow – Matrix and Vector Arithmetic – Scalar Times a Tensor

In the following example a 2 by 3 tensor is multiplied by a scalar value (2).

# Build a graph
graph = tf.Graph()
with graph.as_default():
    # A 2x3 matrix
    a = tf.constant(np.array([[ 1, 2, 3],
                              [10,20,30]]),
                    dtype=tf.float32)
                    
    # Scalar times Matrix
    c =  2 * a

# Run a Session
with tf.Session(graph=graph) as session:
    output = session.run(c)
    print(output)

This prints out

[[  2.   4.   6.]
 [ 20.  40.  60.]]

if you want to reproduce, please indicate the source:
tensorflow – Matrix and Vector Arithmetic – Scalar Times a Tensor - CodeDay