pytorch torch.cumsum(input, dim, out=None)函数(沿轴逐级累加)
生活随笔
收集整理的這篇文章主要介紹了
pytorch torch.cumsum(input, dim, out=None)函数(沿轴逐级累加)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
torch.cumsum(input, dim, out=None) → Tensor
返回輸入沿指定維度的累積和。例如,如果輸入是一個N元向量,則結果也是一個N元向量,第i 個輸出元素值為 yi=x1+x2+x3+…+xi
參數:
- input (Tensor) – 輸入張量
- dim (int) – 累積和操作的維度
- out (Tensor, optional) – 結果張量
例子:
>>> a = torch.randn(10) >>> a-0.6039 -0.2214 -0.3705 -0.01691.3415 -0.12300.97190.6081 -0.12861.0947 [torch.FloatTensor of size 10]>>> torch.cumsum(a, dim=0)-0.6039 -0.8253 -1.1958 -1.21270.12880.00580.97771.58581.45722.5519 [torch.FloatTensor of size 10]參考文章:https://pytorch-cn.readthedocs.io/zh/latest/package_references/torch/#torchcumsum
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的pytorch torch.cumsum(input, dim, out=None)函数(沿轴逐级累加)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: pytorch torch.norm(i
- 下一篇: python matplotlib py