美文网首页Python 使用
resize_()的基本用法

resize_()的基本用法

作者: 吐舌小狗 | 来源:发表于2018-03-14 15:35 被阅读13次

1.tensor.resize_()

import torch
x = torch.Tensor([[1, 2], [4, 5], [7, 8], [9, 0]])
print(x)
输出>>
 1  2
 4  5
 7  8
 9  0
[torch.FloatTensor of size 4x2]

实际的数据的size是4*2

x.resize_(2, 2)
print(x)
输出>>
 1  2
 4  5
[torch.FloatTensor of size 2x2]

当设置为2,2时,全部的数据被当成list,选取前面的四个作为输出

x.resize_(2, 3)
print(x)
输出>>
 1  2  4
 5  7  8
[torch.FloatTensor of size 2x3]

当设置为2,3时,全部的数据被当成list,选取前面的六个作为输出

x.resize_(2, 4)
print(x)
 1  2  4  5
 7  8  9  0
[torch.FloatTensor of size 2x4]
x.resize_(2, 5)
print(x)
输出>>
 1.0000  2.0000  4.0000  5.0000  7.0000
 8.0000  9.0000  0.0000  0.0000  0.0000
[torch.FloatTensor of size 2x5]

当设置为2,5时,实际的数据小于设置的大小,就在后面补0

相关文章

  • resize_()的基本用法

    1.tensor.resize_() 实际的数据的size是4*2 当设置为2,2时,全部的数据被当成list,选...

  • 定时器

    setTimeout和clearTimeout基本用法 setInterval和clearInterval基本用法...

  • 2019-11-16

    E战到底DAY14 SUMIF和SUMIFS函数 一.基本用法 SUMIF基本用法 SUMIFS基本用法 SUMI...

  • 11 - 动态数据绑定实现原理

    一、defineProperty 基本用法 1、基本写法: 2、参数 3、descriptor 参数的基本用法 1...

  • 查找函数(Vlookup、Hlookup、Index、Match

    查找函数(Vlookup、Hlookup、Index、Match) 一、基本用法 (1)、VLOOKUP的基本用法...

  • AFNetWorking

    AFNetworking的基本使用 网络请求 AFNetworking的基本用法和NSURLSession的用法基...

  • as 基本用法

    插件安装 plugin auto import 相当于 eclipse ctrl+o 或者as alt+enter...

  • 基本用法

    Installation 安装 npm install vue vue-server-renderer --sav...

  • 基本用法

    html css js

  • 基本用法

    本地与远程:push 命令会把本地仓库推送到远程仓库(比如gitbub,码云)在push之前要与某个远程仓库建立连...

网友评论

    本文标题:resize_()的基本用法

    本文链接:https://www.haomeiwen.com/subject/ktfxqftx.html