Help with speeding up the search and creating custom loss function expression #905
Replies: 3 comments 3 replies
-
A few tips:
I also find that You can also try template expressions. If you know the functional form, this can help a lot. https://ai.damtp.cam.ac.uk/pysr/examples/#template-expressions
Yes you can do this with |
Beta Was this translation helpful? Give feedback.
-
Hi Miles, I've been implementing your suggestions over the last few days, and they seem to have helped; thank you : D However, I do find that using Alternatively, I realised that maybe using
(taken from the Dimensional Constraints example). I'm having problems adapting it so it works with |
Beta Was this translation helpful? Give feedback.
-
On your loss: be careful because function custom_loss(prediction, target)
T = typeof(prediction)
zero_point = T(1e-9)
loss = abs(log(abs(prediction/target) + zero_point))
sign_loss = 10 * (sign(prediction) - sign(target))^2
return loss + sign_loss
end for the function custom_loss_full(ex, dataset::Dataset{T,L}, options) where {T,L}
prediction, valid = eval_tree_array(ex, dataset.X, options)
!valid && return L(Inf)
y = dataset.y
function custom_loss(a, b)
zero_point = T(1e-9)
loss = abs(log(abs(a / b) + zero_point))
sign_loss = 10 * (sign(a) - sign(b))^2
return loss + sign_loss
end
total_loss = sum([
custom_loss(prediction[i], y[i])
for i in eachindex(y)
])
# The above is written to be pedagogical and python-like.
# In truth, it's actually a tiny bit faster to write this as
# `sum(i -> custom_loss(prediction[i], y[i]), eachindex(y))`
# because you avoid allocating the extra array
return L(total_loss)
end Note that the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I usually run PySR on an HPC and let it run for 4 days at a time but I find that the loss is still quite large and the equations haven't evolved as much as I wanted them to. I've been reading and implementing the tips from Astroautomata, like turning on turbo, bumper and batching, keeping the operators simple, keeping a large
ncycles_per_iteration
, etc. One thing I would like to mention here is that I've kept a largemaxsize
since I'd like more complex equations (I know this can slow the process down a little bit). I've even downsampled the number of points in my dataset. Do you have any other suggestions that could help speed up the search?My second question is, is there a way to save a model and then continue training from where it stopped?
Below is what my hyperparameters look like -
Any help will be appreciated!! Thank you in advance : D
Beta Was this translation helpful? Give feedback.
All reactions