当前位置:网站首页>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]])
边栏推荐
- 2022 Software Test Engineer salary increase strategy, how to reach 30K in three years
- Platform bus
- EasyCVR集群部署如何解决项目中的海量视频接入与大并发需求?
- 南京:全面启用商品房买卖电子合同
- 点到直线的距离直线的交点及夹角
- The introduction to go language is very simple: String
- Binary tree (III) -- heap sort optimization, top k problem
- 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
- Evolution of APK reinforcement technology, APK reinforcement technology and shortcomings
- 航海日答题小程序之航海知识竞赛初赛
猜你喜欢
The countdown to the launch of metaverse ape is hot
[error record] groovy function parameter dynamic type error (guess: groovy.lang.missingmethodexception: no signature of method)
Technology cloud report: how many hurdles does the computing power network need to cross?
All expansion and collapse of a-tree
The difference between MVVM and MVC
The difference between MVVM and MVC
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
Post-90s tester: "after joining Ali, this time, I decided not to change jobs."
Distributed resource management and task scheduling framework yarn
VOT Toolkit环境配置与使用
随机推荐
Record several frequently asked questions (202207)
Editor extensions in unity
700. Search in a Binary Search Tree. Sol
Calculation method of boundary IOU
[groovy] mop meta object protocol and meta programming (Introduction to groovyobject interface | introduction to metaclass | implementation of class methods using groovyobject invokemethod)
344. Reverse String. Sol
Why does the C# compiler allow an explicit cast between IEnumerable< T> and TAlmostAnything?
Binary tree (III) -- heap sort optimization, top k problem
Overriding equals() & hashCode() in sub classes … considering super fields
Text组件新增内容通过tag_config设置前景色、背景色
Vcomp110.dll download -vcomp110 What if DLL is lost
Methods modified by static
Damn, window in ie open()
MCU case -int0 and INT1 interrupt count
2022-07-05: given an array, you want to query the maximum value in any range at any time. If it is only established according to the initial array and has not been modified in the future, the RMQ meth
Distance from point to line intersection and included angle of line
Post-90s tester: "after joining Ali, this time, I decided not to change jobs."
Starting from 1.5, build a micro Service Framework -- log tracking traceid
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
Go语言学习教程(十五)