Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Add test two zeropadding (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiafatom authored Apr 9, 2021
1 parent 63f3b50 commit 383e431
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2638,3 +2638,21 @@ def test_tensor_scatter_update(runner):
tensor_data = np.array([[[6, 5], [6, 6]], [[5, 5], [6, 6]]]).astype(np.float32)
expected = model.predict(tensor_data)
assert runner(onnx_model.graph.name, onnx_model, tensor_data, expected)


def test_two_zero_padding(runner):
def my_func_1(input_layer, nf=64):
temp = keras.layers.Conv2D(filters=nf, kernel_size=(3, 3), strides=(1, 1), padding="same")(input_layer)
pad1 = keras.layers.ZeroPadding2D(padding=((1, 0), (1, 0)))(temp)
pad2 = keras.layers.ZeroPadding2D(padding=((0, 1), (0, 1)))(temp)
conv = keras.layers.Conv2D(filters=nf, kernel_size=(3, 3), strides=(1, 1), padding="valid")
output = keras.layers.concatenate([conv(pad1), conv(pad2)], axis=3)
return output

input1 = Input(shape=(32, 32, 3))
outputs = my_func_1(input1)
model = keras.models.Model(inputs=input1, outputs=outputs)
onnx_model = keras2onnx.convert_keras(model, 'test_two_zero_padding')
data = np.random.rand(1, 32, 32, 3).astype(np.float32)
expected = model.predict(data)
assert runner('test_two_zero_padding', onnx_model, data, expected)

0 comments on commit 383e431

Please sign in to comment.