我正在使用安装了Theano库的Python 2.7 (更新版),我在定义Theano函数时遇到了输入参数的问题。
代码是:
corruption_level = T.scalar('corruption') # % of corruption to use
learning_rate = T.scalar('lr') # learning rate to use
fn = theano.function(
inputs=[
index,
theano.In(corruption_level, value=0.2),
theano.In(learning_rate, value=0.1)
],
outputs=cost,
updates=updates,
givens={
self.x: train_set_x[batch_begin: batch_end]
}
)它是从这里取的:
http://deeplearning.net/tutorial/code/SdA.py
在Eclipse中,它给出了这个错误:
NotImplementedError: In() instances and tuple inputs trigger the old
semantics, which disallow using updates and givens因此,如果我以这种方式更改代码:
fn = theano.function(
inputs=[
index,
#theano.In(corruption_level, value=0.2),
#theano.In(learning_rate, value=0.1)
corruption_level,
learning_rate
],
outputs=cost,
updates=updates,
givens={
self.x: train_set_x[batch_begin: batch_end]
}
)它可以工作,但我不能传递corruption_level和learning_rate的值。
有人能帮上忙吗?谢谢!
卢卡
发布于 2016-04-15 07:35:12
被正式弃用,并有一个计划的替代。在几天内,它被从Theano开发版本中删除。但后来我们意识到,最好是保留它,然后更改它,然后去掉我们计划的替代方案。
在此期间,Theano想要什么和深度学习教程之间也存在一些不一致之处。
这个问题已经解决了。因此,现在,更新到Theano 0.8或使用Theano的当前开发版本,它应该可以正常工作。
也许其他有相关问题的人可能需要更新深度学习教程代码,因为在几天内,它正在使用我们删除的计划替换。
theano.In()现在按照您的问题工作。
https://stackoverflow.com/questions/35622784
复制相似问题