InvalidArgumentError: The input of Op(Conv) should be a 4-D or 5-D Tensor. But received: input's dimension is 3, input's shape is [1, 150, 150]
Created by: SaviorD7
How I can switch dimension of input image data ?
There is my data:
img = fluid.layers.data(name='img', shape=[ 1, 150, 150], dtype='float32')
label = fluid.layers.data(name='label', shape=[1], dtype='int64')
Data format:
{'data': array([[0.07843137, 0.13333333, 0.18039216, ..., 0.30588235, 0.27843137,
0.25882353],
[0.07058824, 0.10588235, 0.16862745, ..., 0.29803922, 0.28235294,
0.25882353],
[0.0745098 , 0.10980392, 0.16470588, ..., 0.29803922, 0.2745098 ,
0.25882353],
...,
[0. , 0. , 0. , ..., 0. , 0. ,
0. ],
[0. , 0. , 0. , ..., 0. , 0. ,
0. ],
[0. , 0. , 0. , ..., 0. , 0. ,
0. ]]), 'label': array([0])}
Uploading data:
data_path_test = '../data/data52182/chest_xray/test'
uploaded_test_data = xray_dataset.upload_data(data_path_test)
def train_test(train_test_program):
acc_set = []
for data in uploaded_test_data:
acc_np = exe.run(program=train_test_program,
feed={'img': np.array([data['data']]), 'label': np.array([data['label']])},
fetch_list=["accuracy_0.tmp_0"])
Get this:
InvalidArgumentError: The input of Op(Conv) should be a 4-D or 5-D Tensor. But received: input's dimension is 3, input's shape is [1, 150, 150].
[Hint: Expected in_dims.size() == 4 || in_dims.size() == 5 == true, but received in_dims.size() == 4 || in_dims.size() == 5:0 != true:1.] at (/paddle/paddle/fluid/operators/conv_op.cc:59)
[operator < conv2d > error]
How can I reshape image [150x150] into 4-D tensor?