import tensorflow as tf
a = tf.constant(12)
b = tf.constant(13)
c = tf.multiply(12, 13)
with tf.Session() as session:
print(session.run(c))
matrixA = tf.constant([[3, 4], [4, 5]])
matrixB = tf.constant([[5, 6], [2, 3]])
matrixC = tf.matmul(matrixA, matrixB)
# Don't get confused with tf.multiply and tf.matmul as the first one does element wise multiplications
# and the latter one gives the dot product of the two matrices
with tf.Session() as session:
print(session.run(matrixC))
variableA = tf.Variable(0)
variableB = tf.constant(5)
activity1 = tf.assign(variableA, variableB)
with tf.Session() as session:
# To be able to use variables in a computation graph it is necessary to initialize them before
# running the graph in a session.
session.run(tf.global_variables_initializer())
session.run(activity1)
print(session.run(variableA))
placeholder1 = tf.placeholder(dtype=tf.float32)
with tf.Session() as session:
print(session.run(placeholder1, feed_dict={placeholder1: 5}))
placeholder2 = tf.placeholder(dtype=tf.float32)
placeholder3 = tf.placeholder(dtype=tf.float32)
activity2 = tf.pow(placeholder2, placeholder3)
with tf.Session() as session:
activity3 = session.run(activity2, feed_dict={placeholder2: 2, placeholder3: 3})
print(activity3)