当前位置:网站首页>Numpy has no unsqueeze function
Numpy has no unsqueeze function
2022-07-28 00:33:00 【seven_ Not Severn】
unsqueeze: Add a length of 1 Dimensions .
import torch
arr = torch.Tensor(3, 5)
# print(type(arr), arr, arr.shape, sep='\n') #torch.Size([3, 5])
arr_1 = arr.unsqueeze(0) #torch.Size([1, 3, 5]) ###‘ Add dimension to the head ’
# print(type(arr_1), arr_1, arr_1.shape, sep='\n')
arr_2 = arr.unsqueeze(-1) #torch.Size([3, 5, 1]) ###‘ Tail plus dimension ’
# print(type(arr_2), arr_2, arr_2.shape, sep='\n')
arr_3 = arr.unsqueeze(1)#torch.Size([3, 1, 5]) ###‘ Add dimension in the middle ’
# print(type(arr_3), arr_3, arr_3.shape, sep='\n')
arr_4 = arr.unsqueeze(2) # No matter how big the number is, it will be wrong #torch.Size([3, 5, 1]) and “##(-1) equally
print(type(arr_4), arr_4, arr_4.shape, sep='\n')
边栏推荐
- How does matlab set the K-line diagram to classic red and green color matching?
- How to realize fast recognition of oversized images
- MATLAB | 那些你不得不知道的MATLAB小技巧(一)
- C# 事件相关的练习代码。
- [BRE]软件构建发布自动化
- C event related exercise code.
- R语言R原生plot函数和lines函数的主要参数说明、解析(type、pch、cex、lty、lwd、col、xlab、ylab)
- Promoting cloud network integration and building a digital economy: Intel unveiled the 5th Digital China Construction Summit - cloud ecosystem Conference
- code review 工具
- 元宇宙的应用场景展示
猜你喜欢

In the third week of July, the list of feigua data station B up main ranking list was released!

mysql分表之后怎么平滑上线?

MATLAB | 那些你不得不知道的MATLAB小技巧(二)

Annual comprehensive analysis of China's online video market in 2022

Window function over

Openvino integrates tensorflow to accelerate reasoning

「图神经网络:基础、前沿与应用」最新IJCAI2022教程

Matlab | those matlab tips you have to know (2)

MATLAB | 那些你不得不知道的MATLAB小技巧(三)

Promoting cloud network integration and building a digital economy: Intel unveiled the 5th Digital China Construction Summit - cloud ecosystem Conference
随机推荐
R语言R原生plot函数和lines函数的主要参数说明、解析(type、pch、cex、lty、lwd、col、xlab、ylab)
推进云网融合,筑路数字经济:英特尔亮相第五届数字中国建设峰会-云生态大会
Mqtt---mqtt.fx client software
How to deal with the website after it is hacked and how to delete batch malicious code
永州清洁级动物实验室建设选址注意事项
『百日百题 · 基础篇』备战面试,坚持刷题 第三话——分支语句!
The R language uses the hexsticker package to convert the visualized results of ggplot2 package into hexagonal diagrams (hexagonal stickers, hexagonal stickers, ggplot2 plot to hex stickers)
adb路径不能包含2空格remote couldn‘t create file: Is a directory
Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
Build Release Blogs
leetcode 452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球(中等)
Openvino integrates tensorflow to accelerate reasoning
基本初等函数
2022年中国网络视频市场年度综合分析
2022最新抖音直播监控全套监控(五)商品详情监控
永州分析实验室建设选址概述
Impulse attends the 2022 Forum on safe circulation of data elements Online - a special session in the field of government affairs, and helps the construction and innovative development of big data for
冲量在线出席2022数据要素安全流通论坛—政务领域专场,助力行业政务大数据建设创新发展
二舅治好我的精神内耗,也让我火出了B站
Introduction to thesis writing | how to write an academic research paper