尺寸我試圖運行此SimpleRNN的錯誤號:上model.fit
model.add(SimpleRNN(init='uniform',output_dim=1,input_dim=len(pred_frame.columns)))
model.compile(loss="mse", optimizer="sgd")
model.fit(X=predictor_train, y=target_train, batch_size=len(pred_frame.index),show_accuracy=True)
錯誤是model.fit,你可以看到如下:
File "/Users/file.py", line 1496, in Pred
model.fit(X=predictor_train, y=target_train, batch_size=len(pred_frame.index),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 239, in _fit
outs = f(ins_batch)
File "/Library/Python/2.7/site-packages/keras/backend/theano_backend.py", line 365, in __call__
return self.function(*inputs)
File "/Library/Python/2.7/site-packages/theano/compile/function_module.py", line 513, in __call__
allow_downcast=s.allow_downcast)
File "/Library/Python/2.7/site-packages/theano/tensor/type.py", line 169, in filter
data.shape))
TypeError: ('Bad input argument to theano function with name "/Library/Python/2.7/site-packages/keras/backend/theano_backend.py:362" at index 0(0-based)', 'Wrong number of dimensions: expected 3, got 2 with shape (88, 88).')
錯誤告訴我它的尺寸錯誤,它應該是3,它只有2。它指的是什麼尺寸?
感謝您的解釋,我有類似的問題。爲什麼在你評論的情況下反向傳播的最大步驟只有2?爲什麼序列的數量是5?順便說一下,順序是指訓練中的一個時代? – David
我隨機選擇數字2作爲本例中反向傳播的先前步驟的數量。結合(也是自由選擇的)8個樣品的數量,這導致總共5個序列。序列1包括樣本1,2和3,序列2包括2,3和4等等。有關詳細信息,請參閱我答案中的圖表。一個時代是當網絡已經被每個序列訓練一次時完成的。然後你再次開始第一個序列 – Lorrit