当前位置:网站首页>How to standardize the creation of a pytorch project

How to standardize the creation of a pytorch project

2022-06-12 07:53:00 Wait for Godot.

A good Pytorch The project shall include the following specifications :

Definition PyTorch Software engineering specification of the project , contain :

  • Code directory for training tests / Document specification ;
  • Configuration specification ;

Code directory for training tests / Document specification

Fit every deepvac canonical PyTorch Model training program , Include the following directories and files :

Catalog / file explain Whether must
README.md Project description 、git Number of branches and their introduction 、 Description of the storage path of the original data yes
train.py Model training and validation documentation , Inherit DeepvacTrain Class extension implementation yes
test.py Model test file , Inherit Deepvac Class extension implementation yes
config.py Project overall configuration file yes
modules/model.py Model definition file ,PyTorch Module Class extension implementation In the case of a single model , yes
modules/model_{name}.py ditto , There are many. model When , Use suffix distinguish In the case of multiple models , yes
modules/loss.pyloss Realization . If the implementation is lightweight , It can be placed directly in modules/model.py in no
modules/utils.py Tool class / Method definition file no
modules/utils_{name}.py ditto , There are multiple tool classes / Function file , Use suffix distinguish no
synthesis/synthesis.py Data synthesis or cleaning code no
synthesis/config.pysynthesis.py Configuration file for no
data/dataloader.pydataset Class no
data/train.txt Training set manifest file no
data/val.txt Validation set manifest file no
aug/aug.py Data enhanced code . If the implementation is lightweight , It can be placed directly in dataset Class no
aug/config.pyaug.py Configuration file for no
log/*.log Log output directory yes
output/model__*.pth Export or import model file Default Deepvac Output
output/checkpoint__*.pth Output or input checkpoint file Default Deepvac Output

These files cover a PyTorch The whole life cycle of model training :

  • Raw data , stay README.md Description in ;
  • Data cleaning / synthesis , stay synthesis/synthesis.py In the definition of ;
  • Data to enhance , stay aug/aug.py In the definition of ( Light weight can be achieved in dataset Definition in class );
  • data input , stay data/dataloader.py In the definition of ;
  • model training , stay train.py In the definition of ;
  • Model validation , stay train.py In the definition of ;
  • Model test , stay test.py In the definition of ;
  • Model output , stay output To store in a directory ;
  • Log output , stay log To store in a directory ;

Configuration specification

  • config.py Is a first-class citizen in the norms ;
  • The configuration of user interface level is in config.py in ;
  • The configurations defined by internal development are all in the class auditConfig In the method , And can be config.py The values in override ;
  • When starting distributed training , because –rank and –gpu The parameter is process level , from argparse.ArgumentParser Module to pass , The user needs to specify... On the command line ;
  • The input parameters of the constructor of a class are generally config example ;
  • Again ,config.py Be a first-class citizen in the norm .

Excerpt from :DeepVac

原网站

版权声明
本文为[Wait for Godot.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203010554184295.html