x.unsqueeze(-1)
时间: 2023-10-16 17:05:16 浏览: 159
pyTorch.randn()、rand()、cat()、pow()、scatter_()、.squeeze() 、.unsqueeze()
5星 · 资源好评率100%
x.unsqueeze(-1)是将张量x在最后一个维度上增加一个维度。具体而言,如果x的形状是(1, 2, 3, 4),那么x.unsqueeze(-1)将返回一个形状为(1, 2, 3, 4, 1)的新张量。这意味着在原来的张量上增加了一个长度为1的维度。这种操作可以用来改变张量的形状,以满足特定的计算需求。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Pytorch squeeze() unsqueeze() 用法](https://blog.csdn.net/weixin_43820352/article/details/125995034)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [PyTorch版《动手学深度学习》学习笔记 Task.4](https://download.csdn.net/download/weixin_38695773/14034979)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [pytorch中的squeeze和unsqueeze](https://blog.csdn.net/flying_all/article/details/117014995)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文