Created by: JepsonWong
API/OP (Conv2D) error message enhancement.
- check the input's type is Variable
import paddle.fluid as fluid
from paddle.fluid.dygraph import nn
import numpy as np
images = np.ones([2, 3, 5, 5], dtype='float32')
conv2d = nn.Conv2D(
num_channels=3, num_filters=3, filter_size=[2, 2])
conv2d_ret1 = conv2d(images)
# TypeError: The type of 'input' in Conv2D must be <class 'paddle.fluid.framework.Variable'>, but received <type 'numpy.ndarray'>
- check the input's dtype is in ['float16', 'float32', 'float64']
import paddle.fluid as fluid
from paddle.fluid.dygraph import nn
import numpy as np
images = fluid.layers.data(
name='pixel', shape=[3, 5, 5], dtype='int32')
conv2d = nn.Conv2D(
num_channels=3, num_filters=3, filter_size=[2, 2])
conv2d_ret2 = conv2d(images)
TypeError: The data type of 'input' in Conv2D must be ['float16', 'float32', 'float64'], but received int32.