随笔分类 -  Python

摘要:Pytorch在保存模型时,会把训练过程中使用的设备号(GPU:0, CPU等)也一起保存下来,当load保存的模型时,会默认把权重加载到训练时使用的设备上,要修改加载到的卡号可以如下: torch.load('your_model.pth', map_location=lambda storage 阅读全文
posted @ 2022-02-19 12:51 sqdtss 阅读(351) 评论(0) 推荐(0) 编辑
摘要:在logging.info()之前添加一行代码:logging.getLogger().setLevel(logging.INFO) 阅读全文
posted @ 2021-03-31 15:20 sqdtss 阅读(2898) 评论(0) 推荐(0) 编辑
摘要:1 import tensorflow as tf 2 from sklearn import datasets 3 import numpy as np 4 5 # 数据集导入 6 x_train = datasets.load_iris().data 7 y_train = datasets.l 阅读全文
posted @ 2020-04-12 14:25 sqdtss 阅读(432) 评论(0) 推荐(0) 编辑
摘要:1 import tensorflow as tf 2 import matplotlib.pyplot as plt 3 import numpy as np 4 5 # 导入数据 6 mnist = np.load('mnist.npz') 7 x_train, y_train = mnist[ 阅读全文
posted @ 2020-04-12 14:24 sqdtss 阅读(367) 评论(0) 推荐(0) 编辑
摘要:1 import tensorflow as tf 2 import numpy as np 3 from tensorflow.keras.utils import to_categorical 4 5 # 导入数据 6 mnist = np.load('mnist.npz') 7 x_train 阅读全文
posted @ 2020-04-12 14:23 sqdtss 阅读(229) 评论(0) 推荐(0) 编辑
摘要:https://cloud.tencent.com/developer/labs/lab/10372 阅读全文
posted @ 2018-09-07 14:38 sqdtss 阅读(88) 评论(0) 推荐(0) 编辑
摘要:settings.py 中进行设置 设置static文件目录 STATIC_ROOT = os.path.join(BASE_DIR, 'static').replace('\\','/') 运行命令python manage.py collectstatic 就可以将admin所需要的静态文件拷贝 阅读全文
posted @ 2018-08-16 12:50 sqdtss 阅读(265) 评论(0) 推荐(0) 编辑
摘要:首先看效果: 输入Hello, 可见输出 int. 打招呼 下面看源码: 阅读全文
posted @ 2018-08-07 20:46 sqdtss 阅读(182) 评论(0) 推荐(0) 编辑
摘要:组件属性,用法 组件位置 更多 阅读全文
posted @ 2018-08-07 20:39 sqdtss 阅读(79) 评论(0) 推荐(0) 编辑
摘要:1.shutil模块 import shutil shutil.make_archive('shutil_archive_test', 'zip', 'D:\pyworkspace\.idea') make_archive函数第一项为压缩成的文件名,第二项为压缩格式,第三项为压缩的目录 shutil.copytree(src, dst, symlinks=False, ignore=None) ... 阅读全文
posted @ 2018-08-07 20:37 sqdtss 阅读(92) 评论(0) 推荐(0) 编辑
摘要:1. class A: def __init__(self, a, b): self.a = a self.b = b print(a, b) class B(A): def __init__(self, aa, bb): 此处最好写成 a,b因为self.a=a 父类是如此,子类亦应如此... 阅读全文
posted @ 2018-08-07 20:36 sqdtss 阅读(110) 评论(0) 推荐(0) 编辑
摘要:from PIL import Image from PIL import ImageDraw from PIL import ImageFont import random class ValidCodeImg: """ 可以生成一个经过降噪后的随机验证码的图片 :param width: 图片宽 阅读全文
posted @ 2018-08-07 20:33 sqdtss 阅读(138) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示