当前位置:网站首页>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]])
边栏推荐
- Some tutorials install the database on ubantu so as not to occupy computer memory?
- 解决thinkphp启动时“No input file specified”的问题
- Metaverse Ape上线倒计时,推荐活动火爆进行
- Distributed resource management and task scheduling framework yarn
- 344. Reverse String. Sol
- MySQL服务莫名宕机的解决方案
- Boring boring
- Qtquick3d real time reflection
- Opencv judgment points are inside and outside the polygon
- Exponential weighted average and its deviation elimination
猜你喜欢

基于STM32的ADC采样序列频谱分析

513. Find the value in the lower left corner of the tree

实战:fabric 用户证书吊销操作流程

Solutions for unexplained downtime of MySQL services

IIC bus realizes client device

Post-90s tester: "after joining Ali, this time, I decided not to change jobs."

90后测试员:“入职阿里,这一次,我决定不在跳槽了”

Distance entre les points et les lignes

2022软件测试工程师涨薪攻略,3年如何达到30K

Metaverse Ape上线倒计时,推荐活动火爆进行
随机推荐
Practice: fabric user certificate revocation operation process
链表之双指针(快慢指针,先后指针,首尾指针)
Calculation method of boundary IOU
[Chongqing Guangdong education] National Open University autumn 2018 0088-21t Insurance Introduction reference questions
Nail error code Encyclopedia
IIC bus realizes client device
点到直线的距离直线的交点及夹角
基于STM32的ADC采样序列频谱分析
TCC of distributed solutions
How can Bluetooth in notebook computer be used to connect headphones
The difference between MVVM and MVC
509. Fibonacci Number. Sol
119. Pascal‘s Triangle II. Sol
New 3D particle function in QT 6.3
The code generator has deoptimised the styling of xx/typescript. js as it exceeds the max of 500kb
[untitled]
解决thinkphp启动时“No input file specified”的问题
VOT Toolkit环境配置与使用
MySQL服务莫名宕机的解决方案
Oracle is sorted by creation time. If the creation time is empty, the record is placed last