Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 2 array(s), but instead got the following list of 1 arrays
1.先检查输入的维度是否有误使用shape查看输入的数据维度和定义的模型维度是否相等
2.当维度无错误时,请检查是否时多输入或多输出例如,当有多个输入X1, X2,…,Xn 或多个输出Y1,Y2,… ,Yn时
应当将所有的输入(出)放在一个列表中
model.fit([X1, X2,…,Xn], [Y1,Y2,… ,Yn])
validation_data按同样的 *** 作
我跑的是DAE,单输入,双输出,所以将输出写在一个列表中
def DAE(sizes): features = sizes[0] classes = sizes[-1] input_tensor = layers.Input([features, ], name="input") x = layers.Dropout(0.2)(input_tensor) for i in range(1, len(sizes)-1): x = layers.Dense(units=sizes[i], activation=activations.relu)(x) out1 = layers.Dense(units=features, activation=activations.relu, name="decode")(x) out2 = layers.Dense(units=classes, activation=activations.softmax, name="class")(x) model = Model(input_tensor, [out1, out2]) return model
dae_model = DAE(sizes) dae_model.compile(optimizer=optimizers.adam(), loss={"decode":losses.mse, "class":losses.categorical_crossentropy}, loss_weights={"decode":lambda1, "class":lambda2}, metrics=["accuracy"]) dae_model.summary() dae_model.fit(x_train_2_axis, [x_train_2_axis, y_train_2_axis], batch_size=32, epochs=10, validation_data=(x_test_2_axis, [x_test_2_axis, y_test_2_axis]))
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)