[英]Keras input shape, simple array of input lists
其中每個數組([x1,x2,x3,...,x15])表示單個輸入
[array([0. , 0.08333333, 0.08333333, 0.08333333, 0.08333333,
0.08333333, 0.08333333, 0. , 0.08333333, 0.08333333,
0.08333333, 0.08333333, 0.08333333, 0.08333333, 0. ])
array([0.04166667, 0.10416667, 0.10416667, 0.08333333, 0. ,
0.10416667, 0.10416667, 0.02083333, 0.10416667, 0.08333333,
0. , 0. , 0.125 , 0.125 , 0. ])
array([0.04166667, 0. , 0.125 , 0.10416667, 0.02083333,
0.125 , 0.125 , 0.02083333, 0.10416667, 0. ,
0.02083333, 0.02083333, 0.14583333, 0.14583333, 0. ])
...
array([0.4375 , 0.0625 , 0. , 0. , 0. ,
0.0625 , 0. , 0.25 , 0. , 0.08333333,
0.04166667, 0.02083333, 0. , 0.04166667, 1. ])
array([0.45833333, 0. , 0.02083333, 0.02083333, 0.02083333,
0.08333333, 0. , 0.25 , 0. , 0.08333333,
0.04166667, 0.02083333, 0. , 0. , 1. ])
array([0.5 , 0. , 0. , 0.02083333, 0.02083333,
0. , 0.02083333, 0.27083333, 0.02083333, 0.10416667,
0.0
4166667, 0. , 0. , 0. , 1. ])]
進入模型
model = Sequential()
model.add(Dense(15, input_dim=15, kernel_initializer='uniform', activation='relu'))
model.add(Dense(16, kernel_initializer='uniform', activation='relu'))
model.add(Dense(14, kernel_initializer='uniform', activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
抱怨:
ValueError: Error when checking input: expected dense_1_input to have shape (15,) but got array with shape (1,)
如何重塑輸入數據以適合此模型?
它不需要內部的numpy數組,它應該是內部列表,但只能是最頂層的數組
X_train = np.array([x.tolist() for x in df['board_in'].values])
y_train = df['target']
y_train = np.array([y for y in df['target'].values])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.