【问题标题】:numpy.float64 object is not callable error on concrete datasetnumpy.float64 object is not callable error on concrete dataset
【发布时间】:2022-12-26 22:22:25
【问题描述】:

I'm writing a simple Regression Model in Keras for predicting Strength.

This is my code:

epochs_number = 50
mean_squared_errors = []
number_of_reapeat = 50

for i in range(0, number_of_reapeat):
    print(i)
    X_train, X_test, y_train, y_test = train_test_split(predictors, target, test_size=0.3, random_state=i)
    model.fit(X_train, y_train, epochs=epochs_number, verbose=0)
    y_pred = model.predict(X_test)
    mean_squared_error = mean_squared_error(y_test, y_pred)
    mean_squared_errors.append(mean_squared_error)

But whenever I run this code , following error shown :

0
10/10 [==============================] - 0s 2ms/step
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [11], line 10
      8 model.fit(X_train , y_train , epochs=epochs_number , verbose=0)
      9 y_pred= model.predict(X_test)
---> 10 mean_squared_error = mean_squared_error(y_test,y_pred)
     11 mean_squared_errors.append(mean_squared_error)

TypeError: 'numpy.float64' object is not callable

What is problem and How can I solve it??

【问题讨论】:

    标签: python keras


    【解决方案1】:

    You presumably have a function named mean_squared_error(), but in your loop you just assigned its output to a variable of the same name.

    【讨论】:

      猜你喜欢
      • 2022-12-26
      • 1970-01-01
      • 2020-07-13
      • 1970-01-01
      • 2018-09-15
      • 2020-03-27
      • 2021-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多