Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Theano元素最大值_Python_Numpy_Theano - Fatal编程技术网

Python Theano元素最大值

Python Theano元素最大值,python,numpy,theano,Python,Numpy,Theano,我在努力寻找它的价值 s=max(ele,0)编号中矩阵上的元素。 我对西亚诺没有多少经验 到目前为止我有 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,零(大小x))这对我很有用

我在努力寻找它的价值
s=max(ele,0)
编号中矩阵上的元素。 我对西亚诺没有多少经验

到目前为止我有

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,零(大小x))

这对我很有用:

import theano.tensor as T
from theano import function

x = T.dmatrix('x')
linmax = function([x], T.maximum(x,0))
测试:

linmax([[-1,-2],[3,4]])
产出:

array([[0.,0.],[3.,4.]])

我已经看到了这一点的实现

s = x*(x>0)
好几次。不知道这是否比T.max()快。

注意:
T.max()
T.max()
不相等。我花了一点时间才意识到!