Created by: Aurelius84
fluid.layers.fc:
- Add input type check, error info as follows:
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
with program_guard(Program(), Program()):
input_data = np.random.random((2, 4)).astype("float32")
fluid.layers.fc(input=input_data, size=1)
TypeError: The type of 'input' in fc must be Variable, but received <type 'numpy.ndarray'>
- if input is list, error info as follows:
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
with program_guard(Program(), Program()):
input_data = np.random.random((2, 4)).astype("float32")
fluid.layers.fc(input=[input_data], size=1)
TypeError: The type of input[0] in fc must be Variable, but received <type 'numpy.ndarray'>
- Add data type check, error info as follows:
import paddle.fluid as fluid
from paddle.fluid import Program, program_guard
with program_guard(Program(), Program()):
x = fluid.data(name='x', shape=[3,4],dtype='int32')
fluid.layers.fc(input=x, size=1)
TypeError: The data type of 'input' in fc must be float32 or float64, but received int32.
sum OP:Enhance error message in InferShape of SumOp
- should have same shape
import paddle.fluid as fluid
import paddle.fluid.layers as layers
import numpy as np
input0 = layers.data(name="input0", shape=[-1,13], dtype='float32')
input1 = layers.data(name="input1", shape=[-1,13], dtype='float32')
out = layers.sum([input0, input1])
place = fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
input0_data = np.random.random([6, 13]).astype("float64")
input1_data = np.random.random([2, 13]).astype("float64")
ret = exe.run(
feed={
'input0': input0_data,
'input1': input1_data
},
fetch_list=[out],
return_numpy=False)
before: PaddleCheckError: Expected in_dim == x_dim, but received in_dim:6, 13 != x_dim:2, 13.
after: ShapeError: The input tensor X of SumOp must have same shape.But received X[0]'s shape = [6, 13], X[1]'s shape = [2, 13].
- should have same dimensions
ShapeError: The input tensor X of SumOp must have same shape.But received X[0]'s shape = [6, 13], X[1]'s shape = [2, 13]
before: PaddleCheckError: Expected in_dim[j] == x_dim[j], but received in_dim[j]:12 != x_dim[j]:13
after: ShapeError: The input tensor X of SumOp must have same shape if not -1.But received X[0]'s shape = [-1, 12], X[1]'s shape = [-1, 13].
ShapeError: The input tensor X of SumOp must have same shape.But received X[0]'s shape = [6, 13], X[1]'s shape = [2, 13]
before: PaddleCheckError: Expected in_dim.size() == x_dim.size(), but received in_dim.size():3 != x_dim.size():2
after: ShapeError: The input tensor X of SumOp must have same dimensions. But received X[0]'s dimensions = 3, X[0]'s shape = [-1, 12, 13], X[1]'s dimensions = 2, X[1]'s shape = [-1, 13]