05 2021 档案
摘要:#复制文件: shutil.copyfile("oldfile","newfile") #oldfile和newfile都只能是文件 shutil.copy("oldfile","newfile") #oldfile只能是文件,newfile可以是文件,也可以是目标目录 #复制文件夹: shutil
阅读全文
摘要:# 加载数据成字典(读) with open(annotations_file, "r") as fa: annotations = json.load(fa) # 上载数据成序列(写) with open("annotation/train_annotation.json", 'w') as fp
阅读全文
摘要:举例说明: 1. 对于列表,字典的解包 # *取列表,元组元素 ls = [1, 2, 3, 4] print(*ls) # **取字典值 dic = {"key1": 1, "key2": 2} print('{key1}, {key2}'.format(**dic)) [注意]:使用**解包时必
阅读全文
摘要:1. 随机选择 使用random包 从列表里随机选出一个元素 from random import choice ls = [1, 2, 3, 4] print(choice(ls)) 2. 随机抽样 从列表里随机抽出出一组元素,不放回抽样 import random ls = [1, 2, 3,
阅读全文
摘要:原文链接:https://www.runoob.com/python/att-string-format.html
阅读全文
摘要:1..data() 将变量(Variable)变为tensor,将requires_grad设置为Flase a = torch.tensor([1.0], requires_grad=True) b = a.data print(b, b.requires_grad) ## 输出为: tensor
阅读全文
摘要:
阅读全文
摘要:解决方法 angle = torch.where(torch.isnan(angle), torch.full_like(angle, 0), angle) print(torch.any(torch.isnan(angle))) torch.where(condition, x, y) 参数1;判
阅读全文
摘要:####1. BN层 torch.nn.BatchNorm1d(num_features, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) 输入:, 对应nu
阅读全文
摘要:一、 函数解释 clone() 返回一个新的tensor,这个tensor与原始tensor的数据不共享一个内存(也就是说, 两者不是同一个数据,修改一个另一个不会变)。 requires_grad属性与原始tensor相同,若requires_grad=True,计算梯度,但不会保留梯度,梯度会与
阅读全文