神经网络python实现回归及问题解决

今天用python实现了一下神经网络回归,遇到了好几个问题,总结了一下问题的类型和解决方案:
本文侧重实现过程中的问题解决
代码如下:

from sklearn import datasets
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn import preprocessing
from sknn.mlp import Regressor, Layer
from sklearn.metrics import mean_squared_error

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

x_MinMax = preprocessing.MinMaxScaler()
y_MinMax = preprocessing.MinMaxScaler()   # 归一化 

y = np.array(y).reshape(len(y), 1)
x = x_MinMax.fit_transform(x)
y = y_MinMax.fit_transform(y)  

x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, train_size=0.8, random_state=0)

fit1 = Regressor(layers=[Layer("Sigmoid", units=6), Layer("Sigmoid", units=14), Layer("Linear")], learning_rate=0.01,random_state=2000, n_iter=10)
fit1.fit(x_train, y_train)

pred1_train = fit1.predict(x_train)

mse_1 = mean_squared_error(pred1_train,y_train)

print ("Train ERROR = ", mse_1)

 下面是关键部分要想实现上述代码需要装以下几个工具包

如果报错信息 
ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True

1、conda install libpython mingw (这里下载很慢很慢,而且有可能会断 所以下载的时候 时不时看一眼 如果断了 重复上述代码)

如果报错信息,无法加载downsample 

点错误得链接会进入pool.py文件,

修改以下几处地方

(1)把原来from theano.tensor.signal import downsample 修改为图中

(2)用contrl+F 搜索第二处downsample 修改为下图

 注:除了把downsample改为pool 还要把ds 改为ws

(3)用contrl+F 搜索第二处downsample 修改为

 

 

  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值