将输入数据重新整形到keras lstm中

时间:2017-11-30 20:26:32

标签: python arrays numpy keras lstm

我的x_train数组(1526472 x 256):

syn0

我的y_train数组(8 x 2):

[[0, 0, 1, ..., 0],
 [0, 1, 0, ..., 0],
 ...
 [0, 0, 0, ..., 1]]

我想做什么:

1)将x_train数组重塑为8个样本(每个样本190809 x 256) 2)重塑y_train数组,将其视为这8个样本中每个样本的标签 3)正确地将这些放入我的lstm 4)将y_train错误理解为我的dense_2层。

我想做什么:

[[0, 1],
 [1, 0],
 ...
 [0, 1]]

lstm_1错误:

1) x_train = x_train.reshape(8, int(len(x_train)/8), 256)  
2) y_train = y_train.reshape(8, 2, 1)  
3) model.add(LSTM(256, input_shape=(int(len(x_train)/8), 256), 
return_sequences = True, activation = 'sigmoid'))  
4) model.add(Dense(2, activation = 'softmax'))

dense_2错误:

ValueError: Error when checking input: expected lstm_1_input to have 
shape (None, 1, 256) but got array with shape (8, 190809, 256)

0 个答案:

没有答案