Wandb在运行训练脚本时忽略–configs标志。

huangapple go评论123阅读模式
英文:

Wandb ignores --configs flag when running training script

问题

使用脚本时,我想指定要使用的配置 YAML 文件。文档 中指出,您可以使用 --configs 标志来指定要加载的配置文件,但是在运行以下脚本时:

  1. >>> python myscript.py --configs new-configs.yaml

在以下脚本中:

  1. import wandb
  2. wandb.init()
  3. print(wandb.config)

我发现加载的配置是 config-defaults.yaml 中包含的配置,而不是 new-configs.yaml。为什么会发生这种情况?

规格

  1. MacOS 13.4.1Apple M1 芯片)
  2. python 3.10.12
  3. tensorflow-macos 2.12.0
  4. tensorflow-metal 0.8.0
  5. wandb 0.15.5
英文:

Running a script I want to specify what config YAML to use. The documentation states you can specify what configuration file to load using the --configs flag, however running

  1. >>> python myscript.py --configs new-configs.yaml

on the following script

  1. import wandb
  2. wandb.init()
  3. print(wandb.config)

I can see that the configuration contained in config-defaults.yaml is being loaded instead. Why is this happening?

Specs

  1. MacOS 13.4.1 (Apple M1 chip)
  2. python 3.10.12
  3. tensorflow-macos 2.12.0
  4. tensorflow-metal 0.8.0
  5. wandb 0.15.5

答案1

得分: 1

--configs标志用于指定一个与默认的config-defaults.yaml不同的配置文件。然而,重要的是要注意,--configs标志应该在运行wandb命令时使用,而不是在运行您的Python脚本时使用。

如果您想在运行Python脚本时使用不同的配置文件,您应该在脚本中手动从文件加载配置。以下是一个示例:

  1. import wandb
  2. import yaml
  3. # 从文件加载配置
  4. with open('new-configs.yaml') as file:
  5. config = yaml.safe_load(file)
  6. # 使用加载的配置初始化wandb
  7. wandb.init(config=config)
  8. print(wandb.config)

在这个示例中,配置是使用yaml库从new-configs.yaml加载的,然后传递给wandb.init()

如果您仍然想使用--configs标志,您可以在wandb命令中使用它,像这样:

  1. wandb --configs=new-configs.yaml

这将使用new-configs.yaml的配置启动一个新的运行。但是,这不会运行您的Python脚本。如果您想使用此配置运行您的脚本,您应该在脚本中从wandb.config加载配置,像这样:

  1. import wandb
  2. # 初始化wandb
  3. wandb.init()
  4. # 获取配置
  5. config = wandb.config
  6. print(config)

在这个示例中,配置是从wandb.config加载的,这是由wandb命令使用--configs标志设置的。希望这有所帮助!

英文:

The --configs flag is used to specify a different configuration file other than the default config-defaults.yaml. However, it's important to note that the --configs flag should be used when running the wandb command, not when running your python script.
If you want to use a different configuration file when running your python script, you should load the configuration from the file manually in your script. Here is an example of how you can do this:

  1. python
  2. import wandb
  3. import yaml
  4. # Load config from file
  5. with open('new-configs.yaml') as file:
  6. config = yaml.safe_load(file)
  7. # Initialize wandb with the loaded config
  8. wandb.init(config=config)
  9. print(wandb.config)

In this example, the configuration is loaded from new-configs.yaml using the yaml library, and then passed to wandb.init().

If you still want to use the --configs flag, you should use it with the wandb command, like this:

  1. bash
  2. wandb --configs=new-configs.yaml

This will start a new run with the configuration from new-configs.yaml. However, this will not run your python script. If you want to run your script with this configuration, you should load the configuration from wandb.config in your script, like this:

  1. python
  2. import wandb
  3. # Initialize wandb
  4. wandb.init()
  5. # Get the configuration
  6. config = wandb.config
  7. print(config)

In this example, the configuration is loaded from wandb.config, which is set by the wandb command with the --configs flag.

I hope this helps!

huangapple
  • 本文由 发表于 2023年7月20日 22:18:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/76730836.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定