解决python 无法加载downsample模型的问题

yipeiwu_com6年前Python基础

downsample 在最新版本里面修改了位置

from theano.tensor.single import downsample (旧版本)

上面以上的的import会有error raise:

from theano.tensor.signal import downsample

ImportError: cannot import name 'downsample'

找到from theano.tensor.single import downsample所在文件,如:

...\lib\site-packages\lasagne\layers\pool.py

把 from theano.tensor.signal import downsample注释掉,改为

from theano.tensor.signal.pool import pool_2d

代码中运用到downsample的地方也要改掉

# 子采样
 pooled_out = downsample.max_pool_2d(
  input=conv_out,
  ds=poolsize,
  ignore_border=True
 )

这里直接将downsample改为pool会出错,因为里面相应的函数有变化

查看pool.py的源码,发现downsample.max_pool_2d()与pool. pool_2d()函数功能相同,用ws代替ds

 # 子采样
pooled_out = pool.pool_2d(
  input=conv_out,
  ws=poolsize,
  ignore_border=True
)
 

以上这篇解决python 无法加载downsample模型的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

浅谈Python peewee 使用经验

本文使用案例是基于 python2.7 实现 以下内容均为个人使用 peewee 的经验和遇到的坑,不会涉及过多的基本操作。所以,没有使用过 peewee,可以先阅读文档 正确性和覆盖面...

浅谈Python的垃圾回收机制

一.垃圾回收机制 Python中的垃圾回收是以引用计数为主,分代收集为辅。引用计数的缺陷是循环引用的问题。 在Python中,如果一个对象的引用数为0,Python虚拟机就会回收这个对象...

python判断字符串是否包含子字符串的方法

本文实例讲述了python判断字符串是否包含子字符串的方法。分享给大家供大家参考。具体如下: python的string对象没有contains方法,不用使用string.contain...

在python中获取div的文本内容并和想定结果进行对比详解

div的内容为: <div style="background-color: rgb(255, 238, 221);" id="status" class="errors">...

python 字典 按key值大小 倒序取值的实例

如下所示: viedoUrl_dict = {1:'hello',2:'python',3:'nihao'} bit_list = sorted(viedoUrl_dict.keys...