Tensorflow模型的超参数调整 [英] Hyperparameter Tuning of Tensorflow Model

查看:400
本文介绍了Tensorflow模型的超参数调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前曾使用Scikit-learn的GridSearchCV优化模型的超参数,但只是想知道是否存在类似的工具来优化Tensorflow的超参数(例如,时期数,学习率,滑动窗口大小等)

I've used Scikit-learn's GridSearchCV before to optimize the hyperparameters of my models, but just wondering if a similar tool exists to optimize hyperparameters for Tensorflow (for instance number of epochs, learning rate, sliding window size etc.)

如果没有,如何实现有效运行所有不同组合的代码段?

And if not, how can I implement a snippet that effectively runs all different combinations?

推荐答案

使用Tensorflow进行网格搜索的另一个可行(已记录)选项是 Ray Tune 。它是用于超参数调整的可扩展框架,专门用于深度学习/强化学习。

Another viable (and documented) option for grid search with Tensorflow is Ray Tune. It's a scalable framework for hyperparameter tuning, specifically for deep learning/reinforcement learning.

您可以尝试此处是快速教程

它还负责Tensorboard日志记录和高效的搜索算法(即 HyperOpt 集成和 HyperBand )使用大约10行Python。

It also takes care of Tensorboard logging and efficient search algorithms (ie, HyperOpt integration and HyperBand) in about 10 lines of Python.

from ray import tune

def train_tf_model(config):  
    for i in range(num_epochs):
        accuracy = train_one_epoch(model)
        tune.report(acc=accuracy)

tune.run(train_tf_model,
         config={
            "alpha": tune.grid_search([0.2, 0.4, 0.6]),
            "beta": tune.grid_search([1, 2]),
         })

(免责声明:我为这个项目做出了积极的贡献!)

(Disclaimer: I contribute actively to this project!)

这篇关于Tensorflow模型的超参数调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