def setUp(self):
self.log_dir = tempfile.mkdtemp()
# We use numpy.random to generate images. We seed to avoid non-determinism
# in this test.
numpy.random.seed(42)
# Create old-style image summaries for run "foo".
tf.reset_default_graph()
sess = tf.Session()
placeholder = tf.placeholder(tf.uint8)
tf.summary.image(name="baz", tensor=placeholder)
merged_summary_op = tf.summary.merge_all()
foo_directory = os.path.join(self.log_dir, "foo")
writer = tf.summary.FileWriter(foo_directory)
writer.add_graph(sess.graph)
for step in xrange(2):
writer.add_summary(sess.run(merged_summary_op, feed_dict={
placeholder: (numpy.random.rand(1, 16, 42, 3) * 255).astype(
numpy.uint8)
}), global_step=step)
writer.close()
# Create new-style image summaries for run bar.
tf.reset_default_graph()
sess = tf.Session()
placeholder = tf.placeholder(tf.uint8)
summary.op(name="quux", images=placeholder,
description="how do you pronounce that, anyway?")
merged_summary_op = tf.summary.merge_all()
bar_directory = os.path.join(self.log_dir, "bar")
writer = tf.summary.FileWriter(bar_directory)
writer.add_graph(sess.graph)
for step in xrange(2):
writer.add_summary(sess.run(merged_summary_op, feed_dict={
placeholder: (numpy.random.rand(1, 6, 8, 3) * 255).astype(
numpy.uint8)
}), global_step=step)
writer.close()
# Start a server with the plugin.
multiplexer = event_multiplexer.EventMultiplexer({
"foo": foo_directory,
"bar": bar_directory,
})
context = base_plugin.TBContext(
logdir=self.log_dir, multiplexer=multiplexer)
plugin = images_plugin.ImagesPlugin(context)
wsgi_app = application.TensorBoardWSGIApp(
self.log_dir, [plugin], multiplexer, reload_interval=0, path_prefix='')
self.server = werkzeug_test.Client(wsgi_app, wrappers.BaseResponse)
self.routes = plugin.get_plugin_apps()
评论列表
文章目录