Python-RNN LSTM模型精度低 [英] Python - RNN LSTM model low accuracy
问题描述
我尝试使用此数据集样本构建LSTM模型
I have tried to build LSTM model with this sample of dataset
(患者编号,以毫秒/秒为单位的时间,X Y和Z的归一化, 峰度,偏度,俯仰,横摇和偏航,标签).
(patient number, time in mill/sec., normalization of X Y and Z, kurtosis, skewness, pitch, roll and yaw, label) respectively.
1,15,-0.248010047716,0.00378335508419,-0.0152548459993,-86.3738760481,0.872322164158,-3.51314800063,0
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,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,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
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)
没有错误,但准确性很低,损失也很高
there is no error but the accuracy is very low and the loss is very high
史诗1/20 -63秒-损失:15.0343-累计:0.0570时期2/20 -60s-损失:15.0343-acc:0.0570时期3/20 -60s-损失:15.0343-acc:0.0570时期4/20 -60s-损失:15.0343-acc:0.0570
Epoch 1/20 - 63s - loss: 15.0343 - acc: 0.0570 Epoch 2/20 - 60s - loss: 15.0343 - acc: 0.0570 Epoch 3/20 - 60s - loss: 15.0343 - acc: 0.0570 Epoch 4/20 - 60s - loss: 15.0343 - acc: 0.0570
推荐答案
这里的错误是使用softmax激活函数,因为它用于分类问题.但这是一个二进制问题,因此是最好的激活函数是乙状结肠
the wrong here is the use of the softmax activation function,, because it is used for categorical problems.. but this is a binary problem so the best activation function is the sigmoid
这篇关于Python-RNN LSTM模型精度低的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!