Skip to content

Commit

Permalink
Softmaxを除去する処理を消して、デフォルトのallclose範囲で一致することを確認
Browse files Browse the repository at this point in the history
  • Loading branch information
Masato Hori committed Feb 19, 2018
1 parent 46321a9 commit 18dd84b
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions python/test/utils/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,21 +712,6 @@ def test_onnx_nnp_conversion_squeezenet(tmpdir, nnp_fixture):
if show_onnx:
print(model)
img = np.random.rand(1,3,224,224).astype(np.float32)

# Remove Softmax for now.
# This is temporal
nodes = len(model.graph.node)
sm_node = model.graph.node[nodes-1]
def change_to_copy(node):
"""Change node operation to a simple copy"""
# Dropout with is_test=True is equal to a simple copy
node.op_type = "Dropout"
attr = node.attribute.add()
attr.name = "is_test"
attr.type = AttributeProto.INT
attr.i = 1
change_to_copy(sm_node)

c2out = onnx_caffe2.backend.run_model(model, [img])
# Process onnx with naabla
nnp = onnx_model_to_nnp_protobuf(model)
Expand Down Expand Up @@ -761,9 +746,7 @@ def change_to_copy(node):
c2 = c2out[out_name]
if show_output:
print(c2, nnout)
assert c2.shape == nnout.shape
if compare_values:
assert np.allclose(c2, nnout, atol=1e-05)
assert np.allclose(c2, nnout)

def test_nnp_onnx_conversion_squeezenet(tmpdir, nnp_fixture):
nnp_dir = TEST_DATA_DIR
Expand All @@ -775,7 +758,6 @@ def test_nnp_onnx_conversion_squeezenet(tmpdir, nnp_fixture):
show_onnx = False
show_nnp = False
show_output = False
compare_values = True
# Process nnp with nnabla
path = os.path.join(nnp_dir, nnp_name)
nn_net = nnload.load([path])
Expand Down Expand Up @@ -809,6 +791,4 @@ def test_nnp_onnx_conversion_squeezenet(tmpdir, nnp_fixture):
# Compare both naabla and caffe2 results
if show_output:
print(c2, nnout)
assert c2.shape == nnout.shape
if compare_values:
assert np.allclose(c2, nnout, atol=1e-05)
assert np.allclose(c2, nnout)

0 comments on commit 18dd84b

Please sign in to comment.