当前位置:网站首页>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]])
边栏推荐
- Nangou Gili hard Kai font TTF Download with installation tutorial
- d3dx9_ How to repair 31.dll_ d3dx9_ 31. Solution to missing DLL
- 抖音__ac_signature
- 我对新中台模型的一些经验思考总结
- Ieventsystemhandler event interface
- 链表之双指针(快慢指针,先后指针,首尾指针)
- BFC block level formatting context
- Why does the C# compiler allow an explicit cast between IEnumerable< T> and TAlmostAnything?
- Double pointeur de liste liée (pointeur rapide et lent, pointeur séquentiel, pointeur de tête et de queue)
- The introduction to go language is very simple: String
猜你喜欢

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

Google Maps case

What about data leakage? " Watson k'7 moves to eliminate security threats

Distributed resource management and task scheduling framework yarn

Interview questions for famous enterprises: Coins represent a given value

Technology cloud report: how many hurdles does the computing power network need to cross?

I closed the open source project alinesno cloud service

All expansion and collapse of a-tree

南京:全面启用商品房买卖电子合同

谷歌地图案例
随机推荐
Global and Chinese markets of industrial pH meters 2022-2028: Research Report on technology, participants, trends, market size and share
抖音__ac_signature
What if win11 is missing a DLL file? Win11 system cannot find DLL file repair method
Starting from 1.5, build a micro Service Framework -- log tracking traceid
Metaverse ape received $3.5 million in seed round financing from negentropy capital
Distributed solution selection
VOT Toolkit环境配置与使用
Interview questions for famous enterprises: Coins represent a given value
2022软件测试工程师涨薪攻略,3年如何达到30K
[agc009e] eternal average - conclusion, DP
90后测试员:“入职阿里,这一次,我决定不在跳槽了”
Unique occurrence times of leetcode simple questions
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
[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)
Damn, window in ie open()
Overriding equals() & hashCode() in sub classes … considering super fields
Nacos installation and service registration
Some tutorials install the database on ubantu so as not to occupy computer memory?
The countdown to the launch of metaverse ape is hot
Platformio create libopencm3 + FreeRTOS project