I have to train a model to classify time-series data. There are 6 classes in this data, that is why I have encoded them with one-hot-encoder. The only input feature is the "ecg" column which consists of row vectors. The data looks like this;
                                               ecg      0  1  2  3  4  5
0    [[0.1912, 0.3597, 0.3597, 0.3597, 0.3597, 0.35...  1  0  0  0  0  0
1    [[0.2179, 0.4172, 0.4172, 0.4172, 0.4172, 0.41...  1  0  0  0  0  0
2    [[0.1986, 0.3537, 0.3537, 0.3537, 0.3537, 0.35...  0  1  0  0  0  0
3    [[0.2808, 0.5145, 0.5145, 0.5145, 0.5145, 0.51...  0  1  0  0  0  0
4    [[0.1758, 0.2977, 0.2977, 0.2977, 0.2977, 0.29...  0  0  1  0  0  0
5    [[0.2183, 0.396, 0.396, 0.396, 0.396, 0.396, 0...  0  0  1  0  0  0
6    [[0.204, 0.3869, 0.3869, 0.3869, 0.3869, 0.386...  0  0  0  1  0  0
7    [[0.1695, 0.2823, 0.2823, 0.2823, 0.2823, 0.28...  0  0  0  1  0  0
8    [[0.2005, 0.3575, 0.3575, 0.3575, 0.3575, 0.35...  0  0  0  0  1  0
9    [[0.1969, 0.344, 0.344, 0.344, 0.344, 0.344, 0...  0  0  0  0  1  0
10   [[0.2312, 0.4141, 0.4141, 0.4141, 0.4141, 0.41...  0  0  0  0  0  1
11   [[0.1862, 0.3084, 0.3084, 0.3084, 0.3084, 0.30...  0  0  0  0  0  1
12   [[0.2605, 0.47, 0.47, 0.47, 0.47, 0.47, 0.3814...  1  0  0  0  0  0
13   [[0.2154, 0.3733, 0.3733, 0.3733, 0.3733, 0.37...  1  0  0  0  0  0
.                            .                          .  .  .  .  .  .
.                            .                          .  .  .  .  .  .
.                            .                          .  .  .  .  .  .
.                            .                          .  .  .  .  .  .
First of all, I have sliced the dataframe to have my train_x and train_y;
train_x = final_dataset.iloc[:,0] #the only input feature is the first column
train_y = final_dataset.iloc[:,1:] # rest of the columns are class labels
After that, I have created my neural network and added layers in it;
model = Sequential()
model.add(Dense(256, input_shape = (1,))) # there is only one input feature
model.add(Activation('relu'))
model.add(Dense(256))
model.add(Activation('relu'))
model.add(Dense(128))
model.add(Activation('relu'))
model.add(Dense(3, activation='softmax'))
As you can see above, I have set the input_shape as 1, because there is only one input feature which is the ecg column. After all of that, I am starting to train my model;
adam = keras.optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=None, decay=0.0, amsgrad=False)
model.compile(optimizer = adam, loss = 'categorical_crossentropy', metrics = ['accuracy'])
model.fit(train_x,train_y,epochs = 500, batch_size = 32, validation_split = 0.3)
I have used the categorical-crossentropy as my loss function. When I run my code, I am having the following error;
Error when checking target: expected dense_4 to have shape (3,) but got array with shape (6,)
I am pretty new to Keras, so I couldn't figure it out what causes the problem and How can I fix it. Any help is appreciated, thanks in advance.