当前位置:网站首页>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]])
边栏推荐
- Ieventsystemhandler event interface
- Event trigger requirements of the function called by the event trigger
- VIM tail head intercept file import
- [secretly kill little buddy pytorch20 days] - [Day2] - [example of picture data modeling process]
- Usage Summary of scriptable object in unity
- Metasploit(msf)利用ms17_010(永恒之蓝)出现Encoding::UndefinedConversionError问题
- All expansion and collapse of a-tree
- Overview of Fourier analysis
- Cobaltstrike builds an intranet tunnel
- 记录几个常见问题(202207)
猜你喜欢
90后测试员:“入职阿里,这一次,我决定不在跳槽了”
鏈錶之雙指針(快慢指針,先後指針,首尾指針)
Nacos installation and service registration
Postman核心功能解析-参数化和测试报告
[secretly kill little buddy pytorch20 days] - [Day2] - [example of picture data modeling process]
The difference between MVVM and MVC
Event trigger requirements of the function called by the event trigger
Distributed resource management and task scheduling framework yarn
Calculation method of boundary IOU
50. Pow(x, n). O(logN) Sol
随机推荐
Global and Chinese markets of tantalum heat exchangers 2022-2028: Research Report on technology, participants, trends, market size and share
How can Bluetooth in notebook computer be used to connect headphones
Postman core function analysis - parameterization and test report
509. Fibonacci Number. Sol
Promql demo service
The introduction to go language is very simple: String
The new content of the text component can be added through the tag_ Config set foreground and background colors
ESP32 hosted
Nanjing: full use of electronic contracts for commercial housing sales
50. Pow(x, n). O(logN) Sol
Arduino measures AC current
如何创建线程
MCU case -int0 and INT1 interrupt count
IIC bus realizes client device
Sparse array [matrix]
Analysis of the problem that the cookie value in PHP contains a plus sign (+) and becomes a space
VIM tail head intercept file import
What changes has Web3 brought to the Internet?
Metaverse Ape获Negentropy Capital种子轮融资350万美元
Go language learning tutorial (XV)