小编gag*_*zhn的帖子

如何在Theano中分配/更新张量共享变量的子集?

编译函数时theano,可以通过指定更新共享变量(比如X)updates=[(X, new_value)].现在我试图只更新共享变量的子集:

from theano import tensor as T
from theano import function
import numpy

X = T.shared(numpy.array([0,1,2,3,4]))
Y = T.vector()
f = function([Y], updates=[(X[2:4], Y)] # error occur:
                                        # 'update target must 
                                        # be a SharedVariable'
Run Code Online (Sandbox Code Playgroud)

代码将引发错误"更新目标必须是SharedVariable",我猜这意味着更新目标不能是非共享变量.那么有没有办法编译一个函数只是udpate共享变量的子集?

python numpy theano

25
推荐指数
2
解决办法
1万
查看次数

标签 统计

numpy ×1

python ×1

theano ×1