Skip to content

Instantly share code, notes, and snippets.

@arafatkatze
Last active January 4, 2017 05:21
Show Gist options
  • Save arafatkatze/d6b5f7265dc02ceb2b38484965806eb1 to your computer and use it in GitHub Desktop.
Save arafatkatze/d6b5f7265dc02ceb2b38484965806eb1 to your computer and use it in GitHub Desktop.
require 'tensorflow'
graph = Tensorflow::Graph2.new
tensor_1 = Tensorflow::Tensor.new([2,3,4,6])
tensor_2 = Tensorflow::Tensor.new([2,3,4,6])
const_1 = graph.const("m1", tensor_1)
const_2 = graph.const("m2", tensor_2)
opec = Tensorflow::OpSpec.new
opec.name = "Additionofconstants"
opec.type = "Add"
opec.input = [const_1, const_2]
op = graph.AddOperation(opec)
session_op = Tensorflow::Session_options.new
sess = Tensorflow::Session.new(graph, session_op)
out_tensor = sess.run([],[op.output(0)],[])
graph.write_file("proto")
print out_tensor, "\n"
# [[4, 6, 8, 12]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment