我是使用 Keras 进行预测的初学者。我理解这个概念和它背后的所有理论。但我很难让它运行。在这个阶段我并不担心它的效率,我只是想运行它并看到一个输出,以便我以后可以进化。
我有这个用作 predictor_train (X) 的虚拟 Pandas DataFrame:
Value 1lag 2lag 3lag 4lag...
Date
2005-04-01 231.721933 165.195418 170.418903 225.892387 206.282539
2005-05-01 163.259812 231.721933 165.195418 170.418903 225.892387
2005-06-01 211.649963 163.259812 231.721933 165.195418 170.418903
2005-07-01 249.054951 211.649963 163.259812 231.721933 165.195418
2005-08-01 168.657539 249.054951 211.649963 163.259812 231.721933
2005-09-01 179.623448 168.657539 249.054951 211.649963 163.259812
2005-10-01 228.437842 179.623448 168.657539 249.054951 211.649963
2005-11-01 165.805266 228.437842 179.623448 168.657539 249.054951
...
[129 rows x 96 columns]
我有另一个 DataFrame 用作 target_train (Y):
Date
2005-04-01 -0.01136
2005-05-01 0.04713
2005-06-01 0.00329
2005-07-01 -0.00985
2005-08-01 0.05635
2005-09-01 -0.03766
2005-10-01 0.01848
2005-11-01 -0.01387
[129 rows x 1 column]
我正在使用以下代码:
from keras.models import Sequential
from keras.layers.core import Dense, Activation
model=Sequential()
model.add(Dense(output_dim=64, input_dim=100, init="glorot_uniform"))
model.add(Activation("tanh"))
model.add(Dense(output_dim=10, init="glorot_uniform"))
model.add(Activation("linear"))
model.compile(loss="mean_squared_error", optimizer="rmsprop")
model.fit(predictor_train, target_train, nb_epoch=5, batch_size=32,show_accuracy=True)
prediction=model.predict(predictor_train)
print prediction
我收到以下错误:
File "/Users/file.py", line 1271, in var_neural_reg1
model.fit(predictor_train, target_train, nb_epoch=5, batch_size=32,show_accuracy=True)
File "/Library/Python/2.7/site-packages/keras/models.py", line 581, in fit
shuffle=shuffle, metrics=metrics)
File "/Library/Python/2.7/site-packages/keras/models.py", line 230, in _fit
ins_batch = slice_X(ins, batch_ids)
File "/Library/Python/2.7/site-packages/keras/models.py", line 65, in slice_X
return [x[start] for x in X]
File "/Library/Python/2.7/site-packages/pandas/core/frame.py", line 1908, in __getitem__
return self._getitem_array(key)
File "/Library/Python/2.7/site-packages/pandas/core/frame.py", line 1953, in _getitem_array
return self.take(indexer, axis=1, convert=True)
File "/Library/Python/2.7/site-packages/pandas/core/generic.py", line 1370, in take
convert=True, verify=True)
File "/Library/Python/2.7/site-packages/pandas/core/internals.py", line 3508, in take
indexer = maybe_convert_indices(indexer, n)
File "/Library/Python/2.7/site-packages/pandas/core/indexing.py", line 1721, in maybe_convert_indices
raise IndexError("indices are out-of-bounds")
IndexError: indices are out-of-bounds
关于如何使这个猛犸象移动的任何见解?