Does slice or index of chainer.Variable to get item in chainer has backward ability?

流过昼夜 提交于 2019-12-12 04:37:50

问题


Does the following code chainer.Variable still have ability to hold graph and can backward (gradient flow) after slice(a[0,1] or index(a[0]):

>>> a = chainer.Variable(np.array([[1,2,3],[10,11,12]]))
>>> a
variable([[ 1,  2,  3],
          [10, 11, 12]])
>>> a[0]
variable([1, 2, 3])
>>> a[0, 1]
variable([1])

回答1:


Yes. Indexing of chainer.Variable supports backprop.



来源:https://stackoverflow.com/questions/45931252/does-slice-or-index-of-chainer-variable-to-get-item-in-chainer-has-backward-abil

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!