TUNGchuan
TUNGchuan
采纳率66.7%
2019-09-26 17:43

keras中model.evaluate()报错:'numpy.float64' object is not iterable

x_train, x_test, y_train, y_test = train_test_split(x_data, y_data, test_size=0.25)
mean = x_train.mean(axis=0)
std = x_train.std(axis=0)
train_data = (x_train - mean) / std
test_data = (x_test - mean) / std
model = Sequential([Dense(64, input_shape=(6,)), Activation('relu'),
                    Dense(32), Activation('relu'),
                    Dense(1)])

sgd = keras.optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='mean_squared_error', optimizer=sgd)
k = model.fit
[loss, sgd] = model.evaluate(test_data, y_test, verbose=1)

最后一步不知道哪出了问题。。test_data, y_test都是dataframe啊

TypeError Traceback (most recent call last)
in
----> 1 [loss, mse] = model.evaluate(test_data, y_test, verbose=1)

TypeError: 'numpy.float64' object is not iterable

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

为你推荐