我正在训练一个由信号数据组成的模型,并且是多维的。
我处理了数据,它包含179个样本。
The following is the shape of the data.
f1 = f1.reshape((179, 15, 1, 5120))
f2 = f2.reshape((179, 15, 1, 5120))
f3 = f3.reshape((179, 15, 1, 5120))
是功能,下面是标签。
# One hot encoding, multi classification
l1 = np_utils.to_categorical(l1)
l2 = np_utils.to_categorical(l2)
l3 = np_utils.to_categorical(l3)
所以我的功能和标签的形状是:
(179, 15, 1, 5120)
(179, 15, 1, 5120)
(179, 15, 1, 5120)
(179, 3)
(179, 3)
(179, 3)
我正在使用以下keras CNN模型的架构
from sklearn.metrics import cohen_kappa_score, make_scorer
kappa_scorer = make_scorer(cohen_kappa_score)
sgd = SGD(lr = 0.01, decay=1e-6, momentum=0.5, nesterov=True)
def baseline_model():
# create model
model = Sequential()
model.add(Conv2D(64, (3, 1), border_mode="same", input_shape=(15, 1, 5120), kernel_initializer='glorot_uniform'))
model.add(MaxPool2D(pool_size=(1,1)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(64))
model.add(Dropout(0.25))
model.add(Dense(32))
model.add(Dense(3, activation="softmax"))
model.compile(loss="categorical_crossentropy", optimizer=sgd, metrics=['accuracy'])
return model
现在,我训练我的模型,
# Fit the model
model.fit(f3, l3, epochs=200, batch_size=5)
这是结果。 它继续这样,数据全部是数字。 我想优化我的模型。不知道如何继续。
Epoch 1/200
179/179 [==============================] - 9s 50ms/step - loss: 9.6746 - acc: 0.3799
Epoch 2/200
179/179 [==============================] - 8s 43ms/step - loss: 10.1751 - acc: 0.3687
Epoch 3/200
179/179 [==============================] - 8s 43ms/step - loss: 10.1751 - acc: 0.3687
Epoch 4/200
179/179 [==============================] - 8s 47ms/step - loss: 10.1751 - acc: 0.3687
Epoch 5/200
179/179 [==============================] - 9s 48ms/step - loss: 10.1751 - acc: 0.3687