Skip to content

Experiments: Modifying parameters in lists #4768

@sjawhar

Description

@sjawhar

Description of requested functionality

One of the things I do in my project is define a neural network model as a list of layers in params.yaml. I'm thinking it would be useful to dvc exp run and tweak different aspects of the model. However, accessing parameters inside lists is currently not supported. For example:

train:
  model:
    hidden_layers:
      - BatchNormalization
      - LSTM:
          units: 32

Let's say I want to change the number of LSTM units. I think I should be able to do that with train.model.hidden_layers.1.units=64. This currently does not work, and throws an error instead.

I know lists can be tricky, but I will also now open a preliminary PR with a very naïve change that at least allows the command to run. I'm sure more changes and tests will be needed, but I wanted to get the ball rolling 😸

Error Logs

2020-10-21 16:59:00,192 ERROR: unexpected error - 'CommentedSeq' object has no attribute 'get'
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/dvc/main.py", line 76, in main
    ret = cmd.run()
  File "/usr/local/lib/python3.8/dist-packages/dvc/command/experiments.py", line 419, in run
    self.repo.experiments.run(
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/__init__.py", line 801, in run
    return run(self.repo, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/__init__.py", line 51, in wrapper
    return f(repo, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/run.py", line 62, in run
    return repo.experiments.reproduce_one(
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/__init__.py", line 345, in reproduce_one
    stash_rev = self.new(**kwargs)
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/__init__.py", line 38, in wrapper
    return f(exp, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/__init__.py", line 407, in new
    stash_rev = self._stash_exp(
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/__init__.py", line 265, in _stash_exp
    self._update_params(params)
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/__init__.py", line 309, in _update_params
    _update(data, params[params_fname])
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/__init__.py", line 299, in _update
    dict_[key] = _update(dict_.get(key, {}), value)
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/__init__.py", line 299, in _update
    dict_[key] = _update(dict_.get(key, {}), value)
  File "/usr/local/lib/python3.8/dist-packages/dvc/repo/experiments/__init__.py", line 299, in _update
    dict_[key] = _update(dict_.get(key, {}), value)
  [Previous line repeated 1 more time]
AttributeError: 'CommentedSeq' object has no attribute 'get'
------------------------------------------------------------
2020-10-21 16:59:00,284 DEBUG: Version info for developers:
DVC version: 1.8.4 (pip)
---------------------------------
Platform: Python 3.8.0 on Linux-5.4.0-51-generic-x86_64-with-glibc2.27
Supports: http, https, s3
Cache types: hardlink, symlink
Repo: dvc, git

Metadata

Metadata

Assignees

No one assigned

    Labels

    A: experimentsRelated to dvc expbugDid we break something?

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions