weixin_44815085
A Peaceful Tree
采纳率75%
2019-09-05 17:44

解决python __init__() missing 1 required positional argument: 'layers'

运行的时候出现了__init__() missing 1 required positional argument: 'layers',有大佬知道怎么解决吗

from sklearn import datasets
boston=datasets.load_boston()
x,y=boston.data, boston.target

from sklearn import preprocessing
x_MinMax=preprocessing.MinMaxScaler()
y_MinMax=preprocessing.MinMaxScaler()

import numpy as np
y=np.array(y).reshape((len(y),1)) #np.array确保y是numpy数组
x=x_MinMax.fit_transform(x) #fit_transform先拟合数据,然后转化它将其转化为标准形式
y=y_MinMax.fit_transform(y)
x.mean(axis=0) #均值为0

import random
from sklearn.cross_validation import train_test_split
np.random.seed(2016)
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2)

from sknn.mlp import Regressor,Layer #预测模型
fit1=Regressor(Layers=[Layer('Sigmoid',units=6),Layer('Sigmoid',units=14),
                       Layer('Linear')],learning_rate=0.02,
               random_state=2016,
               n_iter=10
               )
fit1.fit(x_train,y_train)
predict_train=fit1.predict(x_train)

from sklearn.metrics import mean_squared_error
mse_1=mean_squared_error(predict_train,y_train)
print(mse_1)
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • zaq15csdn greatofdream 2年前

    参数写错了

    Layers=
    换成
    layers

    点赞 1 评论 复制链接分享

相关推荐