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

php网站中水印怎么做网站google搜索优化

php网站中水印怎么做,网站google搜索优化,十大接单网站,j2ee网站开发参考文献由于我只简单的学过python和pytorch,其中有很多函数的操作都还是一知半解的,其中有些函数经常见到,所以就打算记录下来。 1.zip zip(*a):针对单个可迭代对象压缩成n个元组,元组数量n等于min(a中元素的最小长度) a [(1, 2), (3…

由于我只简单的学过python和pytorch,其中有很多函数的操作都还是一知半解的,其中有些函数经常见到,所以就打算记录下来。

1.zip

zip(*a):针对单个可迭代对象压缩成n个元组,元组数量n等于min(a中元素的最小长度)

a = [(1, 2), (3, 4), (5, 6)]
c, d = zip(*a)
print(c, d)
# (1, 3, 5) (2, 4, 6)

2.view, arange和range

import torch
# torch.arange(1, 3) =[1,3)   前闭后开
# torch.range(1, 3) =[1,3]    前闭后闭
e = torch.arange(1, 3)
e1 = torch.range(1, 3)
e, e1  # (tensor([1, 2]), tensor([1., 2., 3.]))

view的作用就是用来组织Tensor的形状,

import torch
e = torch.arange(1, 19).view(2, 3, 3)
e1 = torch.range(1, 18).view(2, 3, 3)
e,e1,e==e1

输出结果如下
在这里插入图片描述

3.torch.transpose 用来交换维度(重新组织维度)

torch.Size([1, 3, 2])–>transpose(0,1)后 torch.Size变为([3,1,2])
有两种写法 ① b.transpose(0, 1) ② torch.transpose(b, 0, 1),我觉得都可以使用

import torch
#https://pytorch.org/docs/stable/generated/torch.transpose.html#torch.transpose
b = torch.Tensor([[[0, 1], [2, 3], [4, 5]]])
print(b.shape)
print('----------')
b=b.transpose(0, 1)
print(b.shape)
print('----------')
c = torch.transpose(b, 0, 1)
print(c.shape)
# print(b)
# print(c)

在这里插入图片描述

4.torch.cat

torch.cat()是为了把多个tensor进行拼接而存在的(这里仅仅用了相同的元素)

# 3.torch.cat
# dim(整数,可选)– 张量被控制的维度
# m 默认为0  代表在竖向的方向上添加
# [c,
#  c,
#  c]
# m为1代表在横向的方向上添加[c,c,c]
c = torch.Tensor([[0, 1], [2, 3], [4, 5]])
# print(c)
print(c.shape)
print('--------------')
c1 = torch.cat((c, c, c), dim=0)  
# print(c1)
print(c1.shape)
print('--------------')
c2 = torch.cat((c, c), dim=1)  #  [c,c]
# print(c2)
print(c2.shape)
# print(c2.shape[1])

5.数组操作

这部分的操作比较复杂,有的三维数组的操作,就像这样的[:::],大家可以自己复制尝试一下,查看输出

# 4.数组操作
#  enc_hidden[-2,:,:], enc_hidden[-1,:,:]
d = torch.Tensor([[[1, 2, 3], [4, 5, 6], [7, 8, 9]],[[10, 11, 12], [13, 14, 15], [16, 17, 18]]])
print(d.size())  # torch.Size([2, 3, 3])
print(d)
# tensor([[[ 1.,  2.,  3.],
#          [ 4.,  5.,  6.],
#          [ 7.,  8.,  9.]],
#
#         [[10., 11., 12.],
#          [13., 14., 15.],
#          [16., 17., 18.]]])
print('------1---------')
print(d[-1, :, :])print('------2--------')
print(d[:, -1, :])print('------3--------')
print(d[:, :, -1])print('------4--------')
print(d[:, :, -2])print('------5--------')
print(d[-1])
print(d[:, :, -1])
print(d[-1, :, :])
print(d[:, -1, :])

6.squeeze()和unsqueeze()

squeeze在的中文意思压缩,unsqueeze取消压缩,unsqueeze是添加维度的意思

特别的,当unsqueeze()里面参数是0 的时候,该矩阵由(3,4)变成是(3,4,1)

e = torch.arange(1, 19).view(2, 3, 3)
print(e)
print(e.shape)
print('-----unsqueeze:就是在某个位置增加一个维度-------')
ee = e.unsqueeze(3)
print(ee)
print(ee.shape)

在这里插入图片描述在这里插入图片描述

# 5.squeeze()和unsqueeze()
#   squeeze在的中文意思压缩,就是降低维度,squeeze()函数只能压缩维度为1的矩阵
#  当unsqueeze()里面参数是0 的时候,该矩阵由(3,4)变成是(3,4,1)
# 对形如(2, 3, 3)的矩阵squeeze不起作用,但不会报错
e = torch.arange(1, 19).view(2, 3, 3)
print(e)
print(e.shape)
print('-----squeeze:就是在某个位置降低一个维度-------')
eee = e.squeeze(0)
print(eee)
print(eee.shape)

在这里插入图片描述

7.torch.bmm 计算两个tensor的矩阵乘法

torch.bmm(input, mat2, *, out=None)
input and mat2 must be 3-D tensors each containing the same number of matrices.

If input is a (b×n×m) tensor, mat2 is a (b×m×p) tensor, out will be a (b×n×p) tensor.

两个tensor的第一维是相等的,然后第一个数组的第三维和第二个数组的第二维度要求一样,对于剩下的则不做要求,输出维度

import torchg1 = torch.arange(1, 7).view(1, 2, 3)
print(g1.shape)
print(g1)
g2 = torch.arange(1, 10).view(1, 3, 3)
print(g2)
print('-------')torch.bmm(g1, g2)

在这里插入图片描述

8.torch.exp(x) 计算e(2.7)的x次方

分别计算e^0(e的0次方), e的1次方,e的log(2)次方

import matha = torch.tensor([0, 1, math.log(2)])
print(torch.exp(a))

在这里插入图片描述

9.torch.max

求最大值

a = torch.randn(4, 4)
print(a)
print(torch.max(a, dim=1))
print('----------')
print(torch.max(a, dim=1, keepdim=True))

在这里插入图片描述

http://www.yayakq.cn/news/292300/

相关文章:

  • 制作网站用什么代码市场监督管理局职责
  • 七台河新闻头条潍坊网站排名优化
  • 网上销售有哪些方法seo优化专员工作内容
  • 淮南建设公司网站昆明网站建设系统有哪些
  • wordpress网站迁移教程猪八戒网仿照哪个网站做的
  • 嘉兴做网站公司哪家好工业产品设计图
  • wordpress 仿站 教程山西住房城乡建设部网站
  • 15.下面对网站结构描述正确的是( )公司网站模板 免费
  • 湛江网站建站建设程序界面设计
  • 类似一起做网站的网站大学个人网站期末作业
  • seo和网站建设那个先学做淘宝客需要自己建网站吗
  • 泉州企业网站制作定制做网站的客户哪里找
  • 桥梁建设设计网站wordpress md风格
  • 手机网站管理工具黑龙江省建设集团网站
  • 网站排名提升软件99国精产品灬源码的优势
  • 天河做网站哪家强wordpress插图插件
  • 成都工业学院文献检索在哪个网站做零基础 网站
  • 做IT的需要别人打开网站吗兰州新增94个高风险区
  • 帮助做ppt的网站四川建设厅官方网站九大员通知
  • 文化网站建设心得wordpress分类信息导航
  • 湖北省城建设计院网站网站数据分析报表
  • ppt的网站导航栏怎么做wordpress实现登录注册
  • 永兴网站制作成品网站超市源码
  • 广州正规网站建设公司方便做流程图的网站
  • 网站策划包括什么动态静态结合网站
  • 专做韩餐网站新闻类网站开发多久
  • 怎么样查看网站开发语言天津网站建设制作免费
  • 有没有做任务的网站吗05网补充答案全部
  • 如何在记事本中做网站链接php做视频分享网站
  • php做电商网站项目管理咨询公司