## YACS
### Introduction
YACS was created as a lightweight library to define and manage
system configurations, such as those commonly found in software
designed for scientific experimentation. These "configurations"
typically cover concepts like hyperparameters used in training a
machine learning model or configurable model hyperparameters, such
as the depth of a convolutional neural network. Since you're doing
science, **reproducibility is paramount** and thus you need a reliable
way to serialize experimental configurations. YACS
uses YAML as a simple, human readable serialization format.
The paradigm is: `your code + a YACS config for experiment E (+
external dependencies + hardware + other nuisance terms ...) =
reproducible experiment E`. While you might not be able to control
everything, at least you can control your code and your experimental
configuration. YACS is here to help you with that.
YACS grew out of the experimental configuration systems used in:
[py-faster-rcnn](https://github.com/rbgirshick/py-faster-rcnn) and
[Detectron](https://github.com/facebookresearch/Detectron).
### Usage
YACS can be used in a variety of flexible ways. There are two main
paradigms:
- Configuration as *local variable*
- Configuration as a *global singleton*
It's up to you which you prefer to use, though the local variable
route is recommended.
To use YACS in your project, you first create a project config
file, typically called `config.py` or `defaults.py`. *This file
is the one-stop reference point for all configurable options.
It should be very well documented and provide sensible defaults
for all options.*
```python
# my_project/config.py
from yacs.config import CfgNode as CN
_C = CN()
_C.SYSTEM = CN()
# Number of GPUS to use in the experiment
_C.SYSTEM.NUM_GPUS = 8
# Number of workers for doing things
_C.SYSTEM.NUM_WORKERS = 4
_C.TRAIN = CN()
# A very important hyperparameter
_C.TRAIN.HYPERPARAMETER_1 = 0.1
# The all important scales for the stuff
_C.TRAIN.SCALES = (2, 4, 8, 16)
def get_cfg_defaults():
"""Get a yacs CfgNode object with default values for my_project."""
# Return a clone so that the defaults will not be altered
# This is for the "local variable" use pattern
return _C.clone()
# Alternatively, provide a way to import the defaults as
# a global singleton:
# cfg = _C # users can `from config import cfg`
```
Next, you'll create YAML configuration files; typically you'll make
one for each experiment. Each configuration file only overrides the
options that are changing in that experiment.
```yaml
# my_project/experiment.yaml
SYSTEM:
NUM_GPUS: 2
TRAIN:
SCALES: (1, 2)
```
Finally, you'll have your actual project code that uses the config
system. After any initial setup it's a good idea to freeze it to
prevent further modification by calling the `freeze()` method. As
illustrated below, the config options can either be used a global
set of options by importing `cfg` and accessing it directly, or
the `cfg` can be copied and passed as an argument.
```python
# my_project/main.py
import my_project
from config import get_cfg_defaults # local variable usage pattern, or:
# from config import cfg # global singleton usage pattern
if __name__ == "__main__":
cfg = get_cfg_defaults()
cfg.merge_from_file("experiment.yaml")
cfg.freeze()
print(cfg)
# Example of using the cfg as global access to options
if cfg.SYSTEM.NUM_GPUS > 0:
my_project.setup_multi_gpu_support()
model = my_project.create_model(cfg)
```
#### Command line overrides
You can update a `CfgNode` using a list of fully-qualified key, value pairs.
This makes it easy to consume override options from the command line. For example:
```python
cfg.merge_from_file("experiment.yaml")
# Now override from a list (opts could come from the command line)
opts = ["SYSTEM.NUM_GPUS", 8, "TRAIN.SCALES", "(1, 2, 3, 4)"]
cfg.merge_from_list(opts)
```
The following principle is recommended: "There is only one way to
configure the same thing." This principle means that if an option
is defined in a YACS config object, then your program should set
that configuration option using `cfg.merge_from_list(opts)` and
not by defining, for example, `--train-scales` as a command line
argument that is then used to set `cfg.TRAIN.SCALES`.
#### Python config files (instead of YAML)
`yacs>= 0.1.4` supports loading `CfgNode` objects from Python source files. The
convention is that the Python source must export a module variable named `cfg` of
type `dict` or `CfgNode`. See examples using a [CfgNode](example/config_override.py)
and a [dict](example/config_override_from_dict.py) as well as usage in the unit tests.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源说明】 1、该资源内项目代码都是经过测试运行成功,功能正常的情况下才上传的,请放心下载使用。 2、适用人群:主要针对计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、数学、电子信息等)的同学或企业员工下载使用,具有较高的学习借鉴价值。 3、不仅适合小白学习实战练习,也可作为大作业、课程设计、毕设项目、初期项目立项演示等,欢迎下载,互相学习,共同进步!
资源推荐
资源详情
资源评论
收起资源包目录
2020华为DIGIX全球校园AI算法精英大赛计算机视觉赛道第三名解决方案(完整源码+学习说明).zip (508个子文件)
.flake8 247B
.gitignore 237B
.gitignore 226B
1025.iml 606B
fuxian114.iml 568B
magic_base.iml 568B
╟╨╕ε.iml 492B
qiege.iml 436B
tox.ini 144B
LICENSE 10KB
README.md 5KB
README.md 3KB
README.md 2KB
CONTRIBUTING.md 906B
README.md 365B
NOTICE 1KB
digix全球校园ai算法精英大赛决赛答辩-数码设备图像检索-TIME.pptx 19.49MB
make_model_101.py 76KB
make_model_peng.py 74KB
make_model.py 62KB
resnest.py 23KB
resnest.py 22KB
make_model_fpn.py 22KB
make_model2.py 21KB
processor.py 20KB
config.py 19KB
resnest.py 17KB
regnet.py 17KB
metrics.py 17KB
regnet.py 17KB
resnet_bdb.py 15KB
post_process.py 15KB
resnet.py 14KB
swa.py 14KB
inception.py 14KB
make_model_.py 13KB
post_process.py 13KB
osnet_ain.py 13KB
osnet_ain.py 13KB
metrics.py 13KB
osnet.py 13KB
osnet.py 13KB
utils.py 12KB
veri.py 12KB
processor.py 12KB
weakly_supervised_crop_aug.py 11KB
model.py 11KB
make_dataloader.py 11KB
make_model_local.py 11KB
veri.py 10KB
resnet_ibn_a.py 10KB
resnet_ibn_a.py 10KB
make_model_p.py 10KB
tests.py 10KB
baseline.py 10KB
config.py 10KB
config.py 10KB
res2net.py 9KB
densenet_ibn.py 9KB
make_model_layer4.py 9KB
fmix.py 9KB
triplet_loss.py 8KB
resnet_ibn_a.py 8KB
reid_eval.py 8KB
resnet.py 8KB
re_ranking_faster_multivpu.py 8KB
triplet_loss.py 8KB
res2net.py 8KB
res2net.py 8KB
batch_norm.py 8KB
densenet.py 8KB
reranking.py 8KB
transforms.py 8KB
re_ranking_fastest.py 8KB
re_ranking_faster.py 8KB
re_ranking_faster_.py 8KB
reranking.py 8KB
train.py 8KB
resnext_ibn_a.py 7KB
densenet.py 7KB
my_rerank.py 7KB
se_resnet_ibn_a.py 7KB
se_resnet_ibn_a.py 7KB
train.py 7KB
defaults.py 7KB
veri.py 7KB
ranger.py 7KB
ranger.py 7KB
resnext_ibn_a.py 7KB
metric_learning.py 7KB
resnext_ibn_a.py 7KB
bases.py 7KB
train_net.py 7KB
defaults.py 7KB
defaults.py 7KB
resnet_ibn_b.py 6KB
triplet_loss.py 6KB
aicity20_ReOri.py 6KB
aicity20_ReColor.py 6KB
aic_querymining.py 6KB
共 508 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
龙年行大运
- 粉丝: 1222
- 资源: 3825
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功