1
votes

I have regression problem, where there are around 20 features, the expected output is prices(in float). Can I use Convolutional neural network here to predict the prices. I used both 1D,2D convolution.

But I get below errors,

For 2D,error is

ValueError: Input 0 of layer sequential_4 is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: (None, 18)

For 1D, error is

ValueError: Input 0 of layer sequential_4 is incompatible with the layer: : expected min_ndim=3, found ndim=2. Full shape received: (None, 18)

Can I use CNN for data other than images? What I am missing here. Please help here.

Below is the code,

model2 = tf.keras.Sequential()
model2.add(tf.keras.layers.Conv1D(32,kernel_size=(3),strides=1,                                activation='relu'))
model2.add(tf.keras.layers.BatchNormalization())
model2.add(tf.keras.layers.Conv1D(64, kernel_size=(3), strides=(2)))
model2.add(tf.keras.layers.ReLU())
model2.add(tf.keras.layers.BatchNormalization())
model2.add(tf.keras.layers.Dense(1, activation='linear'))
model2.compile(optimizer='adam',loss='mean_absolute_error',metrics['mean_absolute_error'])
1
I found the issue. There was issue in model.fit. Instead of calling model.fit(X_train,y_train,val=(X_test,y_test)). I had called in this way model.fit((X_train,y_train), val=(X_test,y_Test)). Model was trying to call it as fit_generator instead of fit because of the extra bracket.Coder

1 Answers

0
votes

I found the issue. There was issue in model.fit. Instead of calling model.fit(X_train,y_train,val=(X_test,y_test)). I had called in this way model.fit((X_train,y_train), val=(X_test,y_Test)). Model was trying to call it as fit_generator instead of fit because of the extra bracket.