In [10]:
import tensorflow as tf
#Basic
w = tf.constant(2, tf.float16)
b = tf.constant(1., tf.float16)
x = tf.placeholder(tf.float16)
eq = tf.add(tf.multiply(w,x),b)
with tf.Session() as sess:
print(sess.run(eq, feed_dict={x : 3.}))
In [18]:
#Matrix
W = tf.constant([[1., 2., 3.], [4., 5., 6.]], dtype = tf.float16, shape = [2, 3])
B = tf.constant([1., 2., 3.], dtype = tf.float16, shape = [1, 3])
X = tf.placeholder(dtype = tf.float16, shape = [1, 2])
eq = tf.add(tf.matmul(X, W), B)
with tf.Session() as sess:
print(sess.run(eq, feed_dict={X : [[1., 2.]]}))