torch normalize dim的问题

import torch
import torch.nn as nn
import torch.nn.functional as F

aaa=torch.FloatTensor([[3,4],[5,12]])
print(F.normalize(aaa,2,0))
print(F.normalize(aaa,2,1))
print(F.normalize(aaa,2,-1))
print(torch.sum(aaa,0))
print(torch.sum(aaa,1))
print(torch.sum(aaa,-1))
print(torch.norm(aaa,p=2,dim=0))
print(torch.norm(aaa,p=2,dim=1))
print(torch.norm(aaa,p=2,dim=-1))

官网normallize

p指定计算方式,dim指定计算的维度,结果如上

这个大佬很细致,可参考

https://blog.csdn.net/ECNU_LZJ/article/details/103653133?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task

发布了3 篇原创文章 · 获赞 0 · 访问量 75

猜你喜欢

转载自blog.csdn.net/Yang_137476932/article/details/105169329