Laozhongyi is a simple but effective automatic hyper-parameter tuning program based on grid search and simulated annealing.
# Why use Laozhongyi?
* There are lots of boring things in hyperparameter tuning, e.g., configuring a bunch of values for hyperparameters, naming a bunch of log files, launching a bunch of processes, comparing results among log files, etc. So manual operation is both time consuming and error prone.
* Some existed automatic hyperparameter tuning programs rely on Python, while Laozhongyi only relies on string parsing. Thus you can use laozhongyi with any programming language and any deep learning library.
# Getting started
We will illustrate how to use Laozhongyi in the following.
## An example of the tuning range's config file
```
lr,0.01,0.001,0.0001
dropout,0,0.1,0.2,0.3,0.4,0.5
batch_size,1,2,4,8,16,32,64
pretrained,/home/xxx/modelxxx
```
Each line is a hyperparameter name followed by a list of values to be tuned, separated by commas. In particular, if the parameter has only one value, it means a fixed value and will not be tuned.
## Requirements for your program to be tuned
* Your program should exit when it performs sufficiently well (e.g., the F1 value on the validation set has not improved for ten consecutive epochs). Otherwise, Laozhongyi will abort your program after it reaches the upper elapsed time limit, which will harm tuning efficiency.
* Your program should output the log to standard output (Laozhongyi will redirect the standard output to a corresponding log file). The log should contain strings such as laozhongyi_0.8, where 0.8 means the best performance on the validation set.
* Your program should parse the hyperparameter config file generated by Laozhongyi and take the path of the hyperparameter config file as the command line argument.
An example of the generated hyperparameter config file is as follows:
```
lr = 0.001
dropout = 0.1
batch_size = 64
pretrained = /home/xxx/modelxxx
```
## Run
This project is built with Java 8 and Maven, so you can run *mvn clean package* to generate the target folder, or download it from [releases](https://github.com/chncwang/laozhongyi/releases).
The command line arguments of Laozhongyi are listed as follows:
```
usage: laozhonghi
-c <arg> cmd
-rt <arg> program runtime upper bound in minutes
-s <arg> scope file path
-sar <arg> simulated annealing ratio
-sat <arg> simulated annealing initial temperature
-strategy <arg> base or sa
-wd <arg> working directory
```
* -c means your program's command line which should be quoted, e.g., "python3 train.py -train train.txt -dev dev.txt -test test.txt -hyper {}",where {} will be replaced with the hyperparameter config file's path by Laozhongyi.
* -rt means the upper limit of the running time of each process in minutes. For example, *-rt 20* means that if a process does not exit after 20 minutes, it will be aborted.
* -s means the path to the config file for the hyperparameter tuning range.
* -strategy means the search strategy, with *base* referring to the coordinate descent method, and *sa* referring to the simulated annealing method.
* -sar means the temperature's decay rate.
* -sat means the initial temperature.
A complete example is as follows:
```Bash
cd target
java -cp "*:lib/*" com.hljunlp.laozhongyi.Laozhongyi -s /home/wqs/laozhongyi.config\
-c "python3 train.py -train train.txt -dev dev.txt -test test.txt -hyper {}"\
-sar 0.9 -sat 1 -strategy sa -rt 5
```
We recommend you to use *screen* to run Laozhongyi.
When Laozhongyi starts, it will generate the log directory with the timestamp suffix and the hyperparameter config directory in the home directory.
# Features
## Process Management
* Laozhongyi supports multi-process hyperparameter-tuning, currently up to 8 processes.
* Your program should exit when performance is unlikely to improve any further, or it will be killed when reaching the elapsed time limit.
## Search Strategy
### Coordinate Descent
The coordinate descent method tries all the hyperparameters in a loop. For each hyperparameter, Laozhongyi tries all of its values and selects the one that performs best. The algorithm stops until the selected values of all the hyperparameters are no longer changed.
### Simulated Annealing
To alleviate the problem that the coordinate descent method is easy to converge to the local optimal solution, we introduce the strategy of simulated annealing.
# Question?
Email: chncwang@gmail.com
没有合适的资源?快使用搜索试试~ 我知道了~
一个基于网格搜索和模拟退火的自动超参数调优程序_java_代码_下载
共20个文件
java:16个
license:1个
md:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 4 浏览量
2022-06-21
11:35:25
上传
评论
收藏 21KB ZIP 举报
温馨提示
超参调优有很多无聊的事情,比如给超参配置一堆值,给一堆日志文件命名,启动一堆进程,比较日志文件的结果等等,所以手动操作既费时又出错易于。 现有的一些自动超参数调优程序依赖于 Python,而老中易只依赖于字符串解析。因此,您可以将老中易与任何编程语言和任何深度学习库一起使用。 特征 流程管理 老中易支持多进程超参调优,目前最多8个进程。 当性能不太可能进一步提高时,您的程序应该退出,或者在达到经过的时间限制时将被终止。 搜索策略 坐标下降 坐标下降法在一个循环中尝试所有超参数。对于每个超参数,老中易都会尝试其所有值并选择表现最佳的那个。算法停止,直到所有超参数的选定值不再更改。 模拟退火 为了缓解坐标下降法容易收敛到局部最优解的问题,我们引入了模拟退火策略。 更多详情、使用方法,请下载后阅读README.md文件
资源推荐
资源详情
资源评论
收起资源包目录
laozhongyi-master.zip (20个子文件)
laozhongyi-master
pom.xml 6KB
LICENSE 1KB
src
test
java
com
hljunlp
laozhongyi
strategy
StrategyTest.java 623B
main
java
com
hljunlp
laozhongyi
GeneratedFileManager.java 3KB
Laozhongyi.java 15KB
HyperParameterScopeConfigReader.java 1KB
process
ShellProcess.java 4KB
ParamsAndCallable.java 494B
ProcessManager.java 3KB
HyperParamResultManager.java 922B
HyperParameterScopeItem.java 624B
strategy
SimulatedAnnealingStrategy.java 982B
Strategy.java 379B
BaseStrategy.java 591B
TraiditionalSimulatedAnnealingStrategy.java 2KB
VariantSimulatedAnnealingStrategy.java 1KB
Utils.java 962B
HyperParameterConfig.java 2KB
.gitignore 308B
README.md 4KB
共 20 条
- 1
资源评论
快撑死的鱼
- 粉丝: 1w+
- 资源: 9149
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功