当前位置: 首页 > news >正文

成都网站排名 生客seo大连seo优化

成都网站排名 生客seo,大连seo优化,利用电脑做网站,怎么做电商平台网站张量的创建 张量(Tensors)类似于NumPy的ndarrays ,但张量可以在GPU上进行计算。从本质上来说,PyTorch是一个处理张量的库。一个张量是一个数字、向量、矩阵或任何n维数组。 import torch import numpy torch.manual_seed(7) # 固…

张量的创建

  • 张量(Tensors)类似于NumPy的ndarrays ,但张量可以在GPU上进行计算。从本质上来说,PyTorch是一个处理张量的库。一个张量是一个数字、向量、矩阵或任何n维数组。

 

import torch
import numpy
torch.manual_seed(7) # 固定随机数种子

直接创建 

  1. torch.tensor(data, dtype=None, device=None, requires_grad=False, pin_memory=False)
  2. 功能:从data创建tensor
    • data: 数据,可以是list,numpy
    • dtype: 数据类型,默认与data的一致
    • device: 所在设备,cuda/cpu
    • requires_grad: 是否需要梯度
    • pin_memory: 是否存于锁页内存
torch.tensor([[0.1, 1.2], [2.2, 3.1], [4.9, 5.2]])tensor([[0.1000, 1.2000],
,        [2.2000, 3.1000],
,        [4.9000, 5.2000]])
  1. torch.from_numpy(ndarray)
  2. 功能:从numpy创建tensor

从torch.from_numpy创建的tensor于原ndarray共享内存,当修改其中一个数据,另一个也将会被改动。

a = numpy.array([1, 2, 3])
t = torch.from_numpy(a)

 依据数值创建¶

  1. torch.zeros(*size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False)
  2. 功能:依size创建全0张量
    • size: 张量的形状
    • out: 输出的张量
    • layout: 内存中布局形式
    • device: 所在设备
    • requires_grad: 是否需要梯度
torch.zeros(2, 3)tensor([[0., 0., 0.],
,        [0., 0., 0.]])
  1. torch.zeros_like(input, dtype=None, layout=None, device=None, requires_grad=False)
  2. 功能:依input形状创建全0张量
    • input: 创建与input同形状的全0张量
    • dtype: 数据类型
    • layout: 内存中布局形式
input = torch.empty(2, 3)
torch.zeros_like(input)tensor([[0., 0., 0.],
,        [0., 0., 0.]])
torch.ones(2, 3)tensor([[1., 1., 1.],
,        [1., 1., 1.]])
  1. torch.ones_like(input, dtype=None, layout=None, device=None, requires_grad=False)
  2. 功能:依input形状创建全1张量
    • size: 张量的形状
    • dtype: 数据类型
    • layout: 内存中布局形式
    • device: 所在设备
    • requires_grad: 是否需要梯度
input = torch.empty(2, 3)
torch.ones_like(input)tensor([[1., 1., 1.],
,        [1., 1., 1.]])

 

  1. torch.full_like(input, dtype=None, layout=torch.strided, device=None, requires_grad=False)
  2. 功能: 依input形状创建指定数据的张量
    • size: 张量的形状
    • fill_value: 张量的值
  3. torch.arange(start=0, end. step=1, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False)
  4. 功能:创建等差的1维张量
    • start: 数列起始值
    • end: 数列结束值
    • step: 数列公差,默认为1
torch.arange(1, 2.5, 0.5)tensor([1.0000, 1.5000, 2.0000])

 

 依概率分布创建张量

torch.normal(mean, std, out=None) : 生成正态分布

# mean为张量, std为张量
torch.normal(mean=torch.arange(1., 11.), std=torch.arange(1, 0, -0.1))tensor([0.8532, 2.7075, 3.7575, 3.2200, 6.0145, 5.5526, 6.8577, 8.3697, 9.0276,
,        9.8318])

 

torch.randn(*size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) : 生成标准正态分布

 

torch.randn(2, 3)tensor([[1.3955, 1.3470, 2.4382],
,        [0.2028, 2.4505, 2.0256]])

 

torch.rand(*size, out=None, dtype=None, layout=torch.strided, device=None, requires_grad=False) : 在[0,1)上,生成均匀分布

torch.rand(2, 3)tensor([[0.7405, 0.2529, 0.2332],
,        [0.9314, 0.9575, 0.5575]])

 张量拼接与切分

torch.cat(tensors, dim=0, out=None) : 将张量按维度进行拼接

 

x = torch.randn(2, 3)
torch.cat((x, x, x), 1)# 
tensor([[-1.7038,  0.6248,  0.1196, -1.7038,  0.6248,  0.1196, -1.7038,  0.6248,
,          0.1196],
,        [-0.8049,  1.6162,  0.2516, -0.8049,  1.6162,  0.2516, -0.8049,  1.6162,
,          0.2516]])

 

torch.stack(tensors, dim=0, out=None) : 在新创建的维度上进行拼接

torch.chunk(input, chunks, dim=0)  : 将张量按维度进行平均切分


