当前位置:网站首页>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]])
边栏推荐
- 基于STM32的ADC采样序列频谱分析
- 90后测试员:“入职阿里,这一次,我决定不在跳槽了”
- How to reverse a string fromCharCode? - How to reverse String. fromCharCode?
- Why does the C# compiler allow an explicit cast between IEnumerable< T> and TAlmostAnything?
- IIC bus realizes client device
- How can Bluetooth in notebook computer be used to connect headphones
- Binary tree (II) -- code implementation of heap
- Sub total of Pico development
- Global and Chinese market of networked refrigerators 2022-2028: Research Report on technology, participants, trends, market size and share
- Thinkphp5.1 cross domain problem solving
猜你喜欢

Search: Future Vision (moving sword)

Nangou Gili hard Kai font TTF Download with installation tutorial

Double pointer of linked list (fast and slow pointer, sequential pointer, head and tail pointer)

MCU case -int0 and INT1 interrupt count

What changes has Web3 brought to the Internet?
![[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)](/img/ab/086c7455706eecc467eef92c660803.jpg)
[groovy] groovy dynamic language features (automatic type inference of function arguments in groovy | precautions for function dynamic parameters)
![[groovy] mop meta object protocol and meta programming (Introduction to groovyobject interface | introduction to metaclass | implementation of class methods using groovyobject invokemethod)](/img/48/cd7960bbbc51a967b20da410bf81fe.jpg)
[groovy] mop meta object protocol and meta programming (Introduction to groovyobject interface | introduction to metaclass | implementation of class methods using groovyobject invokemethod)

链表之双指针(快慢指针,先后指针,首尾指针)

30 optimization skills about mysql, super practical

傅里叶分析概述
随机推荐
Damn, window in ie open()
Calculation method of boundary IOU
分布式解决方案选型
Vcomp110.dll download -vcomp110 What if DLL is lost
d3dx9_ How to repair 31.dll_ d3dx9_ 31. Solution to missing DLL
How to quickly experience oneos
我把开源项目alinesno-cloud-service关闭了
How can Bluetooth in notebook computer be used to connect headphones
MySQL服务莫名宕机的解决方案
Practice: fabric user certificate revocation operation process
What changes has Web3 brought to the Internet?
New 3D particle function in QT 6.3
Nangou Gili hard Kai font TTF Download with installation tutorial
QT creator 7-cmake update
Hcip day 16
Starting from 1.5, build a micro Service Framework -- log tracking traceid
从 1.5 开始搭建一个微服务框架——日志追踪 traceId
What if the files on the USB flash disk cannot be deleted? Win11 unable to delete U disk file solution tutorial
Global and Chinese markets of industrial pH meters 2022-2028: Research Report on technology, participants, trends, market size and share
Google Maps case