当前位置:网站首页>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')
边栏推荐
- leetcode 452. Minimum Number of Arrows to Burst Balloons 用最少数量的箭引爆气球(中等)
- Application scenario Display of metauniverse
- code review 工具
- 很棒的一个思维题CF1671D Insert a Progression
- Esp8266----- mqtt cloud device on cloud
- 窗口函数over
- Oracle密码过期解决办法
- Matlab | those matlab tips you have to know (2)
- 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)
- Those "experiences and traps" in the data center
猜你喜欢

Is there a general formula for tens of millions of players? B station is underestimated as a hot money opportunity!

阿里二面:为什么要分库分表?

Intel releases open source AI Reference Suite

Window function over

Harmonyos 3 pure mode can limit the access to personal data of risk applications detected in Huawei's application market

MFC提示this application has requested the runtime to terminate it in an unusual way editbox框已经删了还在使用

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 difficult is it to apply for a doctorate under the post system in northern Europe?

҈ straight ҈ Broadcast ҈ Pre ҈ Report ҈ |҈ In hot summer, let's cross the high temperature and "bake" with nono!

Matlab | those matlab tips you have to know (4)
随机推荐
元宇宙办公,打工人的终极梦想
Server open sensitive port
服务器中毒了——菜是原罪
Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
看知名企业们如何利用 Web3进行产业重塑
Mqtt---mqtt.fx client software
【Objective-C语言的SEL对象】
渲染问题
服务器开放敏感端口
Precautions for site selection of Yongzhou clean animal laboratory
【打新必读】魅视科技估值分析,分布式视听产品及解决方案
Matlab | those matlab tips you have to know (I)
y79.第四章 Prometheus大厂监控体系及实战 -- prometheus的服务发现机制(十)
Understand the parental delegation model
Those "experiences and traps" in the data center
Database tuning - principle analysis and JMeter case sharing
Intel joins hands with hanshuo and Microsoft to release the "Ai + retail" trick!
How difficult is it to apply for a doctorate under the post system in northern Europe?
Read one line of string input each time (to be supplemented)
很棒的一个思维题CF1671D Insert a Progression