Numpy 扫描序号中张量变量的所有其他元素

Numpy 扫描序号中张量变量的所有其他元素,numpy,parallel-processing,gpgpu,theano,Numpy,Parallel Processing,Gpgpu,Theano,它应该产生类似于: input = [1,2,3,4,5,6] output = scan_every_other(lambda x:x, input) // output should be [1,3,5] 我已经简单地阅读了这篇文章,但没有找到我要找的东西。 谢谢。:)您不需要使用theano.scan。只需使用numpy中的普通索引/切片表示法: 在努比,如果 input = [1,2,3,4,5,6] 然后 将显示 [1, 3, 5] 在Theano中,这可以通过做同样的事情来实现

它应该产生类似于:

input = [1,2,3,4,5,6]
output = scan_every_other(lambda x:x, input)
// output should be [1,3,5]
我已经简单地阅读了这篇文章,但没有找到我要找的东西。
谢谢。:)

您不需要使用
theano.scan
。只需使用numpy中的普通索引/切片表示法:

在努比,如果

input = [1,2,3,4,5,6]
然后

将显示

[1, 3, 5]
在Theano中,这可以通过做同样的事情来实现:

import theano
import theano.tensor as tt
input = tt.vector()
f = theano.function([input], input[::2])
print f([1,2,3,4,5,6])
import theano
import theano.tensor as tt
input = tt.vector()
f = theano.function([input], input[::2])
print f([1,2,3,4,5,6])