with tf.name_scope("loss"):
loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),
reduction_indices=[1]))
tf.scalar_summary("loss", loss)
with tf.name_scope("train"):
train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss)
After Change
with tf.name_scope("loss"):
loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),
reduction_indices=[1]))
if int((tf.__version__).split(".")[1]) < 12: // tensorflow version < 0.12
tf.scalar_summary("loss", loss)
else: // tensorflow version >= 0.12
tf.summary.scalar("loss", loss)
with tf.name_scope("train"):
train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss)
sess = tf.Session()
if int((tf.__version__).split(".")[1]) < 12: // tensorflow version < 0.12
merged = tf.merge_all_summaries()
else: // tensorflow version >= 0.12
merged = tf.summary.merge_all()
// tf.train.SummaryWriter soon be deprecated, use following
if int((tf.__version__).split(".")[1]) < 12: // tensorflow version < 0.12
writer = tf.train.SummaryWriter("logs/", sess.graph)
else: // tensorflow version >= 0.12
writer = tf.summary.FileWriter("logs/", sess.graph)