BoundsError when using TemplateExpressionSpec with custom loss function #1011
-
|
Hi, I’m hitting a BoundsError whenever I use TemplateExpressionSpec with a simple setup (combine="g(s) + h(v)"). It looks like the template combine function is trying to access expressions[2] while only one sub-expression is present. My EnvironmentPySR: 1.5.9 CodeError messageI don't know why this problem occurs and how to fix it, but if you have any good suggestions, please let me know. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Ah, you should use |
Beta Was this translation helpful? Give feedback.
For computing gradients in a template expression you could use the
Doperator? https://ai.damtp.cam.ac.uk/pysr/examples/#13-using-differential-operatorseval_grad_tree_arrayis not set up to work with template expressions. You could either useDwithin the template expression body (recommended) or, for advanced usage, you could use ForwardDiff (or Zygote/Mooncake/Enzyme) to compute a derivative ofeval_tree_arraydirectly.In any case, it's probably a good idea to throw an error for both cases (much appreciated if you could post a dedicated issue for this, to help us track things)