当前位置:网站首页>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]])
边栏推荐
- Business introduction of Zhengda international futures company
- Google Maps case
- Nacos 的安装与服务的注册
- Some tutorials install the database on ubantu so as not to occupy computer memory?
- FBO and RBO disappeared in webgpu
- 344. Reverse String. Sol
- How to quickly experience oneos
- Why does the C# compiler allow an explicit cast between IEnumerable< T> and TAlmostAnything?
- Cobaltstrike builds an intranet tunnel
- Assign the output of a command to a variable [repeat] - assigning the output of a command to a variable [duplicate]
猜你喜欢
实战:fabric 用户证书吊销操作流程
30 optimization skills about mysql, super practical
Kubernetes Administrator certification (CKA) exam notes (IV)
从 1.5 开始搭建一个微服务框架——日志追踪 traceId
Event trigger requirements of the function called by the event trigger
Lesson 1: serpentine matrix
Unity Max and min constraint adjustment
Overview of Fourier analysis
513. Find the value in the lower left corner of the tree
Search: Future Vision (moving sword)
随机推荐
Metasploit (MSF) uses MS17_ 010 (eternal blue) encoding:: undefined conversionerror problem
Starting from 1.5, build a micro Service Framework -- log tracking traceid
QT creator 7-cmake update
[error record] file search strategy in groovy project (src/main/groovy/script.groovy needs to be used in the main function | groovy script directly uses the relative path of code)
Unity Max and min constraint adjustment
Calculation method of boundary IOU
Hcip day 16
Damn, window in ie open()
VIM tail head intercept file import
VOT Toolkit环境配置与使用
a-tree 树的全部展开和收起
Global and Chinese markets of industrial pH meters 2022-2028: Research Report on technology, participants, trends, market size and share
[secretly kill little buddy pytorch20 days] - [Day2] - [example of picture data modeling process]
Navigation day answer applet: preliminary competition of navigation knowledge competition
Qtquick3d real time reflection
Draw a red lantern with MATLAB
Wonderful review of the digital Expo | highlight scientific research strength, and Zhongchuang computing power won the digital influence enterprise award
Global and Chinese markets for welding products 2022-2028: Research Report on technology, participants, trends, market size and share
Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
The code generator has deoptimised the styling of xx/typescript. js as it exceeds the max of 500kb