To implement the first operational gate, , in TensorFlow and train the output towards the value of 50, follow these steps:
- Start off by loading TensorFlow and creating a graph session as follows:
import tensorflow as tf sess = tf.Session()
- Now we will need to declare our model variable, input data, and placeholder. We make our input data equal to the value 5, so that the multiplication factor to get 50 will be 10 (that is, 5X10=50), as follows:
a = tf.Variable(tf.constant(4.))x_val = 5.x_data = tf.placeholder(dtype=tf.float32)
- Next, we add the operation to our computational graph with the following input:
multiplication ...