In [1]:
import tensorflow as tf
import numpy as np
In [2]:
sess = tf.InteractiveSession()
accuracy = tf.Variable(0.2, name="xxx")
accuracy_ = tf.placeholder("float")
img_ = tf.placeholder("float", shape=[None, 1080, 1920, 3])
img = tf.Variable(tf.zeros([1, 1080,1920,3]))
tf.summary.scalar("acc", accuracy)
tf.summary.image("img", img)
summary_op = tf.merge_all_summaries()
summary_writer = tf.summary.FileWriter("log_test", graph=sess.graph)
update = tf.assign(accuracy, accuracy_)
update_img = tf.assign(img, img_)
In [3]:
tf.global_variables_initializer().run()
In [4]:
# copy from Week01 animation example
from math import pi, sin
a = np.zeros((1080,1920,3))
i_ = np.arange(1,64)
c = np.random.uniform(size=(63,3))
def color_arrows(t):
t_ = (i_*7.15+t)
x1 = (t_/3%1*1920).astype(np.int32)
y1 = (np.sin(t_)*500+500).astype(np.int32)
for i in range(63):
a[y1[i]:y1[i]+80, x1[i]:x1[i]+80] = c[i]
return a
In [5]:
for i in range(100):
update.eval(feed_dict={accuracy_: i/100.0})
color_arrows(i/100)
if i == 99:
update_img.eval(feed_dict={img_: a[None, ...]})
summary_writer.add_summary(summary_op.eval(), i)
In [ ]:
summary_writer.close()
sess.close()
In [ ]: