05 2021 档案

摘要:#复制文件: shutil.copyfile("oldfile","newfile") #oldfile和newfile都只能是文件 shutil.copy("oldfile","newfile") #oldfile只能是文件,newfile可以是文件,也可以是目标目录 #复制文件夹: shutil 阅读全文
posted @ 2021-05-28 14:29 Guang'Jun 阅读(156) 评论(0) 推荐(0) 编辑
摘要:# 加载数据成字典(读) with open(annotations_file, "r") as fa: annotations = json.load(fa) # 上载数据成序列(写) with open("annotation/train_annotation.json", 'w') as fp 阅读全文
posted @ 2021-05-28 10:58 Guang'Jun 阅读(38) 评论(0) 推荐(0) 编辑
摘要:举例说明: 1. 对于列表,字典的解包 # *取列表,元组元素 ls = [1, 2, 3, 4] print(*ls) # **取字典值 dic = {"key1": 1, "key2": 2} print('{key1}, {key2}'.format(**dic)) [注意]:使用**解包时必 阅读全文
posted @ 2021-05-26 10:37 Guang'Jun 阅读(132) 评论(0) 推荐(0) 编辑
摘要:1. 随机选择 使用random包 从列表里随机选出一个元素 from random import choice ls = [1, 2, 3, 4] print(choice(ls)) 2. 随机抽样 从列表里随机抽出出一组元素,不放回抽样 import random ls = [1, 2, 3, 阅读全文
posted @ 2021-05-25 12:41 Guang'Jun 阅读(142) 评论(0) 推荐(0) 编辑
摘要:原文链接:https://www.runoob.com/python/att-string-format.html 阅读全文
posted @ 2021-05-15 13:30 Guang'Jun 阅读(36) 评论(0) 推荐(0) 编辑
摘要:1..data() 将变量(Variable)变为tensor,将requires_grad设置为Flase a = torch.tensor([1.0], requires_grad=True) b = a.data print(b, b.requires_grad) ## 输出为: tensor 阅读全文
posted @ 2021-05-15 11:39 Guang'Jun 阅读(1057) 评论(0) 推荐(0) 编辑
摘要:![image](https://img2020.cnblogs.com/blog/2199011/202105/2199011-20210515111855809-369266290.png) 阅读全文
posted @ 2021-05-15 11:19 Guang'Jun 阅读(20) 评论(0) 推荐(0) 编辑
摘要:解决方法 angle = torch.where(torch.isnan(angle), torch.full_like(angle, 0), angle) print(torch.any(torch.isnan(angle))) torch.where(condition, x, y) 参数1;判 阅读全文
posted @ 2021-05-14 23:07 Guang'Jun 阅读(1642) 评论(0) 推荐(0) 编辑
摘要:####1. BN层 torch.nn.BatchNorm1d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) 输入:(N,C) or (N,C,L),  C对应nu 阅读全文
posted @ 2021-05-13 19:51 Guang'Jun 阅读(344) 评论(0) 推荐(0) 编辑
摘要:一、 函数解释 clone() 返回一个新的tensor,这个tensor与原始tensor的数据不共享一个内存(也就是说, 两者不是同一个数据,修改一个另一个不会变)。 requires_grad属性与原始tensor相同,若requires_grad=True,计算梯度,但不会保留梯度,梯度会与 阅读全文
posted @ 2021-05-01 00:20 Guang'Jun 阅读(1472) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示
主题色彩
主题色彩