小编shu*_*liu的帖子

如何使用 PyTorch 仅对矩阵的上三角元素进行 softmax?

给定输入如下:

tensor([[[1.9392, -1.9266,  0.9664],
         [0.0000, -1.9266,  0.9664],
         [0.0000, -0.0000,  0.9664]]])
Run Code Online (Sandbox Code Playgroud)

我想要的输出是:

tensor([[[0.4596,  0.0096, 0.1737],
         [0.0000,  0.0096, 0.1737],
         [0.0000, -0.0000, 0.1737]]])
Run Code Online (Sandbox Code Playgroud)

即仅计算上三角元素的函数。

python matrix softmax pytorch tensor

6
推荐指数
1
解决办法
1238
查看次数

标签 统计

matrix ×1

python ×1

pytorch ×1

softmax ×1

tensor ×1