摘要: import torch x = torch.randint(1,24, (2,3,4)) print(x) x = x.permute(2, 0, 1) print(x) 结果: 前: ([[[15, 23, 21, 14], [ 2, 15, 7, 14], [21, 8, 8, 22]], [ 阅读全文
posted @ 2021-04-26 10:15 id_ning 阅读(892) 评论(0) 推荐(0) 编辑
摘要: import torch a = torch.arange(2 * 3).view(2, 3) a_sum = torch.sum(a, 0) b = torch.arange(2 * 3 * 4).view(2, 3, 4) b_sum = torch.sum(b, (2, 1)) # 相当于b_ 阅读全文
posted @ 2021-04-26 09:46 id_ning 阅读(214) 评论(0) 推荐(0) 编辑
摘要: import torch x = torch.randint(2, 3) x1 = torch.cat((x, x), 0) x2 = torch.cat((x, x), 1) print(x) print(x1) print(x2) 结果: x:([[1, 4, 5], [4, 3, 1]]) x 阅读全文
posted @ 2021-04-25 14:59 id_ning 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 官方链接:https://pytorch.org/docs/stable/generated/torch.nn.GRU.html?highlight=gru#torch.nn.GRU 阅读全文
posted @ 2021-04-25 11:42 id_ning 阅读(1660) 评论(0) 推荐(0) 编辑
摘要: 哈达玛积(Hadamard product)是矩阵的一类运算,若A=(aij)和B=(bij)是两个同阶矩阵,若cij=aij×bij,则称矩阵C=(cij)为A和B的哈达玛积,或称基本积[1]。 [1] 数学辞海编辑委员会.数学辞海第二卷:中国科学技术出版社,2002 参考:https://bai 阅读全文
posted @ 2021-04-25 11:29 id_ning 阅读(188) 评论(0) 推荐(0) 编辑
摘要: class torch.nn.Conv1d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True) in_channels(int) :输入信号的通道。在文本分类中,即 阅读全文
posted @ 2021-04-23 11:13 id_ning 阅读(2013) 评论(0) 推荐(0) 编辑
摘要: torch.randn()返回一个张量,包含了从标准正态分布(均值为0,方差为1,即高斯白噪声)中抽取的一组随机数。张量的形状由参数size定义。 import torch import numpy as np a = np.array(torch.randn(1000, 1000)) print( 阅读全文
posted @ 2021-04-22 14:57 id_ning 阅读(1613) 评论(0) 推荐(0) 编辑
摘要: import numpy as np a = [1, 0, -1] a_mean = np.mean(a) a_var = np.var(a) a_std = np.std(a) print('a_mean: ', a_mean) print('a_var:', a_var) print('a_st 阅读全文
posted @ 2021-04-22 10:06 id_ning 阅读(1349) 评论(0) 推荐(0) 编辑
摘要: 版权声明:本文为CSDN博主「七月听雪」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。原文链接:https://blog.csdn.net/qq_23262411/article/details/100175943 import torch import torc 阅读全文
posted @ 2021-04-21 17:17 id_ning 阅读(2998) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/weixin_43250623/article/details/89197488?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLe 阅读全文
posted @ 2021-04-21 10:36 id_ning 阅读(143) 评论(0) 推荐(0) 编辑