首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将输入参数传递给Theano函数的正确方法是什么?

将输入参数传递给Theano函数的正确方法是什么?
EN

Stack Overflow用户
提问于 2016-02-25 17:09:35
回答 1查看 1K关注 0票数 6

我正在使用安装了Theano库的Python 2.7 (更新版),我在定义Theano函数时遇到了输入参数的问题。

代码是:

代码语言:javascript
复制
    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中,它给出了这个错误:

代码语言:javascript
复制
NotImplementedError: In() instances and tuple inputs trigger the old
semantics, which disallow using updates and givens

因此,如果我以这种方式更改代码:

代码语言:javascript
复制
        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的值。

有人能帮上忙吗?谢谢!

卢卡

EN

回答 1

Stack Overflow用户

发布于 2016-04-15 07:35:12

被正式弃用,并有一个计划的替代。在几天内,它被从Theano开发版本中删除。但后来我们意识到,最好是保留它,然后更改它,然后去掉我们计划的替代方案。

在此期间,Theano想要什么和深度学习教程之间也存在一些不一致之处。

这个问题已经解决了。因此,现在,更新到Theano 0.8或使用Theano的当前开发版本,它应该可以正常工作。

也许其他有相关问题的人可能需要更新深度学习教程代码,因为在几天内,它正在使用我们删除的计划替换。

theano.In()现在按照您的问题工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35622784

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档