theano报一种float类型错误的处理办法
2016-04-06 09:44
274 查看
我实际用的环境是Keras,查错误时查到是Theano的配置问题,所以在标题里就写成Theano的问题了,
是这样的,从Github上下载的别人的代码,准备复现别人的实验,结果在机器上部署好环境之后跑代码时报错为:
TypeError: ('An update must have the same type as the original shared variable (shared_var=weight_1,
shared_var.type=TensorType(float32, matrix), update_val=Elemwise{sub,no_inplace}.0,
update_val.type=TensorType(float64, matrix)).', 'If the difference is related to the broadcast pattern, you
can call the tensor.unbroadcast(var, axis_to_unbroadcast[, ...]) function to remove broadcastable
dimensions.')
意思就是代码里float的位数不对,以前的Keras版本都是float32的,现在的新版Keras默认是float64的,具体两者有什么区别还不太清楚,但是表现在执行的时候就是报上面的错,之后程序停止,
解决方案:在代码中,import语句的下面添加下面一行代码,
theano.config.floatX= 'float32'
之后运行就行了,此时就是显式设置相关编译信息,
(初来乍到,有错误之处还望指正,其实个人刚开始使用Keras和Theano,有很多也不太了解,)
是这样的,从Github上下载的别人的代码,准备复现别人的实验,结果在机器上部署好环境之后跑代码时报错为:
TypeError: ('An update must have the same type as the original shared variable (shared_var=weight_1,
shared_var.type=TensorType(float32, matrix), update_val=Elemwise{sub,no_inplace}.0,
update_val.type=TensorType(float64, matrix)).', 'If the difference is related to the broadcast pattern, you
can call the tensor.unbroadcast(var, axis_to_unbroadcast[, ...]) function to remove broadcastable
dimensions.')
意思就是代码里float的位数不对,以前的Keras版本都是float32的,现在的新版Keras默认是float64的,具体两者有什么区别还不太清楚,但是表现在执行的时候就是报上面的错,之后程序停止,
解决方案:在代码中,import语句的下面添加下面一行代码,
theano.config.floatX= 'float32'
之后运行就行了,此时就是显式设置相关编译信息,
(初来乍到,有错误之处还望指正,其实个人刚开始使用Keras和Theano,有很多也不太了解,)
相关文章推荐
- slf4j-api-1.5.8.jar
- 正则例四
- LeetCode 226 -Invert Binary Tree ( JAVA )
- SQL Server @@ROWCOUNT 、@@ERROR用法
- shell中的${},##和%%的使用
- 静态代码块与非静态代码块
- Python-OpenCV(5)
- Web——在淘宝搜索到看到商品
- servlet api.jar是干什么的?
- 正则例三
- 基于.NET平台常用的框架整理(转)
- 包含min函数的栈
- php 5.6.19连接数据库
- 欢迎使用Markdown编辑器写博客
- 剑指offer面试题之约瑟夫环问题
- UE4学习资料搜集
- nodejs(二)
- 转载文章 ubuntu安装php Apache mysql 继承环境
- SharePoint 2013 使用JavaScript对象模型配置智能提示
- servlet-api-2.5.jar - jar not loaded