Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (29 sloc) 1.93 KB


Using Tensorboard with Tensorflow.rb is very easy. To make use of tensorboard. First, please make sure that you have installed tensorflow completely and tensorflow.rb is working on your system. I will walk you through a very simple example.
Consider the function

require 'tensorflow'
graph =
tensor_1 =[[2, 23, 10, 6]])
tensor_2 =[[22, 3, 7, 12]])
placeholder_1 = graph.placeholder('tensor1', tensor_1.type_num)
placeholder_2 = graph.placeholder('tensor2', tensor_2.type_num)
opspec ='Addition_of_tensors', 'Add', nil, [placeholder_1, placeholder_2])

op = graph.AddOperation(opspec)
session_op =
session =, session_op)
hash = {}
hash[placeholder_1] = tensor_1
hash[placeholder_2] = tensor_2
out_tensor =, [op.output(0)], [])
puts out_tensor[0]

This example is very simple and easy to understand. A graph just adds takes two tensors and adds them. If you look at the last line that says graph.write_file("addition.pb")
Here I am saving the graph defination in protobuf format in the file addition.pb Now you can use the file and convert the addition.pb to a format understandable by tensorboard. You can change directory and filename variable as per your convinience. After running the file on your file a new directory will be made as specified in the directory variable and then you can run tensorboard by running the command tensorboard --logdir=directory. Example if you directory is /home/arafat/Desktop/test then the command must be run as tensorboard --logdir=/home/arafat/Desktop/test