maxframe.tensor.cumprod#
- maxframe.tensor.cumprod(a, axis=None, dtype=None, out=None)[源代码]#
返回沿给定轴的元素的累积乘积。
- 参数:
- 返回:
cumprod -- 返回一个包含结果的新张量,除非指定了 out,此时返回对 out 的引用。
- 返回类型:
Tensor
参见
numpy.doc.ufuncs“输出参数”部分
备注
使用整数类型时运算是模运算,溢出时不会引发错误。
示例
>>> import maxframe.tensor as mt
>>> a = mt.array([1,2,3]) >>> mt.cumprod(a).execute() # intermediate results 1, 1*2 ... # total product 1*2*3 = 6 array([1, 2, 6]) >>> a = mt.array([[1, 2, 3], [4, 5, 6]]) >>> mt.cumprod(a, dtype=float).execute() # specify type of output array([ 1., 2., 6., 24., 120., 720.])
a 每一列(即跨行)的累积乘积:
>>> mt.cumprod(a, axis=0).execute() array([[ 1, 2, 3], [ 4, 10, 18]])
a 每一行(即跨列)的累积乘积:
>>> mt.cumprod(a,axis=1).execute() array([[ 1, 2, 6], [ 4, 20, 120]])