forked from somaticio/tensorflow.rb
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23c6833
commit 41dd55f
Showing
8 changed files
with
280 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
require 'spec_helper' | ||
describe 'Operation' do | ||
it 'Should ensure that the Graph is not garbage collected while the program still has access to the Operation' do | ||
it 'Should ensure that the Graph is not garbage collected while the program still has access to the Operation' do | ||
graph = Tensorflow::Graph.new | ||
tensor_1 = Tensorflow::Tensor.new([[ 1, 3, 5], [2, 4, 7]]) | ||
tensor_1 = Tensorflow::Tensor.new([[1, 3, 5], [2, 4, 7]]) | ||
placeholder_1 = graph.placeholder('tensor1', tensor_1.type_num) | ||
expect(placeholder_1.operation.name).to match('tensor1') | ||
expect(placeholder_1.operation.type).to match('Placeholder') | ||
end | ||
end | ||
|
||
it 'Should Test Operation Output List Size' do | ||
it 'Should Test Operation Output List Size' do | ||
graph = Tensorflow::Graph.new | ||
tensor_1 = Tensorflow::Tensor.new(1) | ||
tensor_2 = Tensorflow::Tensor.new([[1,2], [3,4]]) | ||
const_1 = graph.const("const1", tensor_1) | ||
const_2 = graph.const("const2", tensor_2) | ||
tensor_2 = Tensorflow::Tensor.new([[1, 2], [3, 4]]) | ||
const_1 = graph.const('const1', tensor_1) | ||
const_2 = graph.const('const2', tensor_2) | ||
opspec = Tensorflow::OpSpec.new('Addition_of_tensors', 'ShapeN', nil, nil, [const_1, const_2]) | ||
op = graph.AddOperation(opspec) | ||
n = op.output_list_size("output") | ||
n = op.output_list_size('output') | ||
expect(n).to match(2) | ||
expect(op.num_outputs).to match(2) | ||
end | ||
end | ||
|
||
#TODO: If and when the API to get attributes is added add a test to check it. | ||
# TODO: If and when the API to get attributes is added add a test to check it. | ||
it 'Should Test Operation DataType' do | ||
graph = Tensorflow::Graph.new | ||
tensor_1 = Tensorflow::Tensor.new(1) | ||
const_1 = graph.const("const1", tensor_1) | ||
expect(const_1.dataType).to match(9) # TF_INT64 => 9 | ||
graph = Tensorflow::Graph.new | ||
tensor_1 = Tensorflow::Tensor.new(1) | ||
const_1 = graph.const('const1', tensor_1) | ||
expect(const_1.dataType).to match(9) # TF_INT64 => 9 | ||
end | ||
|
||
it 'Should Test Operation DataType' do | ||
graph = Tensorflow::Graph.new | ||
tensor_1 = Tensorflow::Tensor.new(1.232) | ||
const_1 = graph.const("const1", tensor_1) | ||
expect(const_1.dataType).to match(2) # TF_DOUBLE => 2 | ||
graph = Tensorflow::Graph.new | ||
tensor_1 = Tensorflow::Tensor.new(1.232) | ||
const_1 = graph.const('const1', tensor_1) | ||
expect(const_1.dataType).to match(2) # TF_DOUBLE => 2 | ||
end | ||
#TODO: Add Shape method and tests. | ||
# TODO: Add Shape method and tests. | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
require 'spec_helper' | ||
# TODO: Check std::pair in savedmodel. | ||
describe "Savedmodel" do | ||
it "Load Saved model" do | ||
bundle = Tensorflow::Savedmodel.new() | ||
bundle.LoadSavedModel(File.dirname(__FILE__)+'/testdata/half_plus_two/00000123',["serve"], nil) | ||
bundle.graph.operation('y') | ||
end | ||
describe 'Savedmodel' do | ||
it 'Load Saved model' do | ||
bundle = Tensorflow::Savedmodel.new | ||
bundle.LoadSavedModel(File.dirname(__FILE__) + '/testdata/half_plus_two/00000123', ['serve'], nil) | ||
bundle.graph.operation('y') | ||
end | ||
end |
Oops, something went wrong.