I have 400 input features and 1 output value for every record and 1000 records. I want to apply CNN, please anyone tell how I fit the convolution layer? Should I use 1D or 2D convolution?
A 1D convolution is used for time series , vector data, NLP, and the kernal moves in one direction right to left(vector/feature values) as in your case.
For 2D kernel moves in 2 directions with high x width , which mostly used in Image classification.
however , you could also try to use 2D , by reshaping your feature/vector for each record to be 20*20 (W*H).
It all depends on how you want to process your data.
Indeed, usually we consider time series as 1-dimensional data and images as 2-dimensional. But it is not "a must" because reshaping time series, as mentioned above, can result in 2-D image and considering RGB channel in 2-D image will result in 3-D data.
Here, an example of CNN running on time series of ECG signals. Each ECG signal consists of 12 leads (12 time series in fact). These 12 leads are "glued" together to create a 2-D "image" and they are processed by CNN in this form:
The difference between 1D and 2D Convolutional Kernels is the direction of filter/kernel moving along the axis. First, you need to understand why are you using CNN. In fact, a CNN tries to find a similar pattern between with the kernel and input data. So, my suggestion is to visualize your data. If this pattern lies in one axis, use 1D CL, otherwise 2D.
I recommend to read this article for more information:
[Intuitive understanding of 1D, 2D, and 3D convolutions in convolutional neural networks] wandb.ai/ayush-thakur/dl-question-bank/reports/Intuitive-understanding-of-1D-2D-and-3D-convolutions-in-convolutional-neural-networks---VmlldzoxOTk2MDA
On the other hand, what these 400 features really are? If they are not a consistent (continuous) data series (e.g., time series, image) then one shall re-think if CNN is needed. In case of a vector of uncorrelated features other approach may be as same or more effective but less complex - few short examples, using multilayer perceptron and autoencoders:
Just think about what convolutional process simply does ,it will clear your conception while deciding which type of convolution you want to use.
What is Convolution process does is that it runs a filter through the data and try to find pattern and generalizes it. This pattern depends on the correlation between data. If your data changes with respect to one axis then you will run 1d convolution which means on time series
If data is spread is in 2D vector space(like images if you plot) then simply use 2d convolution example-images.
But there are also cases like ECG signals which are composed with 12 time series where there are correlation between different time series then you may want to you 2D convolution to get better result(2D convolution will help to find inter-series correlation or pattern).
But there are also cases like ECG signals which are composed with 12 time series where there are correlation between different time series then you may want to you 2D convolution to get better result(2D convolution will help to find inter-series correlation or pattern).