application 1

 from torch.autograd import Variable
import torch
b = Variable(torch.FloatTensor([64, 100, 43]))
print(b)
'''
Variable containing:
64
100
43
[torch.FloatTensor of size 3]
'''

application 2

 from torch.autograd import Variable
import torch a1 = Variable(torch.randn(64, 100, 43))
# print(a)
a2 = Variable(torch.randn(64, 100, 44))
a3 = Variable(torch.randn(64, 100, 45))
a = [a1, a2, a3] # method 1
a = torch.cat((i.data for i in a), 2)
# method 2
a = torch.cat(a, 2)
print(a)
'''
Variable containing:
( 0 ,.,.) =
-8.0339e-01 -1.0054e+00 -3.8750e-01 ... -8.1924e-01 -5.0174e-01 1.2302e+00
-2.4266e+00 3.8993e-01 9.6254e-01 ... -2.6002e-01 3.8668e-01 -1.0960e+00
-9.8618e-01 1.5732e-01 -7.6385e-01 ... -9.6085e-01 4.7323e-01 1.0353e+00
... ⋱ ...
(63 ,.,.) =
-8.9123e-01 8.9774e-01 -1.1528e+00 ... 2.8538e-01 -1.3932e+00 -3.7968e-01
1.0256e+00 2.1746e+00 6.9736e-01 ... 1.2657e+00 -1.0258e+00 5.7128e-01
-1.0966e+00 7.1878e-01 3.5268e-01 ... 3.5731e-01 1.9369e+00 -7.3994e-01
[torch.FloatTensor of size 64x100x132]
'''

function_cat()

 >>> x = torch.randn(2, 3)
>>> x 0.5983 -0.0341 2.4918
1.5981 -0.5265 -0.8735
[torch.FloatTensor of size 2x3] >>> torch.cat((x, x, x), 0) 0.5983 -0.0341 2.4918
1.5981 -0.5265 -0.8735
0.5983 -0.0341 2.4918
1.5981 -0.5265 -0.8735
0.5983 -0.0341 2.4918
1.5981 -0.5265 -0.8735
[torch.FloatTensor of size 6x3] >>> torch.cat((x, x, x), 1) 0.5983 -0.0341 2.4918 0.5983 -0.0341 2.4918 0.5983 -0.0341 2.4918
1.5981 -0.5265 -0.8735 1.5981 -0.5265 -0.8735 1.5981 -0.5265 -0.8735
[torch.FloatTensor of size 2x9]

PyTorch学习笔记之Variable_and_function_cat的更多相关文章

  1. Pytorch学习笔记(二)---- 神经网络搭建

    记录如何用Pytorch搭建LeNet-5,大体步骤包括:网络的搭建->前向传播->定义Loss和Optimizer->训练 # -*- coding: utf-8 -*- # Al ...

  2. Pytorch学习笔记(一)---- 基础语法

    书上内容太多太杂,看完容易忘记,特此记录方便日后查看,所有基础语法以代码形式呈现,代码和注释均来源与书本和案例的整理. # -*- coding: utf-8 -*- # All codes and ...

  3. 【pytorch】pytorch学习笔记(一)

    原文地址:https://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.html 什么是pytorch? pytorch是一个基于p ...

  4. 【深度学习】Pytorch 学习笔记

    目录 Pytorch Leture 05: Linear Rregression in the Pytorch Way Logistic Regression 逻辑回归 - 二分类 Lecture07 ...

  5. Pytorch学习笔记(一)——简介

    一.Tensor Tensor是Pytorch中重要的数据结构,可以认为是一个高维数组.Tensor可以是一个标量.一维数组(向量).二维数组(矩阵)或者高维数组等.Tensor和numpy的ndar ...

  6. [PyTorch 学习笔记] 1.3 张量操作与线性回归

    本章代码:https://github.com/zhangxiann/PyTorch_Practice/blob/master/lesson1/linear_regression.py 张量的操作 拼 ...

  7. [PyTorch 学习笔记] 1.1 PyTorch 简介与安装

    PyTorch 的诞生 2017 年 1 月,FAIR(Facebook AI Research)发布了 PyTorch.PyTorch 是在 Torch 基础上用 python 语言重新打造的一款深 ...

  8. [PyTorch 学习笔记] 1.4 计算图与动态图机制

    本章代码:https://github.com/zhangxiann/PyTorch_Practice/blob/master/lesson1/computational_graph.py 计算图 深 ...

  9. [PyTorch 学习笔记] 2.2 图片预处理 transforms 模块机制

    PyTorch 的数据增强 我们在安装PyTorch时,还安装了torchvision,这是一个计算机视觉工具包.有 3 个主要的模块: torchvision.transforms: 里面包括常用的 ...

随机推荐

  1. 【HIHOCODER 1420】 Bigint Multiplication

    描述 Given 2 nonnegative integers a and b, calculate a × b. 输入 One line with 2 integers a and b separa ...

  2. 【HIHOCODER 1403】后缀数组一·重复旋律(后缀数组)

    描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为长度为 N 的数构成的数列. 小Hi在练习过很多曲子以后发现很多作品自身包含一样的旋律.旋律是一段连续的数列,相似的旋律在原数列 ...

  3. Linux编程中链接库的使用

    链接库本质上是一段可执行的二进制代码,可以被操作系统载入内存执行.按加载的时机不同,链接库可以分为静态链接库和动态链接库. 静态链接库:编译过程中加载进可执行文件的库(静态库省去了运行时加载的消耗,但 ...

  4. 牛客练习赛22 C 简单瞎搞题

    //位运算 // & 都是1 才是 1 // | 都是0 才是0 // ^ 不一样才是1 #include <iostream> #include <cstdio> # ...

  5. 第十四届华中科技大学程序设计竞赛决赛同步赛 Beautiful Land

    It’s universally acknowledged that there’re innumerable trees in the campus of HUST.Now HUST got a b ...

  6. source insight

    关于source inlight的版本 http://www.camnpr.com/archives/559.html   最新版本 http://www.sourceinsight.com/upda ...

  7. 利用virt-manager,xmanager, xshell启动界面来管理虚拟机

    有时候我们需要搭建一套自己的简单环境来启动一个虚拟机,验证一些问题. 1.首先我利用vmware workstation来创建centos7虚拟机,然后开启虚拟化,如下图所示. 2.其次,启动虚拟机, ...

  8. selenium2中TestNG相关解释

    testNg官网:http://testng.org/doc/documentation-main.html 新建testNG class的时候,同时也新建了一个TestNG.xml的文件. 此xml ...

  9. UVa 1309 DLX Sudoku

    16×16的数独. 看白书学的DLX,有些细节还有待消化,贴个模板先. #include <cstdio> #include <cstring> #include <al ...

  10. luogu3386 【模板】二分图匹配 匈牙利算法 hdu2063 过山车 dinic

    luogu 匈牙利算法 #include <iostream> #include <cstring> #include <cstdio> using namespa ...