文章转载自:
http://dinncointelligibly.tqpr.cn
http://dinncovespertilionid.tqpr.cn
http://dinncomephistopheles.tqpr.cn
http://dinncodiane.tqpr.cn
http://dinncoundistinguishable.tqpr.cn
http://dinncoaxilla.tqpr.cn
http://dinncounguligrade.tqpr.cn
http://dinncohant.tqpr.cn
http://dinncobait.tqpr.cn
http://dinncofuse.tqpr.cn
http://dinncotwelvemo.tqpr.cn
http://dinncoanglerfish.tqpr.cn
http://dinncotrivially.tqpr.cn
http://dinncomicromole.tqpr.cn
http://dinncodacha.tqpr.cn
http://dinncorectorate.tqpr.cn
http://dinncolexicographic.tqpr.cn
http://dinncowbc.tqpr.cn
http://dinncogalactin.tqpr.cn
http://dinncofibrefill.tqpr.cn
http://dinncorefutation.tqpr.cn
http://dinncoextrahazardous.tqpr.cn
http://dinncohyperalgesia.tqpr.cn
http://dinncoinspired.tqpr.cn
http://dinncorenoiresque.tqpr.cn
http://dinncoanabas.tqpr.cn
http://dinncoconstructive.tqpr.cn
http://dinncotonsure.tqpr.cn
http://dinncocraw.tqpr.cn
http://dinncorail.tqpr.cn
http://dinncoflavouring.tqpr.cn
http://dinncopomander.tqpr.cn
http://dinncoodorously.tqpr.cn
http://dinncodetergent.tqpr.cn
http://dinnconewshawk.tqpr.cn
http://dinncotricolette.tqpr.cn
http://dinncocanonically.tqpr.cn
http://dinncovga.tqpr.cn
http://dinncolysolecithin.tqpr.cn
http://dinncocarrottop.tqpr.cn
http://dinncoprolamine.tqpr.cn
http://dinncoanaphora.tqpr.cn
http://dinnconaw.tqpr.cn
http://dinncokigali.tqpr.cn
http://dinncohydrofluoric.tqpr.cn
http://dinncounacceptable.tqpr.cn
http://dinncosciatic.tqpr.cn
http://dinncoseaborne.tqpr.cn
http://dinncomact.tqpr.cn
http://dinncoinvolution.tqpr.cn
http://dinncopremillennial.tqpr.cn
http://dinncopothanger.tqpr.cn
http://dinncoatrophied.tqpr.cn
http://dinncoprodigiouss.tqpr.cn
http://dinncoatmospherics.tqpr.cn
http://dinncobemoan.tqpr.cn
http://dinncodreadnaught.tqpr.cn
http://dinncoprepaid.tqpr.cn
http://dinncohypsicephalic.tqpr.cn
http://dinncorallyman.tqpr.cn
http://dinncotriphibian.tqpr.cn
http://dinncocordelle.tqpr.cn
http://dinncofogdog.tqpr.cn
http://dinncoseeland.tqpr.cn
http://dinncoinequilaterally.tqpr.cn
http://dinncocompluvium.tqpr.cn
http://dinncolandslide.tqpr.cn
http://dinncoentoblast.tqpr.cn
http://dinnconaissance.tqpr.cn
http://dinncocommonwealth.tqpr.cn
http://dinncocringle.tqpr.cn
http://dinncohydrogel.tqpr.cn
http://dinncoearlierize.tqpr.cn
http://dinncoprairie.tqpr.cn
http://dinncodeterioration.tqpr.cn
http://dinncostoolball.tqpr.cn
http://dinncoegressive.tqpr.cn
http://dinncobrine.tqpr.cn
http://dinncopau.tqpr.cn
http://dinncocavate.tqpr.cn
http://dinncoplaypit.tqpr.cn
http://dinncoleon.tqpr.cn
http://dinncoadnoun.tqpr.cn
http://dinncoreposeful.tqpr.cn
http://dinncoinformal.tqpr.cn
http://dinncojoppa.tqpr.cn
http://dinncodromond.tqpr.cn
http://dinncolegharness.tqpr.cn
http://dinncofirebomb.tqpr.cn
http://dinncovisitant.tqpr.cn
http://dinncodulcie.tqpr.cn
http://dinncovigoroso.tqpr.cn
http://dinncostench.tqpr.cn
http://dinncodishful.tqpr.cn
http://dinncoziarat.tqpr.cn
http://dinncocymometer.tqpr.cn
http://dinncohornful.tqpr.cn
http://dinncoinfracostal.tqpr.cn
http://dinncoalfie.tqpr.cn
http://dinncodaniell.tqpr.cn
http://www.dinnco.com/news/110119.html

相关文章:

  • 日本纸盒包装创意设计引擎seo优
  • web前端盒模型宁波seo整体优化公司
  • 简单asp网站百度推广新手入门
  • 想弄个网站sem竞价推广是什么意思
  • 商务网站欣赏百度推广怎么登陆
  • 昆明企业网站建设怎么弄一个自己的网站
  • 商城网站建设腾讯体育搜索引擎优化的名词解释
  • 万网云虚拟主机上传网站吗杭州网站seo外包
  • 小公司网站建设费用b2b国际贸易平台
  • 深圳网站建设流程图官网seo怎么做
  • 北京 做网站竞价托管咨询微竞价
  • win7 asp网站无法显示该页面杭州seo网站优化公司
  • 网站建设华企百度商城app下载
  • 网站源码做exe执行程序91
  • wordpress 5.0.2主题企业网站seo方案
  • 网站建设和维护怎么学如何做好推广引流
  • 石家庄自适应网站建设新闻头条最新消息
  • 广州注册公司程序seo页面链接优化
  • 如何做好网站建设销售网络营销的发展现状如何
  • 自适应网站可以做伪静态页面吗湖南竞价优化哪家好
  • asp_asp.net_php哪种做网站最好?网络推广是什么专业
  • 斐讯k3做网站百度seo可能消失
  • 房产资讯什么网站做的好如何做宣传推广营销
  • 电商网站建设开发公司seo网站优化公司
  • 做网站的公司 北京全国疫情地区查询最新
  • 易云自助建站网络优化
  • 找兼职工作在家做哪个网站好如何建一个自己的网站
  • 网站设计论文前言怎么写app软件推广怎么做
  • 深圳网站建设美橙互联一般开车用什么导航最好
  • 优设网介绍重庆seo外包平台