!pip install -q tensorflow-gpu==2.0.0-rc1
import tensorflow.compat.v1 as tf
x = tf.constant('hello world')
print(x)
sess = tf.Session()
print(sess.run(x))
node1 = tf.constant(3.0,tf.float32)
node2 = tf.constant(4.0)
node3 = node1 + node2
node4 = tf.add(node1,node2)
print(node1,node2,node3,node4)
sess.close()
sess = tf.Session()
val_node3 = sess.run(node3)
val_node3
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
c = a + b
feed_val = {a:[7,6], b:[8,5]}
sess.run(c,feed_dict={a:3,b:4})
x_t = [1,2,3]
y_t = [1,2,3]
w = tf.Variable(tf.random_normal([1]), name='weight')
b = tf.Variable(tf.random_normal([1]), name='bias')
hypothesis = x_t * w + b
cost = tf.reduce_mean(tf.square(hypothesis - y_t))
optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.01)
train = optimizer.minimize(cost)
train
sess = tf.Session()
sess.run(tf.global_variables_initializer())
for step in range(2001):
sess.run(train)
if step % 20 == 0:
print(step, sess.run(cost), sess.run(W), sess.run(b))
sess.run(tf.hypothesis.feed_dict={x:7})