未验证 提交 01a78323 编写于 作者: Z zhongpu 提交者: GitHub

API/OP (Conv2DTranspose) error message enhancement (#23590)

* error message enhancement for Conv2DTranspose, test=develop

* fix error_message, test=develop
上级 e4f1b1c5
......@@ -2458,6 +2458,10 @@ class Conv2DTranspose(layers.Layer):
return dygraph_utils._append_activation_in_dygraph(
pre_act, act=self._act)
check_variable_and_dtype(input, 'input',
['float16', 'float32', 'float64'],
"Conv2DTranspose")
inputs = {'Input': [input], 'Filter': [self.weight]}
attrs = {
'output_size': self._output_size,
......
......@@ -617,6 +617,28 @@ class TestLayer(LayerTest):
self.assertTrue(
np.array_equal(conv2d1.bias.numpy(), conv2d2.bias.numpy()))
with self.static_graph():
# the input of Conv2DTranspose must be Variable.
def test_Variable():
images = np.ones([2, 3, 5, 5], dtype='float32')
conv2d = nn.Conv2DTranspose(
num_channels=3, num_filters=3, filter_size=[2, 2])
conv2d_ret1 = conv2d(images)
self.assertRaises(TypeError, test_Variable)
# the input dtype of Conv2DTranspose must be float16 or float32 or float64
# float16 only can be set on GPU place
def test_type():
images = layers.data(
name='pixel', shape=[3, 5, 5], dtype='int32')
conv2d = nn.Conv2DTranspose(
num_channels=3, num_filters=3, filter_size=[2, 2])
conv2d_ret2 = conv2d(images)
self.assertRaises(TypeError, test_type)
def test_bilinear_tensor_product(self):
inp_np_x = np.array([[1, 2, 3]]).astype('float32')
inp_np_y = np.array([[4, 5, 6]]).astype('float32')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册