Skip to content

Instantly share code, notes, and snippets.

@arafatkatze
Last active June 28, 2017 11:23
Show Gist options
  • Save arafatkatze/8c3cb5a6043a334858fc2feb7ba2e596 to your computer and use it in GitHub Desktop.
Save arafatkatze/8c3cb5a6043a334858fc2feb7ba2e596 to your computer and use it in GitHub Desktop.
require 'tensorflow'
graph = Tensorflow::Graph.new
tensor_1 = Tensorflow::Tensor.new([[ [2.0,5.0],
[1.0,-20.0]],
[[124.0,5.0],
[53.0,-2.0]],
[[1.0,0.0],
[0.0,1.0]]
])
placeholder_1 = graph.placeholder('tensor1', tensor_1.type_num)
opspec = Tensorflow::OpSpec.new('Determinant_of_matrix', 'MatrixDeterminant', nil, [placeholder_1])
op = graph.AddOperation(opspec)
session_op = Tensorflow::Session_options.new
session = Tensorflow::Session.new(graph, session_op)
hash = { placeholder_1 => tensor_1 }
result = session.run(hash, [op.output(0)], [])
print result, "\n"
# [[-45.0, -513.0, 1.0]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment