当前位置:网站首页>torch stack() meshgrid()
torch stack() meshgrid()
2022-06-30 19:06:00 【Gy Zhao】
x= torch.arange(4)
y= torch.arange(4)
# Input is a one-dimensional sequence , Output two 2D meshes , Commonly used to generate coordinates
ox,oy = torch.meshgrid([x,y])
# Splice according to a certain dimension , Input sequence shape It has to be consistent , The default in accordance with the dim0
o2 = torch.stack((ox,oy))
print(ox,oy)
print(o2,o2.shape)
tensor([[0, 0, 0, 0],
[1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3]])
tensor([[0, 1, 2, 3],
[0, 1, 2, 3],
[0, 1, 2, 3],
[0, 1, 2, 3]])
amount to (0,0)(0,1)… Two pairs of elements with the same position of two-dimensional tensors are one coordinate
tensor([[[0, 0, 0, 0],
[1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3]],
[[0, 1, 2, 3],
[0, 1, 2, 3],
[0, 1, 2, 3],
[0, 1, 2, 3]]]) torch.Size([2, 4, 4])
边栏推荐
猜你喜欢

不同制造工艺对PCB上的焊盘的影响和要求

教你30分钟快速搭建直播间

ForkJoinPool

AI首席架构师10-AICA-蓝翔 《飞桨框架设计与核心技术》

Dlib库实现人脸关键点检测(Opencv实现)

AI chief architect 10-aica-lanxiang, propeller frame design and core technology

医疗行业企业供应链系统解决方案:实现医疗数智化供应链协同可视

ForkJoinPool

What if the apple watch fails to power on? Apple watch can not boot solution!

英飞凌--GTM架构-Generic Timer Module
随机推荐
基于 actix、async-graphql、rbatis、pgsql/mysql 构建 GraphQL 服务(4)-变更服务
手机股票账号开户安全吗?是靠谱的吗?
AI chief architect 10-aica-lanxiang, propeller frame design and core technology
Infineon - GTM architecture -generic timer module
正则表达式(正则匹配)
Swin-Transformer(2021-08)
Huaxing Securities: kitex practice under the original hybrid Cloud Architecture
PO模式简介「建议收藏」
ForkJoinPool
3.10 haas506 2.0 development tutorial example TFT
Tensorflow2 深度学习十必知
一文详解|Go 分布式链路追踪实现原理
Countdowncatch and completabilefuture and cyclicbarrier
Redis入门到精通01
基于STM32F1的环境光与微距离检测系统
Memory Limit Exceeded
Full recharge, im+rtc+x full communication service "feedback season" starts
Merged binary tree of leetcode
Sword finger offer 16 Integer power of numeric value
金融服务行业SaaS项目管理系统解决方案,助力企业挖掘更广阔的增长服务空间