![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
essenge
顺势而为
展开
-
Early stopping
import numpy as npimport torchclass EarlyStopping: """Early stops the training if validation loss doesn't improve after a given patience.""" def __init__(self, patience=7, verbose=False, delta=0, path='checkpoint.pt'): """ Args:原创 2020-06-12 14:25:33 · 262 阅读 · 0 评论 -
Logger
import loggingimport sys# 获取logger实例,如果参数为空则返回root loggerlogger = logging.getLogger("AppName")# 指定logger输出格式formatter = logging.Formatter(‘%(asctime)s %(levelname)-8s: %(message)s‘)# 文件日志file_handler = logging.FileHandler("test.log")file_handler原创 2020-06-10 22:12:47 · 137 阅读 · 0 评论 -
爬取中国寺庙祠观造像数据库代码
# 导入re正则库,用于正则匹配像主名和像主idimport re# 导入requests库,用于图片抓取和页面访问import requests# lxml库用于解析html页面from lxml import etree# 导入os库用于创建文件夹,以及保存图片import os# 伪造通讯协议头headers = { 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Cache-Control': 'no-原创 2020-11-19 21:12:09 · 704 阅读 · 0 评论 -
批量爬取某网站照片1
# !/usr/bin/env python # -*- coding:utf-8 -*-''''''import requestsfrom bs4 import BeautifulSoupheaders = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'}.原创 2020-11-18 22:57:22 · 107 阅读 · 0 评论