Attributeerror: 'history' Object Has No Attribute 'predict' - Fitting A List Of Train And Test Data
I am trying a NN model using this example. I am fitting a list of values to a NN model. However, I am getting an AttributeError. This has been asked before and has been answered. U
Solution 1:
model.fit() does not return the Keras model, but a History object containing loss and metric values of your training. So in this code:
NNmodelList.append(nn_model.fit(i,j))
you're creating a list of History objects, not models. A simple fix would be:
NNmodelList.append(nn_model)
nn_model.fit(i,j)
Solution 2:
enter code here
def build_regressor() :
regressor = Sequential()
regressor.add(Dense(units = 64, kernel_initializer = 'uniform', activation = 'relu', input_dim = 5))
regressor.add(Dense(units =64 , kernel_initializer = 'uniform', activation = 'relu'))
regressor.add(Dense(units = 1, kernel_initializer = 'uniform', activation = 'relu'))
regressor.compile(optimizer='adam', loss='mean_squared_error')
return regressor
regressor=KerasRegressor(build_fn=build_regressor, batch_size=32,epochs=200)
results=regressor.fit(X_train,y_train)
regressor.history
print(results.coef_)
but this shows the following error:
AttributeError: 'KerasRegressor' object has no attribute 'history'
Post a Comment for "Attributeerror: 'history' Object Has No Attribute 'predict' - Fitting A List Of Train And Test Data"