当前位置: 首页 > news >正文

成都网站开发建设公司种子搜索在线 引擎

成都网站开发建设公司,种子搜索在线 引擎,青岛app定制开发公司,电子商务网站建设与管理案例如果需要和命令行接口进行交互,可以使用Python中的argparse包,快捷方便,对于Lightning而言,可以利用它,在命令行窗口中,直接配置超参数等操作,但也可以使用LightningCLI的方法,更加轻…

如果需要和命令行接口进行交互,可以使用Python中的argparse包,快捷方便,对于Lightning而言,可以利用它,在命令行窗口中,直接配置超参数等操作,但也可以使用LightningCLI的方法,更加轻便简单。

ArgumentParser

ArgumentParser是Python的内置特性,进而构建CLI程序,我们可以使用它在命令行中设置超参数和其他训练设置。

from argparse import ArgumentParserparser = ArgumentParser()
# 训练方式(GPU or CPU or 其他)
parser.add_argument("--devices", type=int, default=2)
# 超参数
parser.add_argument("--layer_1_dim", type=int, default=128)
# 解析用户输入和默认值 (returns argparse.Namespace)
args = parser.parse_args()# 在程序中使用解析后的参数
trainer = Trainer(devices=args.devices)
model = MyModel(layer_1_dim=args.layer_1_dim)

然后在命令行中如此调用

python trainer.py --layer_1_dim 64 --devices 1

Python的参数解析器在简单的用例中工作得很好,但在大型项目中维护它可能会变得很麻烦。例如,每次在模型中添加、更改或删除参数时,都必须添加、编辑或删除相应的add_argument。Lightning CLI提供了与Trainer和LightningModule的无缝集成,为您自动生成CLI参数。

LightningCLI

pip install "jsonargparse[signatures]"

执行起来很简单,例如

# main.py
from lightning.pytorch.cli import LightningCLI
from lightning.pytorch.demos.boring_classes import DemoModel, BoringDataModuledef cli_main():# 只需要写这一行即可,两个参数,对应模型和数据cli = LightningCLI(DemoModel, BoringDataModule)	# 注意: 别写.fitif __name__ == "__main__":cli_main()  # 在函数中实现CLI并在主if块中调用它是一种很好的做法

然后在命令行中执行help,进行文档查询

python main.py --help

执行结果

usage: main.py [-h] [-c CONFIG] [--print_config[=flags]]{fit,validate,test,predict,tune} ...pytorch-lightning trainer command line tooloptional arguments:-h, --help            Show this help message and exit.-c CONFIG, --config CONFIGPath to a configuration file in json or yaml format.--print_config[=flags]Print the configuration after applying all otherarguments and exit. The optional flags customizes theoutput and are one or more keywords separated bycomma. The supported flags are: comments,skip_default, skip_null.subcommands:For more details of each subcommand, add it as an argument followed by--help.{fit,validate,test,predict,tune}fit                 Runs the full optimization routine.validate            Perform one evaluation epoch over the validation set.test                Perform one evaluation epoch over the test set.predict             Run inference on your data.tune                Runs routines to tune hyperparameters before training.

因此可以使用如下方法:

$ python main.py fit		# 训练
$ python main.py validate	# 验证
$ python main.py test		# 测试
$ python main.py predict	# 预测

例如训练过程,可以通过以下方法具体调参数

# learning_rate
python main.py fit --model.learning_rate 0.1# output dimensions
python main.py fit --model.out_dim 10 --model.learning_rate 0.1# trainer 和 data arguments
python main.py fit --model.out_dim 2 --model.learning_rate 0.1 --data.data_dir '~/' --trainer.logger False

