我是在keras中使用LSTM的新手。
我想知道您的宝贵信息,以改进我的模型。
我想使用LSTM进行分类,因为我的训练数据是连续的。
我的数据包含车辆CAN信号,动态数据。
X.shape = (195,100,4)
# 195 segments, each segment is of shape 100*4
# every row in 100*4 corresponds to each Time step
# each time step in 100*4 represented as t1, t2, t3,.....t100
Y.shape(195,)
# each segment out of 195 segments belongs to either 0 or 1 (2 classes)
我想预测该细分受众群属于哪个类别,甚至 在时间步t100之前, 即,@ t60或t70或t80,模型应预测 以上2类。(0或1)
# My Intersection model
input_ = Input(shape=(100,4))
x = LSTM(10, return_sequences= True, activation='tanh')(input_)
# since i Need to predict the class, before the time stamp t100,
# i returned the result for every Time stamp
# and peform Global Max pooling operation.
x = GlobalMaxPool1D()(x)
output = Dense(1, activation="sigmoid")(x)
model = Model(inputs=input_, outputs=output)
model.compile(
loss='binary_crossentropy',
optimizer=Adam(lr=1e-3),
metrics=['accuracy']
)
# Training
r = model.fit(
X,
Y,
batch_size=5,
epochs=100,
validation_split=0.1
)
模型结果:
At the end of 100 epoch
Epoch 100/100
175/175 [==============================] - 7s 38ms/step - loss: 0.4416 - acc: 0.7600 - val_loss: 0.5095 - val_acc: 0.8000
请支持。