How to make scatterplots using a strain gauge - tensor flow

Now, I am studying tensor. but I cannot draw a point graph with a tensor.

if I have training data samples for example

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 a tensogram. I know that "import matplotlib.pyplot as plt" can do this. but I can just use the console (putty). therefore, cannot use this method.

Can I see a scatter graph, for example, scatter plots using a tensogram.

Can anybody help me?

+4
source share
1 answer

Not a complete answer, but I am doing matplotlib import without using a display:

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

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)

get_plot_buf:

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
0

Source: https://habr.com/ru/post/1665070/


All Articles