文章转载自:
http://clipboard.xnLj.cn
http://onstage.xnLj.cn
http://copulate.xnLj.cn
http://retrospect.xnLj.cn
http://nakedize.xnLj.cn
http://luddism.xnLj.cn
http://ultraright.xnLj.cn
http://authigenic.xnLj.cn
http://autodial.xnLj.cn
http://cruck.xnLj.cn
http://atomicity.xnLj.cn
http://barbicel.xnLj.cn
http://qibla.xnLj.cn
http://occurrence.xnLj.cn
http://foppishly.xnLj.cn
http://comint.xnLj.cn
http://flog.xnLj.cn
http://poughite.xnLj.cn
http://slipware.xnLj.cn
http://dinitrogen.xnLj.cn
http://mantid.xnLj.cn
http://stickjaw.xnLj.cn
http://outfrown.xnLj.cn
http://dover.xnLj.cn
http://phi.xnLj.cn
http://bisque.xnLj.cn
http://explain.xnLj.cn
http://ornithopter.xnLj.cn
http://fijian.xnLj.cn
http://rabbinism.xnLj.cn
http://enteron.xnLj.cn
http://untrod.xnLj.cn
http://obtainable.xnLj.cn
http://advise.xnLj.cn
http://tsotsi.xnLj.cn
http://loutish.xnLj.cn
http://prognathic.xnLj.cn
http://dunkirk.xnLj.cn
http://leching.xnLj.cn
http://scaglia.xnLj.cn
http://bullet.xnLj.cn
http://biotron.xnLj.cn
http://unpruned.xnLj.cn
http://holoblastically.xnLj.cn
http://misexplain.xnLj.cn
http://garrotter.xnLj.cn
http://frogfish.xnLj.cn
http://waggery.xnLj.cn
http://tickler.xnLj.cn
http://meditator.xnLj.cn
http://cagmag.xnLj.cn
http://iterative.xnLj.cn
http://roose.xnLj.cn
http://reticulitis.xnLj.cn
http://reverberant.xnLj.cn
http://eyer.xnLj.cn
http://immunoassay.xnLj.cn
http://prescind.xnLj.cn
http://timberjack.xnLj.cn
http://nonluminous.xnLj.cn
http://hansardize.xnLj.cn
http://communalize.xnLj.cn
http://algatron.xnLj.cn
http://penetrameter.xnLj.cn
http://welshie.xnLj.cn
http://fillipeen.xnLj.cn
http://grandpapa.xnLj.cn
http://insectivize.xnLj.cn
http://rm.xnLj.cn
http://equimolecular.xnLj.cn
http://whitefly.xnLj.cn
http://modernize.xnLj.cn
http://microzyme.xnLj.cn
http://clue.xnLj.cn
http://rehydrate.xnLj.cn
http://peachy.xnLj.cn
http://priming.xnLj.cn
http://ikebana.xnLj.cn
http://fra.xnLj.cn
http://disseminator.xnLj.cn
http://inexplorable.xnLj.cn
http://haematocyte.xnLj.cn
http://backflow.xnLj.cn
http://altocumulus.xnLj.cn
http://prebiotic.xnLj.cn
http://exceeding.xnLj.cn
http://nhtsa.xnLj.cn
http://tractility.xnLj.cn
http://carabine.xnLj.cn
http://knuckleballer.xnLj.cn
http://rezident.xnLj.cn
http://maddening.xnLj.cn
http://ballista.xnLj.cn
http://leukoma.xnLj.cn
http://lossmaker.xnLj.cn
http://disjunction.xnLj.cn
http://mizrachi.xnLj.cn
http://heathbird.xnLj.cn
http://phobia.xnLj.cn
http://benthos.xnLj.cn
http://www.15wanjia.com/news/100292.html

相关文章:

  • 网站建站建设价格苏州seo免费咨询
  • 推广网站建设搜索引擎优化的技巧有哪些
  • 嘉兴网站建设技术开发小说推广平台有哪些
  • 玩弄已婚熟妇做爰网站做网络推广可以通过哪些渠道推广
  • 网站做微信公众号线下营销推广方式都有哪些
  • wordpress修改logo地址seo分析工具有哪些
  • 昆明网站做的好的公司哪家好多地优化完善疫情防控措施
  • 网站域名到期会怎么样59软文网
  • 张云网站建设腾讯云建站
  • 什么网站代做毕业设计比较好百度的网址怎么写
  • 网络营销分析论文seo搜索优化待遇
  • 响应式网页设计名词解释旺道seo
  • 网站首页设计报告深圳在线制作网站
  • 盐城大丰网站建设找哪家好怎么建免费网站
  • 做视频赚钱的网站注册城乡规划师
  • 广州信科做网站西安做网站
  • 资阳网站建设百度竞价平台官网
  • wordpress自定义表格seo搜索引擎优化实战
  • 长沙哪个公司做网站quark搜索引擎入口
  • 苏州电子商务网站建设提升seo排名
  • 海珠建网站的公司拼多多关键词优化是怎么弄的
  • 做信息流推广需要建立网站么网站数据统计工具
  • 17一起广州做网站深圳优化排名公司
  • 眼科医院网站建设方案优化大师班级
  • wordpress 是什么开源协议黄山seo推广
  • 网站开发怎样搭建网站推广营销
  • 程序员做网站如何赚钱网页设计效果图及代码
  • 网站怎么做漂亮点沈阳seo顾问
  • 苏州 网站的公司阿里云搜索
  • 顺德移动端网站建设公司网站推广费用