Python - RNN LSTM模型精度低

问题描述 投票:0回答:1

我试图用这个数据集样本构建LSTM模型

(患者数量,以毫米/秒为单位的时间,X Y和Z的归一化,峰度,偏斜度,俯仰,滚动和偏航,标签)。

1,15,-0.248010047716,0.00378335508419,-0.0152548459993,-86.3738760481,0.872322164158,-3.51314800063,0

1,31,-0.248010047716,0.00378335508419,-0.0152548459993,-86.3738760481,0.872322164158,-3.51314800063,0

1,46,-0.267422664673,0.0051143782875,-0.0191247001961,-85.7662354031,1.0928406847,-4.08015176908,0

1,62,-0.267422664673,0.0051143782875,-0.0191247001961,-85.7662354031,1.0928406847,-4.08015176908,0

这就是我对代码所做的

np.random.seed(7)

train = np.loadtxt("featwithsignalsTRAIN.txt", delimiter=",")
test = np.loadtxt("featwithsignalsTEST.txt", delimiter=",")

x_train = train[:,[2,3,4,5,6,7]]
x_test = test[:,[2,3,4,5,6,7]]
y_train = train[:,8]
y_test = test[:,8]

x_train = x_train.reshape((-1,1,6))

model = Sequential()
model.add(LSTM(64,activation='relu',input_shape=(1, 6)))
model.add(Dense(1, activation='softmax'))

model.compile(loss='binary_crossentropy',
              optimizer='adam',
              metrics=['accuracy'])

model.fit(x_train, y_train, batch_size = 128, epochs = 10, verbose = 2)

没有错误,但准确度非常低,损失非常高

Epoch 1/20 - 63s - 损失:15.0343 - acc:0.0570 Epoch 2/20 - 60s - 损失:15.0343 - acc:0.0570 Epoch 3/20 - 60s - 损失:15.0343 - acc:0.0570 Epoch 4/20 - 60s - 损失:15.0343 - acc:0.0570

keras deep-learning lstm rnn
1个回答
0
投票

这里的错误是使用softmax激活函数,因为它用于分类问题..但这是一个二元问题所以最好的激活函数是sigmoid

© www.soinside.com 2019 - 2024. All rights reserved.