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

企业网站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://www.15wanjia.com/news/28033.html

相关文章:

  • 网页设计网站建设专业现状seo门户
  • 南宁网红景点百度seo快速排名
  • php网站开发设计系统长春最新发布信息
  • 中国建设银行网站登录不了湘潭网站设计
  • 表格制作手机软件seo优化方案报价
  • 太原做网站的公司网站建设站长工具排名分析
  • 成都网站设计公司德阳seo
  • 网站运营和管理网络销售是什么
  • 有口碑的武进网站建设重庆森林经典台词 凤梨罐头
  • 政府网站整改建设郑州网络营销
  • 网站开发需要那些技术人员热门搜索关键词
  • 安徽专业做网站的大公司代发推广百度首页包收录
  • 秦皇岛手机网站制作价格北京全网推广
  • 购物类网站建设方案怎么上百度搜索
  • 网站建设(中企动力)网站优化哪家好
  • 深圳宝安网站建设工百度网站免费优化软件下载
  • 优秀门户网站欣赏营销方案范文100例
  • 网站 设计 深圳去哪里推广软件效果好
  • 临淄招聘信息最新招聘信息seo全称是什么
  • 石家庄做网站的公司seo的排名机制
  • 网站蜘蛛来访记录百度免费推广怎么做
  • 百竞网站建设找个免费网站这么难吗
  • 荆门住房建设厅网站南宁哪里有seo推广厂家
  • 桥头网站仿做网络营销的用户创造价值
  • 长沙网站制作多少钱新闻头条新闻
  • 深圳排名前十的跨境电商公司seo快速排名
  • 线上做汉语教师网站合肥网站制作
  • 百度建设公司网站东莞整站优化
  • 什么叫利用网站做蜘蛛池sem是什么的缩写
  • 深圳制作网站专业国际国内新闻最新消息今天