Can someone explain to me what happens when a keras Conv1D layer is fed 2D input? Such as:
model=Sequential()
model.add(Conv1D(input_shape=(9000,2),kernel_size=200,strides=1,filters=20))
Varying the input size between (9000,1) and (9000,2) and calling model.summary(), I see that the output shape stays the same, but the number of parameters changes. So, does that mean that different filters are trained for each channel, but the output is summed/averaged across the 2nd dimension before outputting? Or what?
We can see that the 2D in Conv2D means each channel in the input and filter is 2 dimensional(as we see in the gif example) and 1D in Conv1D means each channel in the input and filter is 1 dimensional(as we see in the cat and dog NLP example).
The convolutional kernel moves in 3-direction (x,y,z) to calculate the convolutional output. Use Case: Conv3D is mostly used with 3D image data such as Magnetic Resonance Imaging (MRI) or Computerized Tomography (CT) Scan.
kernel_size: An integer or tuple/list of a single integer, specifying the length of the 1D convolution window. strides: An integer or tuple/list of a single integer, specifying the stride length of the convolution. Specifying any stride value != 1 is incompatible with specifying any dilation_rate value != 1.
First, we'll load the dataset and check the x input dimensions. The next important step is to reshape the x input data. We'll create one-dimensional vectors from each row of x input data. We'll check the labels of y output data and find out the class numbers that will be defined in a model output layer.
Here is a visual illustration
kernel_size = (2, )
-------------
| 1 1 1 1 1 | <---- kernel dim = kernel_size X 5
| 2 2 2 2 2 |
-------------
3 3 3 3 3
--------------------------
| 1 1 1 1 1 1 1 1 1 1 1 1 | <---- kernel dim = kernel_length X 12
| 2 2 2 2 2 2 2 2 2 2 2 2 | i.e more params! but after
-------------------------- you apply say MaxPool1D(pool_size=(2,2))
3 3 3 3 3 3 3 3 3 3 3 3 in both cases, then layer shapes from here
on out are the same, thus same outputs!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With