Giter Club home page Giter Club logo

Comments (4)

PaParaZz1 avatar PaParaZz1 commented on May 29, 2024

cfg就是user config啊,在任何compile和merge的时候都是放在第二个参数上

from di-engine.

jedz5 avatar jedz5 commented on May 29, 2024

create_config才是usr_config的哇。。?
image

from di-engine.

PaParaZz1 avatar PaParaZz1 commented on May 29, 2024

理一下config的结构和compile_config的原理:

  • user_config:用户写的env_algo_config.py是user_config;user_config中有两部分,main_config和create_config,前者是具体的参数设置信息,后者是具体各个模块创建需要的信息(比如什么类型,相应文件的引用路径)。
  • main_config(cfg):main_config是所有使用情况下都必需的config,包含所有具体的配置信息,所以在代码里也一般简写为cfg
  • create_config:对于使用CLI工具,或者serial_entry_xxx.py系列入口,为了实现多算法通用的接口,使用注册器-创建函数机制来创建模块,因此就需要指定额外的信息(比如policy要指定type是dqn),并在compile_config函数中传入create_config,同时指定auto=True;但是如果使用自定义入口(比如cartpole_dqn_main.py),就可以直接import相关类来创建对象,同时直接将具体的类名传入compile_config函数并指定auto=False
  • compile_config:DI-engine中的诸多模块都有default_config,一方面在阅读代码时可以看到这个类最常用的配置参数值,另一方面,用户在使用时就不需要指定所有相关的配置字段了,只需指定其想修改的相关字段。而compile_config,就是将user_config和default_config进行合并和转化的相关函数,而要在这个函数中获得default_config,就必须知道这次启动想要使用的模块对应的类,所以要么传create_config,要么传具体的类名
  • 另外,关于config的高级转化和验证,我们还设计实现了Loader相关工具,在分布式版本中将会起到重要作用,有兴趣的话可以了解一下 https://github.com/opendilab/DI-engine/tree/main/ding/utils/loader

from di-engine.

jedz5 avatar jedz5 commented on May 29, 2024

好的 懂了 多谢~~

from di-engine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.