当前位置:网站首页>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')
边栏推荐
- 数据中台的那些“经验与陷阱”
- Introduction to thesis writing | how to write an academic research paper
- View the construction details of Yongzhou dioxin Laboratory
- 渲染问题
- leetcode 452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球(中等)
- Intel releases open source AI Reference Suite
- 学yolo需要什么基础?怎么学YOLO?
- See how well-known enterprises use Web3 to reshape their industries
- Leetcode 452. minimum number of arrows to burst balloons (medium)
- Shell(3)
猜你喜欢
随机推荐
Yuanuniverse office, the ultimate dream of migrant workers
What a beautiful rainbow
Analysis and solution of errors in symbols uploading when baget manages packages
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
How does matlab set the K-line diagram to classic red and green color matching?
Implement Gobang game with C language
49 times faster, NVIDIA releases quantum hybrid programming platform qoda
Strong collaboration and common development! Intel and Taiyi IOT held a seminar on AI computing box aggregation services
阿里二面:为什么要分库分表?
英特尔携手汉朔、微软,释放“AI + 零售”大招!
Leetcode 452. minimum number of arrows to burst balloons (medium)
7月第3周榜单丨飞瓜数据B站UP主排行榜发布!
Jin's thinking
泵站远程监控
Precautions for site selection of Yongzhou clean animal laboratory
threejs个人笔记
元宇宙办公,打工人的终极梦想
Remote solution of Internet of things system in Mechanical Engineering
How to realize fast recognition of oversized images
[sel object of Objective-C language]








