TUM-DAML / seml

SEML: Slurm Experiment Management Library
Other
165 stars 29 forks source link

Bug: Step sizes for grid ranges are converted to integers #96

Closed heborras closed 2 years ago

heborras commented 2 years ago

Expected Behavior

When defining a grid search of the type range seml should follow the behaviour of np.arange and accept float parameters as steps.

Actual Behavior

The step size is cast to an integer in this code line: https://github.com/TUM-DAML/seml/blob/master/seml/parameters.py#L179 Which in some cases results in the wrong step size and in extreme cases causes a division by zero error.

Steps to Reproduce the Problem

  1. Define a grid search of type range with a step size of 0.1.
  2. Trying to add the experiment to seml will result in a ZeroDivisionError as pasted below.

Error message:

(seml) [hborras@ceg-octane sensitivity-metric]$ seml mlp-test3 add mlp_global_noise_experiment.yaml
Traceback (most recent call last):
  File "/home/hborras/.conda/envs/seml/bin/seml", line 8, in <module>
    sys.exit(main())
  File "/home/hborras/.conda/envs/seml/lib/python3.9/site-packages/seml/main.py", line 298, in main
    f(**vars(command))
  File "/home/hborras/.conda/envs/seml/lib/python3.9/site-packages/seml/add.py", line 153, in add_experiments
    configs = generate_configs(experiment_config, overwrite_params=overwrite_params)
  File "/home/hborras/.conda/envs/seml/lib/python3.9/site-packages/seml/config.py", line 224, in generate_configs
    grids = [generate_grid(v, parent_key=k) for k, v in grid_params.items()]
  File "/home/hborras/.conda/envs/seml/lib/python3.9/site-packages/seml/config.py", line 224, in <listcomp>
    grids = [generate_grid(v, parent_key=k) for k, v in grid_params.items()]
  File "/home/hborras/.conda/envs/seml/lib/python3.9/site-packages/seml/parameters.py", line 181, in generate_grid
    values = list(np.arange(min_val, max_val, step))
ZeroDivisionError: float division by zero

Specifications

Details - Version: 0.3.6 - Python version: 3.7 - Platform: ``` (seml) [hborras@ceg-octane examples]$ uname -a Linux ceg-octane 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux ``` - Anaconda environment (`conda list`): ``` (seml) [hborras@ceg-octane examples]$ conda list # packages in environment at /home/hborras/.conda/envs/seml: # # Name Version Build Channel _libgcc_mutex 0.1 main _openmp_mutex 4.5 1_gnu ca-certificates 2021.10.26 h06a4308_2 certifi 2021.10.8 py37h06a4308_2 colorama 0.4.4 pypi_0 pypi debugpy 1.5.1 pypi_0 pypi docopt 0.6.2 pypi_0 pypi gitdb 4.0.9 pypi_0 pypi gitpython 3.1.27 pypi_0 pypi importlib-metadata 4.11.2 pypi_0 pypi jsonpickle 1.5.2 pypi_0 pypi libedit 3.1.20210910 h7f8727e_0 libffi 3.2.1 hf484d3e_1007 libgcc-ng 9.3.0 h5101ec6_17 libgomp 9.3.0 h5101ec6_17 libstdcxx-ng 9.3.0 hd4cf53a_17 munch 2.5.0 pypi_0 pypi ncurses 6.3 h7f8727e_2 numpy 1.21.5 pypi_0 pypi openssl 1.0.2u h7b6447c_0 packaging 21.3 pypi_0 pypi pandas 1.1.5 pypi_0 pypi pip 21.2.2 py37h06a4308_0 py-cpuinfo 8.0.0 pypi_0 pypi pymongo 4.0.1 pypi_0 pypi pyparsing 3.0.7 pypi_0 pypi python 3.7.0 h6e4f718_3 python-dateutil 2.8.2 pypi_0 pypi pytz 2021.3 pypi_0 pypi pyyaml 6.0 pypi_0 pypi readline 7.0 h7b6447c_5 sacred 0.8.2 pypi_0 pypi seml 0.3.6 pypi_0 pypi setuptools 58.0.4 py37h06a4308_0 six 1.16.0 pypi_0 pypi smmap 5.0.0 pypi_0 pypi sqlite 3.33.0 h62c20be_0 tk 8.6.11 h1ccaba5_0 tqdm 4.63.0 pypi_0 pypi typing-extensions 4.1.1 pypi_0 pypi wheel 0.37.1 pyhd3eb1b0_0 wrapt 1.13.3 pypi_0 pypi xz 5.2.5 h7b6447c_0 zipp 3.7.0 pypi_0 pypi zlib 1.2.11 h7f8727e_4 ```
gasteigerjo commented 2 years ago

Sounds reasonable. Fixed in 30b4afa. Thank you!