我正在尝试在Theano中对矩阵进行逐元素操作,找到s=max(ele, 0)
的值。我对Theano没有太多经验。
目前为止,我的代码是:
x = theano.tensor.dmatrix('x')
s = (x + abs(x)) / 2 # poor man's trick
linmax = function([x], s)
这个方法可行,但不够优雅,我认为应该可以使用 theano.tensor.maximum
来实现。
在matlab中,要实现我想要的功能,只需要编写以下代码:linmax=@(x) max (x, zeros (size (x)))
T.max()
和T.maximum()
不是等价的。花了我一点时间才意识到! - aspiring_sarge