Parametrized convolutional recurrent tests.
@@ -18,15 +18,16 @@ input_num_col = 5
sequence_len = 2
-def test_convolutional_recurrent():
+@pytest.mark.parametrize('data_format', ['channels_first', 'channels_last'])
+@pytest.mark.parametrize('return_sequences', [True, False])
+@pytest.mark.parametrize('use_mask', [True, False])
+def test_convolutional_recurrent(data_format, return_sequences, use_mask):
class Masking5D(Masking):
"""Regular masking layer returns wrong shape of mask for RNN"""
def compute_mask(self, inputs, mask=None):
return K.any(K.not_equal(inputs, 0.), axis=[2, 3, 4])
- for data_format in ['channels_first', 'channels_last']:
-
if data_format == 'channels_first':
inputs = np.random.rand(num_samples, sequence_len,
input_channel,
@@ -36,8 +37,6 @@ def test_convolutional_recurrent():
input_num_row, input_num_col,
input_channel)
- for use_mask in [False, True]:
- for return_sequences in [True, False]:
# test for return state:
x = Input(batch_shape=inputs.shape)
kwargs = {'data_format': data_format,
@@ -57,8 +56,7 @@ def test_convolutional_recurrent():
assert len(states) == 2
model = Model(x, states[0])
state = model.predict(inputs)
- np.testing.assert_allclose(
- K.eval(layer.states[0]), state, atol=1e-4)
+ np.testing.assert_allclose(K.eval(layer.states[0]), state, atol=1e-4)
# test for output shape:
output = layer_test(convolutional_recurrent.ConvLSTM2D,
