当前位置:网站首页>[torch] the most concise logging User Guide
[torch] the most concise logging User Guide
2022-07-02 07:21:00 【lwgkzl】
Most of the online tutorials are very complex , Actually use logging It's simple , Just three lines of code
I use logging For the convenience of debugging , Because the number of output box caches is limited , If you print the output into a file and observe the use experience, it will be much better , Because the function of these three lines of code is to export the output to a file
The configuration code is as follows :
import logging
logging.basicConfig(level=logging.INFO, filename='./mylog/test.log', filemode='w')Here we first quote logging My bag , And then configure it logging Basic configuration
filename Indicates the location of the output file , Note that here he cannot create a new folder , It means... Here 'mylog' You need to create this directory first .
filemode='w' Indicates the mode of modifying the file , This means that every time you run the file, you write the file again, overwriting the content written in the last run , For more file reading and writing modes, please refer to : Read write mode
So that's configured , Then basically use it like print equally :
logging.info('aaaa')If you want to output variables : Use ‘f’ Operator :
aa = 1
logging.info(f'aa: {aa}')Just enclose the variables to be output with curly braces , Finally, these outputs are stored in mylog The folder test.log In file . f Please refer to :https://blog.csdn.net/lwgkzl/article/details/107695293
above
边栏推荐
- allennlp 中的TypeError: Object of type Tensor is not JSON serializable错误
- pySpark构建临时表报错
- 矩阵的Jordan分解实例
- TCP attack
- SSM supermarket order management system
- Principle analysis of spark
- DNS attack details
- Illustration of etcd access in kubernetes
- Oracle 11g uses ords+pljson to implement JSON_ Table effect
- PHP uses the method of collecting to insert a value into the specified position in the array
猜你喜欢

Sqli Labs clearance summary - page 2

2021-07-05c /cad secondary development create arc (4)

Yolov5 practice: teach object detection by hand

SSM学生成绩信息管理系统

【模型蒸馏】TinyBERT: Distilling BERT for Natural Language Understanding

oracle apex ajax process + dy 校验

ERNIE1.0 与 ERNIE2.0 论文解读

Changes in foreign currency bookkeeping and revaluation general ledger balance table (Part 2)

Oracle apex Ajax process + dy verification

使用MAME32K进行联机游戏
随机推荐
Sparksql data skew
IDEA2020中PySpark的两表关联(字段名相同)
2021-07-17c /cad secondary development creation circle (5)
【信息检索导论】第二章 词项词典与倒排记录表
The boss said: whoever wants to use double to define the amount of goods, just pack up and go
Laravel8中的find_in_set、upsert的使用方法
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
Take you to master the formatter of visual studio code
架构设计三原则
Build FRP for intranet penetration
腾讯机试题
ORACLE APEX 21.2安装及一键部署
JSP智能小区物业管理系统
oracle-外币记账时总账余额表gl_balance变化(上)
Agile development of software development pattern (scrum)
【信息检索导论】第六章 词项权重及向量空间模型
Data warehouse model fact table model design
Cognitive science popularization of middle-aged people
第一个快应用(quickapp)demo
oracle apex ajax process + dy 校验