一、 介绍
支持深度学习调参,优化器算法支持全面,且支持分布式计算,本地可以有效利用多核计算,文档及维护更新较多,安装使用快捷方便。
评分较好


安装:
pip install "ray[tune]" torch torchvision
二、相关用法示例
2.1 demo 示例
定义参数搜索空间 search_space
定义模型评分计算函数 objective
from ray import tune
# 1. Define an objective function.
def objective(config):
score = config["a"] ** 2 + config["b"]
return {
"score": score}
# 2. Define a search space.
search_space = {
"a": tune.grid_search([0.001, 0.01, 0.1, 1.0]),
"b": tune.choice([1, 2, 3]),
}
# 3. Start a Tune run and print the best result.
tuner = tune.Tuner(objective, param_space=search_space)
results = tuner.fit()
print(results.get_best_result(metric="score", mode="min").config)
结果:

三、资源参数示例
3.1 机器资源参数设定
tune.with_resources(trainable, {“cpu”: 2})
示例:
# If you have 4 CPUs on your machine, this will run 2 concurrent trials at a time.
trainable_with_resources = tune.with_resources(trainable, {
"cpu": 2})
tuner = tune.Tuner(
trainable_with_resources,
tune_config=tune.TuneConfig(num_samples=10)
)
results = tuner.fit()
# If you have 4 CPUs on your machine, this will run 1 trial at a time.
trainable_with_resources = tune.with_resources(trainable, {
"cpu": 4})
tuner = tune.Tuner(
trainable_with_resources,
tune_config=tune.TuneConfig(num_samples=10)
)
results = tuner.fit()
# Fractional values are also supported, (i.e., {"cpu": 0.5}).
# If you have 4 CPUs on your machine, this will run 8 concurrent trials at a time.
trainable_with_resources = tune.with_resources(trainable, {

最低0.47元/天 解锁文章
1163

被折叠的 条评论
为什么被折叠?



