当前位置:网站首页>Tensor attribute statistics
Tensor attribute statistics
2022-07-05 22:43:00 【dying_ star】
torch.norm Find norm function

import torch
a=torch.tensor([[1,2,3],[-1,1,4]],dtype=torch.float)
print(a.norm(p=1))# Calculate the sum of the absolute values of each element
print(torch.norm(a,p=1,dim=1))# Specify dimensions , Calculate the sum of the absolute values of each element horizontally
print(torch.norm(a,p=1,dim=0))# Vertically calculate the sum of the absolute values of each element Output
tensor(12.)
tensor([6., 6.])
tensor([2., 3., 7.])max Function statistics maximum
a=torch.tensor([[1,2,3],[-1,1,4]],dtype=torch.float)
print(a.max(),a.min(),a.mean())# Return maximum , minimum value , Average
print(a.argmax())# Returns the index of the maximum value , The default level is 1 dimension
print(a.argmax(dim=1))# Specify dimensions , Returns the index of the maximum value of each row
print(a.max(dim=1,keepdim=True))# Specify dimensions , Return the index and maximum value of the maximum value of each row
# Output results will lose dimensions ,keepdim=True Keep the dimension of the original tensor
print(a.topk(2,dim=1))# a max Method ,topk Can return n Multiple larger values and their indexes Output
tensor(4.) tensor(-1.) tensor(1.6667)
tensor(5)
tensor([2, 2])
torch.return_types.max(
values=tensor([[3.],
[4.]]),
indices=tensor([[2],
[2]]))
torch.return_types.topk(
values=tensor([[3., 2.],
[4., 1.]]),
indices=tensor([[2, 1],
[2, 1]]))a=torch.tensor([[1,2,3],[-1,1,4]],dtype=torch.float)
print(torch.eq(a,a))# Judge whether the two tensors are equal
print(a>0)# Judge elements and 0 The relationship between Output
tensor([[True, True, True],
[True, True, True]])
tensor([[ True, True, True],
[False, True, True]])
边栏推荐
- MySQL服务莫名宕机的解决方案
- Methods modified by static
- Why does the C# compiler allow an explicit cast between IEnumerable< T> and TAlmostAnything?
- Google Maps case
- Kubernetes Administrator certification (CKA) exam notes (IV)
- The countdown to the launch of metaverse ape is hot
- Overview of Fourier analysis
- Lesson 1: serpentine matrix
- 344. Reverse String. Sol
- Metaverse ape received $3.5 million in seed round financing from negentropy capital
猜你喜欢

如何快速体验OneOS

Matlab draws a cute fat doll

My experience and summary of the new Zhongtai model

What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method

第一讲:蛇形矩阵
![Sparse array [matrix]](/img/62/27b02deeeaa5028a16219ef51ccf82.jpg)
Sparse array [matrix]

點到直線的距離直線的交點及夾角

Lesson 1: serpentine matrix

Practice: fabric user certificate revocation operation process

关于MySQL的30条优化技巧,超实用
随机推荐
Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
BFC block level formatting context
Spectrum analysis of ADC sampling sequence based on stm32
二叉树(三)——堆排序优化、TOP K问题
Some tutorials install the database on ubantu so as not to occupy computer memory?
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)
Event trigger requirements of the function called by the event trigger
Character conversion PTA
TCC of distributed solutions
When the industrial Internet era is truly mature, we will look at the emergence of a series of new industrial giants
从 1.5 开始搭建一个微服务框架——日志追踪 traceId
2022软件测试工程师涨薪攻略,3年如何达到30K
Go语言学习教程(十五)
Function default parameters, function placeholder parameters, function overloading and precautions
实战:fabric 用户证书吊销操作流程
Nail error code Encyclopedia
Overriding equals() & hashCode() in sub classes … considering super fields
I closed the open source project alinesno cloud service
Technology cloud report won the special contribution award for the 10th anniversary of 2013-2022 of the "cloud Ding Award" of the global cloud computing conference