Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make a scatter plots using tensorboard - tensorflow

now, i'm studying tensorflow. but, i can't draw dot graph using tensorboard.

if i have sample data for training, like that

train_X = numpy.asarray([3.3, 4.4, 5.5, 6.71, 6.93, 4.168, 9.779])
train_Y = numpy.asarray([1.7, 2.76, 2.09, 3.19, 1.694, 1.573, 3.366])

i want to show scatter plots using tensorboard. i know "import matplotlib.pyplot as plt" can do that. but i can just use console (putty). so can't use this method.

can i see dot graph, like scatter plots using tensorboard.

can anyone help me?

like image 759
jaewan Shin Avatar asked Dec 28 '16 05:12

jaewan Shin


People also ask

How do you graph a TensorBoard?

Select the Graphs dashboard by tapping “Graphs” at the top. You can also optionally use TensorBoard. dev to create a hosted, shareable experiment. By default, TensorBoard displays the op-level graph.

How do you visualize a TensorBoard?

Head over to localhost:6006 to see TensorBoard on your local machine. We can see some of the scalar metrics that are provided by default With the linear Classifier. We can also Expand and Zoom into any of these graphs. Double-clicking allows us to zoom out.

Does TensorBoard work with TensorFlow 1?

TensorBoard is a built-in tool for providing measurements and visualizations in TensorFlow. Common machine learning experiment metrics, such as accuracy and loss, can be tracked and displayed in TensorBoard. TensorBoard is compatible with TensorFlow 1 and 2 code.

Is TensorBoard part of TensorFlow?

TensorBoard is a visualization tool provided with TensorFlow. This callback logs events for TensorBoard, including: Metrics summary plots. Training graph visualization.


1 Answers

Not really a full answer, but what I do is import matplotlib for no display use:

import matplotlib as mpl
mpl.use('Agg')  # No display
import matplotlib.pyplot as plt

Then draw my plots into a buffer and save that as a PNG:

# setting up the necessary tensors:
plot_buf_ph = tf.placeholder(tf.string)
image = tf.image.decode_png(plot_buf_ph, channels=4)
image = tf.expand_dims(image, 0)  # make it batched
plot_image_summary = tf.summary.image('some_name', image, max_outputs=1)

# later, to make the plot:
plot_buf = get_plot_buf()
plot_image_summary_ = session.run(
        plot_image_summary,
        feed_dict={plot_buf_ph: plot_buf.getvalue()})
summary_writer.add_summary(plot_image_summary_, global_step=iteration)

where get_plot_buf is:

def get_plot_buf(self):
    plt.figure()

    # ... draw plot here ...

    buf = io.BytesIO()
    plt.savefig(buf, format='png')
    plt.close()

    buf.seek(0)
    return buf
like image 115
fabian789 Avatar answered Oct 02 '22 15:10

fabian789