Reshma NirmalKumar
Reshma NirmalKumar

Reputation: 61

how to plot the tensorflow neural network object

I tried example code of tensorflow spiral dataset and constructed the neural network. I wanted to visualize the graphical structure of the network. PFB the code i tried.

with tf.Graph().as_default():
    net = tflearn.input_data([None, 2])
    net = tflearn.fully_connected(net,6,
                activation='tanh',weights_init='normal')
    print(net)

Upvotes: 4

Views: 3785

Answers (1)

Olivier Moindrot
Olivier Moindrot

Reputation: 28198

To visualize a graph, you should use TensorBoard. Here is a tutorial for how to use it.

You can add at the end of your code a summary writer, which will write an event file (containing the visualization of the graph) into the given location.

graph = tf.Graph()
with graph.as_default():
    net = tflearn.input_data([None, 2])
    net = tflearn.fully_connected(net,6,
                activation='tanh',weights_init='normal')

sess = tf.Session(graph=graph)
writer = tf.train.SummaryWriter('tmp/tensorboard_log', sess.graph)

Then you just need to run tensorboard --logdir tmp/tensorboard_log and go in your browser to localhost:6006/#graphs.

Upvotes: 3

Related Questions