Theano中的阈值

Theano中的阈值,theano,Theano,有没有一种方法可以在Theano张量中设置阈值?例如,如果v=t.vector(),我想创建另一个张量w,该张量包含与v相同的值,除了超过某个阈值t的张量被t本身替换: v = [1, 2, 3, 100, 200, 300] T = 100 w = [1, 2, 3, 100, 100, 100] 更一般地说,有什么标准框架可以创建您自己对张量的操作?下面是实现这一点的代码。使用剪辑功能 import theano v = theano.tensor.vector() f = theano.

有没有一种方法可以在Theano张量中设置阈值?例如,如果
v=t.vector()
,我想创建另一个张量
w
,该张量包含与
v
相同的值,除了超过某个阈值
t
的张量被
t
本身替换:

v = [1, 2, 3, 100, 200, 300]
T = 100
w = [1, 2, 3, 100, 100, 100]

更一般地说,有什么标准框架可以创建您自己对张量的操作?

下面是实现这一点的代码。使用剪辑功能

import theano
v = theano.tensor.vector()
f = theano.function([v], theano.tensor.clip(v, 0, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
如果不需要最小值,可以使用开关:

import theano
v = theano.tensor.vector()
f = theano.function([v], theano.tensor.clip(v, 0, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
f = theano.function([v], theano.tensor.switch(v<100, v, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
import theano
v=theano.tensor.vector()
f=theano.函数([v],theano.张量.clip(v,0100))
f([1,2,31002000])
#数组([1,2,3,100,100,100.]))

f=theano.function([v],theano.tensor.switch(v以下是实现此功能的代码。请使用clip函数

import theano
v = theano.tensor.vector()
f = theano.function([v], theano.tensor.clip(v, 0, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
如果不需要最小值,可以使用开关:

import theano
v = theano.tensor.vector()
f = theano.function([v], theano.tensor.clip(v, 0, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
f = theano.function([v], theano.tensor.switch(v<100, v, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
import theano
v=theano.tensor.vector()
f=theano.函数([v],theano.张量.clip(v,0100))
f([1,2,31002000])
#数组([1,2,3,100,100,100.]))

f=theano.function([v],theano.tensor.switch(v以下是实现此功能的代码。请使用clip函数

import theano
v = theano.tensor.vector()
f = theano.function([v], theano.tensor.clip(v, 0, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
如果不需要最小值,可以使用开关:

import theano
v = theano.tensor.vector()
f = theano.function([v], theano.tensor.clip(v, 0, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
f = theano.function([v], theano.tensor.switch(v<100, v, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
import theano
v=theano.tensor.vector()
f=theano.函数([v],theano.张量.clip(v,0100))
f([1,2,31002000])
#数组([1,2,3,100,100,100.]))

f=theano.function([v],theano.tensor.switch(v以下是实现此功能的代码。请使用clip函数

import theano
v = theano.tensor.vector()
f = theano.function([v], theano.tensor.clip(v, 0, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
如果不需要最小值,可以使用开关:

import theano
v = theano.tensor.vector()
f = theano.function([v], theano.tensor.clip(v, 0, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
f = theano.function([v], theano.tensor.switch(v<100, v, 100))
f([1, 2, 3, 100, 200, 300])
# array([   1.,    2.,    3.,  100.,  100.,  100.])
import theano
v=theano.tensor.vector()
f=theano.函数([v],theano.张量.clip(v,0100))
f([1,2,31002000])
#数组([1,2,3,100,100,100.]))
f=无函数([v],无张量开关(v