I've dataset which contains dlib landmark points of the faces. I'm using keras to train a model.

The dataset shape is (length_of_dataset,68,2). I know that I've two options.

  • The first is using conv1d with input_shape = (68,2).
  • The second is using conv2d with input_shape = (1,68,2).

My question is which one is better? And why?

  • $\begingroup$ What do you intend to do with your model ? What is the purpose of your training ? $\endgroup$
    – ma3oun
    May 31 '18 at 14:37

When using Conv2D , the input_shape does not have to be (1,68,2). The number of samples does not have anything to do with the convolution, one sample is given to the layer at each time anyway.

What changes is the number of spatial dimensions of your input that is convolved:

  • With Conv1D, one dimension only is used, so the convolution operates on the first axis (size 68).
  • With Conv2D, two dimensions are used, so the convolution operates on the two axis defining the data (size (68,2))

Therefore you have to carefully chose the filter size. For instance, if you chose a Conv2D with a filter size (4,2), it will produce the same results as a Conv1D with size (4) as it will operate fully on the second axis of data.

Finally, there is no response to what is the best method. Generally, Conv2D work well on images and Conv1D on text. Given the size of your second dimension of data, Conv2D does not seem to make a lot of sense hence Conv1D should work well.


In summary, In 1D CNN, kernel moves in 1 direction. Input and output data of 1D CNN is 2 dimensional. Mostly used on Time-Series data.

In 2D CNN, kernel moves in 2 directions. Input and output data of 2D CNN is 3 dimensional. Mostly used on Image data.

In 3D CNN, kernel moves in 3 directions. Input and output data of 3D CNN is 4 dimensional. Mostly used on 3D Image data (MRI, CT Scans).

You can find more details here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.