Skip to content

Commit bbe28da

Browse files
Added test functions in convolutional_test.py and local_test.py
1 parent 834c9bb commit bbe28da

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tensorflow/python/keras/layers/convolutional_test.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ def fn(inpt):
166166
fn(inpt2)
167167
self.assertEqual(outp1_shape, layer(inpt1).shape)
168168

169+
def test_conv1d_valid_output_shapes(self):
170+
kwargs = {'filters': 2 , 'kernel_size': 10}
171+
with self.assertRaises(ValueError):
172+
keras.layers.Conv1D(**kwargs)
173+
169174

170175
@keras_parameterized.run_all_keras_modes
171176
class Conv2DTest(keras_parameterized.TestCase):
@@ -298,6 +303,11 @@ def test_conv2d_zero_kernel_size(self):
298303
with self.assertRaises(ValueError):
299304
keras.layers.Conv2D(**kwargs)
300305

306+
def test_conv2d_valid_output_shapes(self):
307+
kwargs = {'filters': 2 , 'kernel_size': 10}
308+
with self.assertRaises(ValueError):
309+
keras.layers.Conv2D(**kwargs)
310+
301311

302312
@keras_parameterized.run_all_keras_modes
303313
class Conv3DTest(keras_parameterized.TestCase):
@@ -433,6 +443,11 @@ def test_conv3d_dynamic_shape(self):
433443
input_shape=(None, 3, None, None, None),
434444
input_data=input_data)
435445

446+
def test_conv3d_valid_output_shapes(self):
447+
kwargs = {'filters': 2 , 'kernel_size': 10}
448+
with self.assertRaises(ValueError):
449+
keras.layers.Conv3D(**kwargs)
450+
436451

437452
@keras_parameterized.run_all_keras_modes(always_skip_v1=True)
438453
class GroupedConvTest(keras_parameterized.TestCase):
@@ -518,6 +533,11 @@ def test_conv1d_transpose(self, kwargs, expected_output_shape=None):
518533
test.is_gpu_available(cuda_only=True)):
519534
self._run_test(kwargs, expected_output_shape)
520535

536+
def test_conv1dtranspose_valid_output_shapes(self):
537+
kwargs = {'filters': 2 , 'kernel_size': 10}
538+
with self.assertRaises(ValueError):
539+
keras.layers.Conv1DTranspose(**kwargs)
540+
521541

522542
@keras_parameterized.run_all_keras_modes
523543
class Conv3DTransposeTest(keras_parameterized.TestCase):
@@ -551,6 +571,11 @@ def test_conv3d_transpose(self, kwargs, expected_output_shape=None):
551571
if 'data_format' not in kwargs or test.is_gpu_available(cuda_only=True):
552572
self._run_test(kwargs, expected_output_shape)
553573

574+
def test_conv3dtanspose_valid_output_shapes(self):
575+
kwargs = {'filters': 2 , 'kernel_size': 10}
576+
with self.assertRaises(ValueError):
577+
keras.layers.Conv3DTranspose(**kwargs)
578+
554579

555580
@keras_parameterized.run_all_keras_modes
556581
class ConvSequentialTest(keras_parameterized.TestCase):

tensorflow/python/keras/layers/local_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ def test_locallyconnected_1d_regularization(self, data_format, padding,
158158
self.assertEqual(layer.kernel.constraint, k_constraint)
159159
self.assertEqual(layer.bias.constraint, b_constraint)
160160

161+
def test_locallyconnected1d_valid_output_shapes(self):
162+
kwargs = {'filters': 2 , 'kernel_size': 10}
163+
with self.assertRaises(ValueError):
164+
keras.layers.LocallyConnected1D(**kwargs)
165+
161166

162167
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
163168
class LocallyConnected2DLayersTest(test.TestCase, parameterized.TestCase):
@@ -265,6 +270,12 @@ def test_locallyconnected_2d_regularization(self, data_format, padding,
265270
self.assertEqual(layer.kernel.constraint, k_constraint)
266271
self.assertEqual(layer.bias.constraint, b_constraint)
267272

273+
def test_locallyconnected2d_valid_output_shapes(self):
274+
kwargs = {'filters': 2 , 'kernel_size': 10}
275+
with self.assertRaises(ValueError):
276+
keras.layers.LocallyConnected2D(**kwargs)
277+
278+
268279

269280
@combinations.generate(combinations.combine(mode=['graph', 'eager']))
270281
class LocallyConnectedImplementationModeTest(test.TestCase,

0 commit comments

Comments
 (0)