3D-Convnet-for-Alzheimer-s-Detection icon indicating copy to clipboard operation
3D-Convnet-for-Alzheimer-s-Detection copied to clipboard

Input Error

Open elJonathan opened this issue 4 years ago • 4 comments

I am getting error in the code for inputs. Please let me know the dimensions of the images that you are using as I am getting the following error. ValueError: Error when checking input: expected input to have 5 dimensions, but got array with shape(160, 1)

elJonathan avatar Mar 07 '20 10:03 elJonathan

It seems that you may not be providing a 3D images as input. Typically the network requires a 5 dimensional input: 3 dimensions of the image, 1 dimension for channel and 1 dimension for the batch size. I don't remember exactly what the size of each dimension was, but this code is adaptable to different sizes as long as the number of dimensions are valid.

RishalAggarwal avatar Mar 09 '20 13:03 RishalAggarwal

Hello Rishal,

I have a problem with the input shape for the model. According to the "training cnn.py" script, my input images are :(12, 106, 106, 120) in shape. Next, in "tflearn.input_data(shape=[None, sh[1], sh[2], sh[3], sh[4]])" layer, I don't understand 4th dimension. And is my image's shape correct?

can you please explain that?

MohammadSalehi72 avatar Sep 26 '20 18:09 MohammadSalehi72

You need to add a dimension to the images which will correspond to the channels (analogous to RGB in a regular 2D image)

RishalAggarwal avatar Nov 03 '20 07:11 RishalAggarwal

Hi Rishal,

My input shape is ((1, 96, 96, 60),3). model=ResnetBuilder.build_resnet_34((1,96,96,60),3). Facing below error.

Traceback (most recent call last): File "train_resnet.py", line 269, in model=ResnetBuilder.build_resnet_34((1,96,96,60),3) File "train_resnet.py", line 255, in build_resnet_34 return ResnetBuilder.build(input_shape, num_outputs, basic_block, [3, 4, 6, 3]) File "train_resnet.py", line 233, in build block = _residual_block(block_fn, filters=filters, repetitions=r, is_first_layer=(i == 0))(block) File "train_resnet.py", line 120, in f is_first_block_of_first_layer=(is_first_layer and i == 0))(input) File "train_resnet.py", line 144, in f return _shortcut(input, residual) File "train_resnet.py", line 106, in _shortcut kernel_regularizer=l2(0.0001))(input) File "/data/users/dverma01/conda/envs/gcolab/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 897, in call self._maybe_build(inputs) File "/data/users/dverma01/conda/envs/gcolab/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 2416, in _maybe_build self.build(input_shapes) # pylint:disable=not-callable File "/data/users/dverma01/conda/envs/gcolab/lib/python3.6/site-packages/tensorflow/python/keras/layers/convolutional.py", line 190, in build data_format=self._conv_op_data_format) File "/data/users/dverma01/conda/envs/gcolab/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 1066, in init num_spatial_dims, strides, dilation_rate) File "/data/users/dverma01/conda/envs/gcolab/lib/python3.6/site-packages/tensorflow/python/ops/nn_ops.py", line 755, in _get_strides_and_dilation_rate raise ValueError("all values of strides must be positive") ValueError: all values of strides must be positive

Any input is highly appreciated. Thanks!

dilipv09 avatar Jan 22 '21 19:01 dilipv09