dso-org / deep-symbolic-optimization

A deep learning framework for symbolic optimization.
BSD 3-Clause "New" or "Revised" License
568 stars 122 forks source link

ValueError in train.py #40

Closed TOP1RM closed 2 years ago

TOP1RM commented 2 years ago

Hello,

I am using the control task of DSO. I recently reinstall everything and ran an ancient program that used to work with my previous installation. My goal is to find control law for simple chaotic dynamical systems (Dadras, Rössler, Lorenz etc...). I created gym environements for them, but now I get this error when launch DSO on the Dadras system (not the Lorenz):

MY COMMAND: python -m dso.run ~/Bureau/Scripts/Python/DSO/config/DS.json

THE OUTPUT:

WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

== EXPERIMENT SETUP START ===========
Task type            : control
Environment          : DS-v0
Starting seed        : 0
Runs                 : 1
== EXPERIMENT SETUP END =============

== TRAINING SEED 0 START ============
/home/remi/deep-symbolic-optimization-master/dso/dso/prior.py:757: RuntimeWarning: divide by zero encountered in log
  self.logit_adjust[tokens] -= np.log(len(tokens))
-- BUILDING PRIOR START -------------
WARNING: Skipping invalid 'RelationalConstraint' with arguments {'targets': [], 'effectors': [], 'relationship': None}. Reason: Prior disabled.
WARNING: Skipping invalid 'RepeatConstraint' with arguments {'tokens': 'const', 'min_': None, 'max_': 3}. Reason: Prior disabled.
WARNING: Skipping invalid 'InverseUnaryConstraint' with arguments {}. Reason: There are no inverse unary Token pairs in the Library.
WARNING: Skipping invalid 'TrigConstraint' with arguments {}. Reason: There are no target Tokens.
WARNING: Skipping invalid 'ConstConstraint' with arguments {}. Reason: Uses Tokens not in the Library.
WARNING: Skipping invalid 'LanguageModelPrior' with arguments {'weight': None}. Reason: Prior disabled.
LengthConstraint: Sequences have minimum length 4.
                  Sequences have maximum length 30.
NoInputsConstraint: Sequences contain at least one input variable Token.
UniformArityPrior: Activated.
SoftLengthPrior: No description available.
-- BUILDING PRIOR END ---------------

WARNING: max_length (256) will be overridden by value from LengthConstraint (30).
-- RUNNING EPOCHS START -------------
/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/site-packages/numpy/core/fromnumeric.py:3373: RuntimeWarning: Mean of empty slice.
  out=out, **kwargs)
/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/site-packages/numpy/core/_methods.py:170: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
WOLA []
Traceback (most recent call last):
  File "/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/remi/deep-symbolic-optimization-master/dso/dso/run.py", line 156, in <module>
    main()
  File "/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/remi/deep-symbolic-optimization-master/dso/dso/run.py", line 139, in main
    result, summary_path = train_dso(config)
  File "/home/remi/deep-symbolic-optimization-master/dso/dso/run.py", line 33, in train_dso
    result = model.train()
  File "/home/remi/deep-symbolic-optimization-master/dso/dso/core.py", line 83, in train
    **self.config_training))
  File "/home/remi/deep-symbolic-optimization-master/dso/dso/train.py", line 472, in learn
    p_r_best = programs[np.argmax(r)]
  File "<__array_function__ internals>", line 6, in argmax
  File "/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 1188, in argmax
    return _wrapfunc(a, 'argmax', axis=axis, out=out)
  File "/home/remi/anaconda3/envs/DSO_env_6/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 58, in _wrapfunc
    return bound(*args, **kwds)
ValueError: attempt to get argmax of an empty sequence

As stated by the error message, the problem comes from train.py at line 471, where the variable r is empty, causing the error. I just started to study the code, but I don't think I will have time to understand everything. Maybe an expert could tell me if that error is normal or not.

I don't get this error when working with another dynamical system (Lorenz system for example). My gym environment is the same for Lorenz and Dadras (apart from its behavior, that is to say the equations of the dynamical system).

Looking forward to an answer. Thanks and regards! Rémi

brendenpetersen commented 2 years ago

Hi, if you post your config I should be able to help!

brendenpetersen commented 2 years ago

Feel free to reopen if you want to engage.