Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time per epoch increases substantially for high order (4th) targets #10

Closed
PieterGimbel opened this issue Nov 24, 2020 · 3 comments
Closed

Comments

@PieterGimbel
Copy link

I observed that the training time increases a lot if I added 4th order targets. During a quick check roughly the following training times were observed for the corresponding targets (1000 epochs):

  • 3x 0th order: < 1s
  • 2x 0th + 1x 4th: ~ 30s
  • 1x 0th + 2x 4th: ~ 100s

Is having high order targets that much more computational demanding? Are there ways to improve on this? Enabling GPU does not seem to matter.

@PieterGimbel PieterGimbel changed the title Training time increases substantially for high order (4th) targets Time per epoch increases substantially for high order (4th) targets Nov 26, 2020
@sciann
Copy link
Collaborator

sciann commented Dec 1, 2020

This is normal. Note that 4th differentiation results in an extensive graph and therefore computational time increase.
To avoid this, you can reduce the required order of differentiation by introducing new variables.

@sciann sciann closed this as completed Dec 1, 2020
@PieterGimbel
Copy link
Author

Thank you for your response. Do you mean introducing new variables in the following way?

x = sn.Variable(...)
w = sn.Functional(...)
w1x = sn.diff(w, x, order=1)
w2x = sn.diff(w1x, x, order=1)
w3x = sn.diff(w2x, x, order=1)
w4x = sn.diff(w3x, x, order=1)

This is how I was taking the 4th order derivative, because I noticed a time reduction in comparison to taking the 4th order derivative directly (w4x = sn.diff(w, x, order=4)). However, it was not a very impressive reduction.

@sciann
Copy link
Collaborator

sciann commented Dec 7, 2020

That might help but it still deals with 4th order derivatives that result in long computational graphs because of the chain rule.

Not sure if possible for your problem, but I meant to introduce intermediate functions. For instance, if you want to limit the differentiation order to two, you may do the following:

`
x = sn.Variable(...)
w = sn.Functional(...)
w1x = sn.diff(w, x, order=1)
w2x = sn.diff(w1x, x, order=1)

y = sn.Functional(...)
L1 = w2x - y

w3x = sn.diff(y, x, order=1)
w4x = sn.diff(y, x, order=1)
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant