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

网站建设中 很快回来虚拟app制作

网站建设中 很快回来,虚拟app制作,门户网站做啥,建网站建设文章目录 1. einops2. code3. pytorch 1. einops einops 主要是通过爱因斯坦标记法来处理张量矩阵的库,让矩阵处理上非常简单。 conda : conda install conda-forge::einopspython: 2. code import torch import torch.nn as nn import torch.nn.functional as…

文章目录

  • 1. einops
  • 2. code
  • 3. pytorch

1. einops

einops 主要是通过爱因斯坦标记法来处理张量矩阵的库,让矩阵处理上非常简单。

  • conda :
conda install conda-forge::einops
  • python:

2. code

import torch
import torch.nn as nn
import torch.nn.functional as F
from einops import rearrange, repeat, reducetorch.set_printoptions(precision=3, sci_mode=False)if __name__ == "__main__":run_code = 0x = torch.arange(96).reshape((2, 3, 4, 4)).to(torch.float32)print(f"x.shape={x.shape}")print(f"x=\n{x}")# 1. 转置x_torch_trans = x.transpose(1, 2)x_einops_trans = rearrange(x, 'b i w h -> b w i h')x_check_trans = torch.allclose(x_torch_trans, x_einops_trans)print(f"x_torch_trans is {x_check_trans} same with x_einops_trans")# 2. 变形x_torch_reshape = x.reshape(6, 4, 4)x_einops_reshape = rearrange(x, 'b i w h -> (b i) w h')x_check_reshape = torch.allclose(x_torch_reshape, x_einops_reshape)print(f"x_einops_reshape is {x_check_reshape} same with x_check_reshape")# 3. image2patchimage2patch = rearrange(x, 'b i (h1 p1) (w1 p2) -> b i (h1 w1) p1 p2', p1=2, p2=2)print(f"image2patch.shape={image2patch.shape}")print(f"image2patch=\n{image2patch}")image2patch2 = rearrange(image2patch, 'b i j h w -> b (i j) h w')print(f"image2patch2.shape={image2patch2.shape}")print(f"image2patch2=\n{image2patch2}")y = torch.arange(24).reshape((2, 3, 4)).to(torch.float32)y_einops_mean = reduce(y, 'b h w -> b h', 'mean')print(f"y=\n{y}")print(f"y_einops_mean=\n{y_einops_mean}")y_tensor = torch.arange(24).reshape(2, 2, 2, 3)y_list = [y_tensor, y_tensor, y_tensor]y_output = rearrange(y_list, 'n b i h w -> n b i h w')print(f"y_tensor=\n{y_tensor}")print(f"y_output=\n{y_output}")z_tensor = torch.arange(12).reshape(2, 2, 3).to(torch.float32)z_tensor_1 = rearrange(z_tensor, 'b h w -> b h w 1')print(f"z_tensor=\n{z_tensor}")print(f"z_tensor_1=\n{z_tensor_1}")z_tensor_2 = repeat(z_tensor_1, 'b h w 1 -> b h w 2')print(f"z_tensor_2=\n{z_tensor_2}")z_tensor_repeat = repeat(z_tensor, 'b h w -> b (2 h) (2 w)')print(f"z_tensor_repeat=\n{z_tensor_repeat}")
  • python:
x.shape=torch.Size([2, 3, 4, 4])
x=
tensor([[[[ 0.,  1.,  2.,  3.],[ 4.,  5.,  6.,  7.],[ 8.,  9., 10., 11.],[12., 13., 14., 15.]],[[16., 17., 18., 19.],[20., 21., 22., 23.],[24., 25., 26., 27.],[28., 29., 30., 31.]],[[32., 33., 34., 35.],[36., 37., 38., 39.],[40., 41., 42., 43.],[44., 45., 46., 47.]]],[[[48., 49., 50., 51.],[52., 53., 54., 55.],[56., 57., 58., 59.],[60., 61., 62., 63.]],[[64., 65., 66., 67.],[68., 69., 70., 71.],[72., 73., 74., 75.],[76., 77., 78., 79.]],[[80., 81., 82., 83.],[84., 85., 86., 87.],[88., 89., 90., 91.],[92., 93., 94., 95.]]]])
x_torch_trans is True same with x_einops_trans
x_einops_reshape is True same with x_check_reshape
image2patch.shape=torch.Size([2, 3, 4, 2, 2])
image2patch=
tensor([[[[[ 0.,  1.],[ 4.,  5.]],[[ 2.,  3.],[ 6.,  7.]],[[ 8.,  9.],[12., 13.]],[[10., 11.],[14., 15.]]],[[[16., 17.],[20., 21.]],[[18., 19.],[22., 23.]],[[24., 25.],[28., 29.]],[[26., 27.],[30., 31.]]],[[[32., 33.],[36., 37.]],[[34., 35.],[38., 39.]],[[40., 41.],[44., 45.]],[[42., 43.],[46., 47.]]]],[[[[48., 49.],[52., 53.]],[[50., 51.],[54., 55.]],[[56., 57.],[60., 61.]],[[58., 59.],[62., 63.]]],[[[64., 65.],[68., 69.]],[[66., 67.],[70., 71.]],[[72., 73.],[76., 77.]],[[74., 75.],[78., 79.]]],[[[80., 81.],[84., 85.]],[[82., 83.],[86., 87.]],[[88., 89.],[92., 93.]],[[90., 91.],[94., 95.]]]]])
image2patch2.shape=torch.Size([2, 12, 2, 2])
image2patch2=
tensor([[[[ 0.,  1.],[ 4.,  5.]],[[ 2.,  3.],[ 6.,  7.]],[[ 8.,  9.],[12., 13.]],[[10., 11.],[14., 15.]],[[16., 17.],[20., 21.]],[[18., 19.],[22., 23.]],[[24., 25.],[28., 29.]],[[26., 27.],[30., 31.]],[[32., 33.],[36., 37.]],[[34., 35.],[38., 39.]],[[40., 41.],[44., 45.]],[[42., 43.],[46., 47.]]],[[[48., 49.],[52., 53.]],[[50., 51.],[54., 55.]],[[56., 57.],[60., 61.]],[[58., 59.],[62., 63.]],[[64., 65.],[68., 69.]],[[66., 67.],[70., 71.]],[[72., 73.],[76., 77.]],[[74., 75.],[78., 79.]],[[80., 81.],[84., 85.]],[[82., 83.],[86., 87.]],[[88., 89.],[92., 93.]],[[90., 91.],[94., 95.]]]])
y=
tensor([[[ 0.,  1.,  2.,  3.],[ 4.,  5.,  6.,  7.],[ 8.,  9., 10., 11.]],[[12., 13., 14., 15.],[16., 17., 18., 19.],[20., 21., 22., 23.]]])
y_einops_mean=
tensor([[ 1.500,  5.500,  9.500],[13.500, 17.500, 21.500]])
y_tensor=
tensor([[[[ 0,  1,  2],[ 3,  4,  5]],[[ 6,  7,  8],[ 9, 10, 11]]],[[[12, 13, 14],[15, 16, 17]],[[18, 19, 20],[21, 22, 23]]]])
y_output=
tensor([[[[[ 0,  1,  2],[ 3,  4,  5]],[[ 6,  7,  8],[ 9, 10, 11]]],[[[12, 13, 14],[15, 16, 17]],[[18, 19, 20],[21, 22, 23]]]],[[[[ 0,  1,  2],[ 3,  4,  5]],[[ 6,  7,  8],[ 9, 10, 11]]],[[[12, 13, 14],[15, 16, 17]],[[18, 19, 20],[21, 22, 23]]]],[[[[ 0,  1,  2],[ 3,  4,  5]],[[ 6,  7,  8],[ 9, 10, 11]]],[[[12, 13, 14],[15, 16, 17]],[[18, 19, 20],[21, 22, 23]]]]])
z_tensor=
tensor([[[ 0.,  1.,  2.],[ 3.,  4.,  5.]],[[ 6.,  7.,  8.],[ 9., 10., 11.]]])
z_tensor_1=
tensor([[[[ 0.],[ 1.],[ 2.]],[[ 3.],[ 4.],[ 5.]]],[[[ 6.],[ 7.],[ 8.]],[[ 9.],[10.],[11.]]]])
z_tensor_2=
tensor([[[[ 0.,  0.],[ 1.,  1.],[ 2.,  2.]],[[ 3.,  3.],[ 4.,  4.],[ 5.,  5.]]],[[[ 6.,  6.],[ 7.,  7.],[ 8.,  8.]],[[ 9.,  9.],[10., 10.],[11., 11.]]]])
z_tensor_repeat=
tensor([[[ 0.,  1.,  2.,  0.,  1.,  2.],[ 3.,  4.,  5.,  3.,  4.,  5.],[ 0.,  1.,  2.,  0.,  1.,  2.],[ 3.,  4.,  5.,  3.,  4.,  5.]],[[ 6.,  7.,  8.,  6.,  7.,  8.],[ 9., 10., 11.,  9., 10., 11.],[ 6.,  7.,  8.,  6.,  7.,  8.],[ 9., 10., 11.,  9., 10., 11.]]])

3. pytorch

在这里插入图片描述


文章转载自:

http://Pl6AgtMA.hytqt.cn
http://E4hBTUsN.hytqt.cn
http://GMDi4xtO.hytqt.cn
http://lH8eMU35.hytqt.cn
http://nxcXdDzR.hytqt.cn
http://gBIKCCtv.hytqt.cn
http://BeCAjbgi.hytqt.cn
http://TPpqTi9k.hytqt.cn
http://w6gT9ZxF.hytqt.cn
http://Ay151zed.hytqt.cn
http://loImyy13.hytqt.cn
http://dHUjxJw6.hytqt.cn
http://aPtFrjIM.hytqt.cn
http://ltZO0lzb.hytqt.cn
http://12Ta3vf4.hytqt.cn
http://Q55seecy.hytqt.cn
http://f6ZvcW80.hytqt.cn
http://3dfFasCX.hytqt.cn
http://6BTtGhP4.hytqt.cn
http://g1m62GLx.hytqt.cn
http://Aov7pCPW.hytqt.cn
http://okFqXit0.hytqt.cn
http://vQ9k92ue.hytqt.cn
http://2qTvRn0b.hytqt.cn
http://Chk7Eiqv.hytqt.cn
http://79Lg8xTI.hytqt.cn
http://GwOaPlvU.hytqt.cn
http://CGLMAn7P.hytqt.cn
http://ToBEOcvW.hytqt.cn
http://6MBoaEac.hytqt.cn
http://www.dtcms.com/wzjs/679877.html

相关文章:

  • 做网站go和php用哪个好淘宝网官网登录首页
  • 手机网站 动态 页面 好 静态页面好找印度人做网站
  • 做个简单的企业小网站公司简介模板下载
  • 国内优秀的网站设计建网站的公司排名
  • 网站建设流程及相应技术用asp做网站需要安装什么软件
  • 怎么做淘宝优惠券网站招聘网站如何做运营
  • 下做图软件在哪个网站下载仿小米 wordpress
  • 邢台做网站费用网页制作公司地址
  • 网站设计流程步骤江苏苏州网站建设
  • 境内境外网站区别陕西门户网站建设
  • 如何选择做网站公司湛江做网站seo的
  • 自己如何创立网站万网手机网站
  • 网站建设xml下载成都seo公司排名
  • 企业网站模板 优帮云深圳宝安区是富人区吗
  • 网站内的搜索怎么做的秦皇岛视频优化代理
  • 嘉兴网站开发与制作ui设计的作用
  • 新闻cms静态网站模板下载网站维护方案怎么做
  • 网站建设中的html页面下载做网站一定要域名吗
  • 中山市网站建设 中企动力科右中旗网站建设
  • 南京网站设计案例网站设计形式
  • 网站建设流程文字稿公共资源交易中心网
  • 台州外贸网站报纸改版方案
  • 导购网站怎么做佛山网站建设thual
  • 要建网站怎么做静安区网站开发
  • 好的网站怎么建设注册电商平台需要什么手续
  • 湖州网站网站建设网站建设用什么技术
  • 网站开发文件上传到服务器介绍一个做美食的网站
  • 公司国外网站建设做网站哪个平台好
  • 网站开发程序介绍石家庄网站建设成功案例
  • 如何登录网站服务器dedecms5.7装饰公司网站模板