Add Method

import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# Initialize global variables

init_op = tf.global_variables_initializer()
session = tf.Session()
session.run(init_op)
a = tf.placeholder(tf.float32)
b = a * a
# feeding a placeholder with scalar
result = session.run(b, feed_dict={a:4})
print(result)
16.0
result1 = session.run(b, {a:8})
result1
64.0
# passing one dimensional array to the placeholder
result2 = session.run(b, {a : [1, 6, 2, 5] })
print(result2)
[ 1. 36.  4. 25.]
dictionary = {
    a: [
        [1, 4, 3],
        [2, 2, 4],
        [7, 1, 2]
    ]
}
print(dictionary)
{<tf.Tensor 'Placeholder:0' shape=<unknown> dtype=float32>: [[1, 4, 3], [2, 2, 4], [7, 1, 2]]}
result3 = session.run(b, feed_dict=dictionary)
print(result3)
[[ 1. 16.  9.]
 [ 4.  4. 16.]
 [49.  1.  4.]]
session.close()