import tensorflow as tf import numpy as np w = tf.Variable(tf.constant([3.]), name='w') b = tf.Variable(tf.constant([1.]), name='b') x = tf.Variable(tf.constant([2.]), name='x') y_ = tf.Variable(tf.constant([5.]), name='y_') p = w*x y = p+b s = -y t = s +y_ f = t*t gx, gb, gw, gp, gy, gy_,gs, gt, gf = tf.gradients(f, [x, b, w, p, y, y_,s, t, f]) init = tf.initialize_all_variables() opt = tf.train.