2017-08-14 8 views
3

KerasのLSTMで何か問題があります。私はすべて輸入後unhashable type:Keras LSTMの 'Dimension'

 TypeErrorTraceback (most recent call last) 
<ipython-input-61-a1844d288e79> in <module>() 
    10 print("Actual input: {}".format(X.shape)) 
    11 print("Actual output: {}".format(Y.shape)) 
---> 12 history = model.fit(X, Y, epochs=2, batch_size=100, verbose=1) 

/opt/conda/lib/python3.6/site-packages/keras/models.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, **kwargs) 
    843        class_weight=class_weight, 
    844        sample_weight=sample_weight, 
--> 845        initial_epoch=initial_epoch) 
    846 
    847  def evaluate(self, x, y, batch_size=32, verbose=1, 

/opt/conda/lib/python3.6/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, **kwargs) 
    1403    class_weight=class_weight, 
    1404    check_batch_axis=False, 
-> 1405    batch_size=batch_size) 
    1406   # prepare validation data 
    1407   if validation_data: 

/opt/conda/lib/python3.6/site-packages/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_batch_axis, batch_size) 
    1305       for (ref, sw, cw, mode) 
    1306       in zip(y, sample_weights, class_weights, self._feed_sample_weight_modes)] 
-> 1307   _check_array_lengths(x, y, sample_weights) 
    1308   _check_loss_and_target_compatibility(y, 
    1309            self._feed_loss_fns, 

/opt/conda/lib/python3.6/site-packages/keras/engine/training.py in _check_array_lengths(inputs, targets, weights) 
    208  y_lengths = [y.shape[0] for y in targets] 
    209  w_lengths = [w.shape[0] for w in weights] 
--> 210  set_x = set(x_lengths) 
    211  if len(set_x) > 1: 
    212   raise ValueError('All input arrays (x) should have ' 

TypeError: unhashable type: 'Dimension' 

私のコードを、言って、データの読み込みにフィットしようとしたとき、私は(NUM_ROWS、num_timesteps、num_dimensions)にいくつかのデータを整形しましたが、私はエラーを取得しています

です
X = reshape(np.array(dat), [10000, 101, 26]) 
model = Sequential() 
model.add(LSTM(1, input_shape=(101, 26), return_sequences=False)) 
model.compile(loss='binary_crossentropy', 
       optimizer= 'adam', 
       metrics=['binary_accuracy']) 
model.summary() 
print("Inputs: {}".format(model.input_shape)) 
print("Outputs: {}".format(model.output_shape)) 
print("Actual input: {}".format(X.shape)) 
print("Actual output: {}".format(Y.shape)) 
history = model.fit(X, Y, epochs=2, batch_size=100, verbose=1) 

と健全性チェックラインは与える:私は間違って何をやっている

_________________________________________________________________ 
Layer (type)     Output Shape    Param # 
================================================================= 
lstm_19 (LSTM)    (None, 1)     112  
================================================================= 
Total params: 112.0 
Trainable params: 112 
Non-trainable params: 0.0 
_________________________________________________________________ 
Inputs: (None, 101, 26) 
Outputs: (None, 1) 
Actual input: (10000, 101, 26) 
Actual output: (10000, 1) 

+0

スタックトレースにもう少しコンテキストを追加します。コード内のどの行がスローされてエラーになるのですか? – putonspectacles

+0

完全なスタックトレースを追加しました。 –

答えて

0

解決策が見つかりました。線

X = reshape(np.array(dat), [10000, 101, 26]) 

は、別の変形機能を指していました。私は

X = np.reshape(np.array(dat), [10000, 101, 26]) 

に変更しました。

関連する問題