将数据传递给LSTM、的代码
Xres1.shape
(291676, 15)
yres1.shape
(291676,)
n_samples, n_feats = Xres1.shape[0], Xres1.shape[1]
Xres1 = Xres1.reshape((n_samples, n_feats, 1))
yres1 = to_categorical(yres1, 4)
model = Sequential()
model.add(LSTM(n_feats, input_shape=(n_feats, 1)))
model.add(Dense(20))
model.add(Dense(60))
model.add(Dense(80))
model.add(Dense(90))
model.add(Dense(4, activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam')
model.fit(Xres1, yres1, epochs=300, batch_size=15, verbose=2)
属性错误:DataFrame对象没有属性整形
有时整形功能正常工作,有时不正常。
有什么解决方案吗?
Pandas-Dataframe
没有内置的整形函数。使用.values
重塑数据帧
Xres1 = Xres1.values.reshape((n_samples, n_feats, 1))