Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in AI and Deep Learning by (120 points)

I have a dataset with 367 patients that each of them has 9 visits( in general 3303 rows) with 20 features. I want to train a CNN model on that and at the end find the most important features in each time point which has the most significant impact on patient classification.

my model architecture is in the following:

model = Sequential()
model.add(Conv2D(filters=64, kernel_size=(9,1), padding='same',activation='relu', input_shape=(1,9,20)))
model.add(Dropout(0.4))
model.add(Conv2D(filters=128, kernel_size=(7,1),padding='same', activation='relu'))
model.add(Dropout(0.4))
model.add(Conv2D(512, (1,1), activation='relu'))
model.add(Reshape((1*9 , 512)))
model.add(Conv1D(512, kernel_size=9, padding='same', activation='relu'))
model.add(Dropout(0.4))
model.add(Flatten())
model.add(Dense(128, activation='relu', kernel_regularizer=l2(0.2), bias_regularizer=l2(0.2)))
model.add(Dense(train_set_y.shape[1], activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
model.fit(train_set_x, train_set_y, epochs=300, verbose=1)

and here is my model summary:

Model: "sequential_3"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
conv2d_7 (Conv2D)            (None, 1, 9, 64)          11584     
_________________________________________________________________
dropout_7 (Dropout)          (None, 1, 9, 64)          0         
_________________________________________________________________
conv2d_8 (Conv2D)            (None, 1, 9, 128)         57472     
_________________________________________________________________
dropout_8 (Dropout)          (None, 1, 9, 128)         0         
_________________________________________________________________
conv2d_9 (Conv2D)            (None, 1, 9, 512)         66048     
_________________________________________________________________
reshape_3 (Reshape)          (None, 9, 512)            0         
_________________________________________________________________
conv1d_3 (Conv1D)            (None, 9, 512)            2359808   
_________________________________________________________________
dropout_9 (Dropout)          (None, 9, 512)            0         
_________________________________________________________________
flatten_3 (Flatten)          (None, 4608)              0         
_________________________________________________________________
dense_5 (Dense)              (None, 128)               589952    
_________________________________________________________________
dense_6 (Dense)              (None, 9)                 1161      
=================================================================
Total params: 3,086,025
Trainable params: 3,086,025
Non-trainable params: 0
_________________________________________________________________

but when I want to train my model, I get this error : 
ValueError: Input arrays should have the same number of samples as target arrays. Found 367 input samples and 3303 target samples.

I know that the number of both target and independent variable should be the same, but it is important to separate the patients based on their 9 visits.
Moreover, when I reshape the target variable to have the same number of sample (367 instead of 3303), I get this error:
ValueError: Error when checking target: expected dense_4 to have 2 dimensions, but got array with shape (367, 9, 3).

Can anyone help me in this regard?
Any kind of help is appreciated in advance.
 

Please log in or register to answer this question.

Browse Categories

...