摘要: ###当tensor中只有一个值的时候 .item()返回一个数值,.data返回一个tensor 使用例: test = torch.Tensor(42) a = test.item() b = test.data print(f'a:{a}, b:{b}') #输出为:a:42, b:tenso 阅读全文
posted @ 2021-09-29 09:33 小艾衰 阅读(796) 评论(0) 推荐(0) 编辑
摘要: ###添加语句至 main 下 if __name__ == '__main__': __spec__ = "ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>)" 阅读全文
posted @ 2021-09-29 09:08 小艾衰 阅读(747) 评论(0) 推荐(0) 编辑
摘要: ##今日踩的坑 ####今天保存模型的时候报的这个错误 torch.save(model.state_dic(), 'epoch:{epoch},loss:{loss}.pkl') ####文件名违规 ####于是查了一下windows下的命名规则: 不能包含:< > / \ | : * ? 不超过 阅读全文
posted @ 2021-09-28 15:58 小艾衰 阅读(597) 评论(0) 推荐(0) 编辑
摘要: ###使用例 tup = ((1, 2), (3, 4), (5, 6)) a, b = zip(*tup) print(a, b) >>a:[1, 3, 5] >>b:[2, 4, 6] 阅读全文
posted @ 2021-09-28 10:14 小艾衰 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 设置断点: pdb.set_trace() 进入debug mode python -m pdb main.py --args debug mode下 (pbd)c #continue debug (pbd)step #next step (pbd)exit #exit pbd mode 阅读全文
posted @ 2021-09-28 09:00 小艾衰 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 设置为bool参数时 无法传送参数 使用 action='store_true' ###store_true 是指带触发action时为true,不触发则为false, store_false则相反 parser.add_argument("--trained", action='store_tru 阅读全文
posted @ 2021-09-27 09:49 小艾衰 阅读(314) 评论(0) 推荐(0) 编辑
摘要: pd.DataFrame({key, value}) 报错 pd.DataFrame({key, [value]}) DataFrame 传入字典序列的时候 value 值需要list化 即提供一个index 阅读全文
posted @ 2021-09-26 09:58 小艾衰 阅读(144) 评论(0) 推荐(0) 编辑
摘要: reset_index(inplace, drop) drop=True inplace=True 阅读全文
posted @ 2021-09-26 09:55 小艾衰 阅读(17) 评论(0) 推荐(0) 编辑
摘要: -*- coding: utf-8 -*- @ date 2021-9-14 from faker import Factory from faker import Faker # zh_CN 表示中国大陆版 # old version fake = Factory().create('zh_CN' 阅读全文
posted @ 2021-09-14 13:34 小艾衰 阅读(323) 评论(0) 推荐(0) 编辑
摘要: 建议更新1.0以后的版本 to_html() 增加encoding parameters 老版本会出现编码问题 对应的python版本建议大于3.6 阅读全文
posted @ 2021-09-01 09:37 小艾衰 阅读(723) 评论(0) 推荐(0) 编辑