当前位置:网站首页>DL deep learning experiment management script
DL deep learning experiment management script
2022-06-11 04:37:00 【Dabie Mountains】
Experiment management
A complete record of the experiment requires the following aspects :
- Log files : Log the whole operation process .
- Weight file : The weight file saved during operation , It is used for breakpoint continuation training and test to select the best experimental results ( Terminate training early ).
- TensorBoard file : Save the training process TensorBoard Visualizations , Visually observe the experimental results .
- The configuration file : The parameter adjustment process records the current running configuration in detail
- File backup code : The code used to save the current version , Easy rollback .
Code organization
exp
- The name of the experiment + date
- runs: tensorboard Saved files
- weights: Weight file
- config.yml: The configuration file
- scripts: Core file backup
- train.py
- xxxxx.py
Code implementation
import logging
import argparse
import yaml
parser = argparse.ArgumentParser("ResNet20-cifar100")
parser.add_argument('--batch_size', type=int, default=2048,
help='batch size') # 8192
parser.add_argument('--learning_rate', type=float,
default=0.1, help='init learning rate') parser.add_argument('--config', help="configuration file",
type=str, default="configs/meta.yml")
parser.add_argument('--save_dir', type=str,
help="save exp floder name", default="exp1")
args = parser.parse_args()
# process argparse & yaml
if args.config:
opt = vars(args)
args = yaml.load(open(args.config), Loader=yaml.FullLoader)
opt.update(args)
args = opt
else: # yaml priority is higher than args
opt = yaml.load(open(args.config), Loader=yaml.FullLoader)
opt.update(vars(args))
args = argparse.Namespace(**opt)
args.exp_name = args.save_dir + "_" + datetime.datetime.now().strftime("%mM_%dD_%HH") + "_" + \
"{:04d}".format(random.randint(0, 1000))
# Document processing
if not os.path.exists(os.path.join("exp", args.exp_name)):
os.makedirs(os.path.join("exp", args.exp_name))
# Log files
log_format = "%(asctime)s %(message)s"
logging.basicConfig(stream=sys.stdout, level=logging.INFO,
format=log_format, datefmt="%m/%d %I:%M:%S %p")
fh = logging.FileHandler(os.path.join("exp", args.exp_name, 'log.txt'))
fh.setFormatter(logging.Formatter(log_format))
logging.getLogger().addHandler(fh)
logging.info(args)
# The configuration file
with open(os.path.join("exp", args.exp_name, "config.yml"), "w") as f:
yaml.dump(args, f)
# Tensorboard file
writer = SummaryWriter("exp/%s/runs/%s-%05d" %
(args.exp_name, time.strftime("%m-%d", time.localtime()), random.randint(0, 100)))
# File backup
create_exp_dir(os.path.join("exp", args.exp_name),
scripts_to_save=glob.glob('*.py'))
def create_exp_dir(path, scripts_to_save=None):
if not os.path.exists(path):
os.mkdir(path)
print('Experiment dir : {}'.format(path))
if scripts_to_save is not None:
if not os.path.exists(os.path.join(path, 'scripts')):
os.mkdir(os.path.join(path, 'scripts'))
for script in scripts_to_save:
dst_file = os.path.join(path, 'scripts', os.path.basename(script))
shutil.copyfile(script, dst_file)
Deep learning project directory structure
├── config
│ └── defaults.py - here's the default config file.
│
│
├── configs
│ └── train_mnist_softmax.yml - here's the specific config file for specific model or dataset.
│
│
├── data
│ └── datasets - here's the datasets folder that is responsible for all data handling.
│ └── transforms - here's the data preprocess folder that is responsible for all data augmentation.
│ └── build.py - here's the file to make dataloader.
│ └── collate_batch.py - here's the file that is responsible for merges a list of samples to form a mini-batch.
│
│
├── engine
│ ├── trainer.py - this file contains the train loops.
│ └── inference.py - this file contains the inference process.
│
│
├── layers - this folder contains any customed layers of your project.
│ └── conv_layer.py
│
│
├── modeling - this folder contains any model of your project.
│ └── example_model.py
│
│
├── solver - this folder contains optimizer of your project.
│ └── build.py
│ └── lr_scheduler.py
│
│
├── tools - here's the train/test model of your project.
│ └── train_net.py - here's an example of train model that is responsible for the whole pipeline.
│
│
└── utils
│ ├── logger.py
│ └── any_other_utils_you_need
│
│
└── tests - this foler contains unit test of your project.
├── test_data_sampler.py
边栏推荐
- ACTS:如何让缺陷无处藏身?
- Game Mathematics: calculate the points on the plane in the screen points (God's perspective)
- Overview of guanghetong industrial 5g module product line
- Analysis of zero time technology | discover lightning loan attack
- PostgreSQL数据库复制——后台一等公民进程WalReceiver 收发逻辑
- Unity 高級背包系統
- MySQL index
- MySQL锁总结
- 图的最短路径问题 详细分解版
- Redis persistence (young people always set sail with a fast horse, with obstacles and long turns)
猜你喜欢

MySQL stored procedure

Check the digital tube with a multimeter

PHP话费充值通道网站完整运营源码/全解密无授权/对接免签约支付接口

Exness: liquidity series - order block, imbalance (II)

如何快速寻找STM32系列单片机官方例程

Unity Editor Extension save location

How the idea gradle project imports local jar packages

Unity 音乐播放管理器

Implementation of unity transport mechanism

Best practices and principles of lean product development system
随机推荐
福州核酸检测实验室建设须知事项探讨
What are the similarities and differences between the data center and the data warehouse?
强大新UI装逼神器微信小程序源码+多模板支持多种流量主模式
Programming Examples Using RDMA Verbs
MindManager22专业版思维导图工具
Carbon path first, Huawei digital energy injects new momentum into the green development of Guangxi
[cf571e] geometric progressions -- number theory and prime factor decomposition
Unity MonoSingleton
Vulkan official example interpretation shadows (rasterization)
The 4th small class discussion class on fundamentals of information and communication
Unity 音乐播放管理器
Split all words into single words and delete the product thesaurus suitable for the company
Unity 遮挡剔除
Data type conversion and conditional control statements
Implementation of unity transport mechanism
Legend has it that setting shader attributes with shader ID can improve efficiency:)
Unity 可缩放地图的制作
Emlog新版导航源码/带用户中心
USB转232 转TTL概述
Sorting out relevant programming contents of renderfeature of unity's URP