[英]torch.addmm received an invalid combination of arguments
In the official webpage of pytorch I saw the following code with answers: 在pytorch的官方网页上,我看到了以下带有答案的代码:
>> a = torch.randn(4, 4)
>> a
0.0692 0.3142 1.2513 -0.5428
0.9288 0.8552 -0.2073 0.6409
1.0695 -0.0101 -2.4507 -1.2230
0.7426 -0.7666 0.4862 -0.6628
torch.FloatTensor of size 4x4]
>>> torch.max(a, 1)
(
1.2513
0.9288
1.0695
0.7426
[torch.FloatTensor of size 4]
,
2
0
0
0
[torch.LongTensor of size 4]
)
I know that the first result corresponds to the maximum number per row, however I do not get the second tensor (LongTensor) 我知道第一个结果对应于每行的最大数量,但是我没有得到第二个张量(LongTensor)
I tried other random example and after a pytorch.max, I came to find these results 我尝试了其他随机示例,并在pytorch.max之后,我找到了这些结果
0.9477 1.0090 0.8348 -1.3513
-0.4861 1.2581 0.3972 1.5751
-1.2277 -0.6201 -1.0553 0.6069
0.1688 0.1373 0.6544 -0.7784
[torch.FloatTensor of size 4x4]
(
1.0090
1.5751
0.6069
0.6544
[torch.FloatTensor of size 4]
,
1
3
3
2
[torch.LongTensor of size 4]
)
Can anyone tell me what does it really mean these LongTensor data? 谁能告诉我这些LongTensor数据的真正含义是什么? I thought it was a strange casting between tensors, however after a simple casting of a float tensor, I see that it just cuts decimals
我认为这是张量之间的奇怪转换,但是在简单地转换了浮点张量之后,我看到它只是将小数点减
Thanks 谢谢
It just tells the index of the max element in your original tensor along the queried dimension. 它只是告诉最大张量在原始张量中沿查询维度的索引 。
Eg 例如
0.9477 1.0090 0.8348 -1.3513
-0.4861 1.2581 0.3972 1.5751
-1.2277 -0.6201 -1.0553 0.6069
0.1688 0.1373 0.6544 -0.7784
[torch.FloatTensor of size 4x4]
# torch.max(a, 1)
(
1.0090
1.5751
0.6069
0.6544
[torch.FloatTensor of size 4]
,
1
3
3
2
[torch.LongTensor of size 4]
)
In the above example in torch.LongTensor
, 在上例中的
torch.LongTensor
,
1
is the index of 1.0090
in your original tensor (torch.FloatTensor) 1
是原始张量(torch.FloatTensor)中的1.0090
的索引
3
is the index of 1.5751
in your original tensor (torch.FloatTensor) 3
是指数1.5751
在你原来的张量(torch.FloatTensor)
3
is the index of 0.6069
in your original tensor (torch.FloatTensor) 3
是原始张量(torch.FloatTensor)中的0.6069
的索引
2
is the index of 0.6544
in your original tensor (torch.FloatTensor) 2
是原始张量(torch.FloatTensor)中的0.6544
指数
along dimension 1 . 沿尺寸1 。
Instead, if you'd have requested torch.max(a, 0)
, the entries in torch.LongTensor
would correspond to the indices
of max elements in your original tensor along dimension 0 . 相反,如果您请求了
torch.max(a, 0)
,则torch.LongTensor
的条目将与原始张量中沿着维度0的max元素的indices
相对应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.