0

I am having trouble understanding how 2D Conv calculations are done on 4D inputs. Basically, this is the situation, I have an image of height, width, channels = 128, 128, 103. I want each of these 103 channels to be processed individually as if I'm inputting them to the network one by one. Would the following line work?

import tensorflow.keras
from tensorflow.keras.layers import Conv2D
model1 = tensorflow.keras.models.Sequential()
model1.add(Conv2D(1, kernel_size=(3,3), input_shape = (128, 128,103,1), padding='same'))

enter image description here

I want to avoid splitting the image and inputting it into the network as 103 batches of (128,128,1)

Innat
  • 16,113
  • 6
  • 53
  • 101
Nour
  • 197
  • 1
  • 3
  • 13

1 Answers1

0

As explained in the documentation: https://www.tensorflow.org/api_docs/python/tf/keras/layers/Conv2D?version=nightly

4+D tensor with shape: batch_shape + (channels, rows, cols) if data_format='channels_first' or
4+D tensor with shape: batch_shape + (rows, cols, channels) if data_format='channels_last'.

(by default: data_format='channels_last'.)

You are passing a 5D tensor of shape (batch_shape, 128, 128, 103, 1). I suggest you reshape your tensor into something that will yield a shape like this one (None, 128, 128, 103).

Also please change input_shape = (128, 128,103,1) to input_shape = (128, 128,103)