NeuroDiffGym / neurodiffeq

A library for solving differential equations using neural networks based on PyTorch, used by multiple research groups around the world, including at Harvard IACS.
http://pypi.org/project/neurodiffeq/
MIT License
680 stars 89 forks source link

Unable to import solver and monitor #156

Closed Arup-nit closed 2 years ago

Arup-nit commented 2 years ago

Dear Liu, I am getting error when import solver and monitor. from neurodiffeq.solvers import Solver1D getting error like this ImportError: cannot import name 'Solver1D' from 'neurodiffeq.solvers' (C:\Users\USER\anaconda3\lib\site-packages\neurodiffeq\solvers.py) from neurodiffeq.monitors import Monitor1D getting error like this ImportError: cannot import name 'Monitor1D' from 'neurodiffeq.monitors' (C:\Users\USER\anaconda3\lib\site-packages\neurodiffeq\monitors.py) pl fix it thank u

Arup-nit commented 2 years ago

Also facing same problem for import Solver 2D and Monitor 2D. Thank you

shuheng-liu commented 2 years ago

Can you check your C:\Users\USER\anaconda3\lib\site-packages\neurodiffeq\solvers.py file and see if it contains a Solver1D class? This is likely a python environment issue specific to your local setup.

Arup-nit commented 2 years ago

I update to latest version. I want to solve fourth order ODE, With both neumann and dirichlit conditions. for ex y(0)=1,y'(0)=2,y(1)=2,y'(1)=3 Can I solve using this package?

Arup-nit commented 2 years ago

Dear Liu, after update to latest version; my earlier code is not working for solving second order ode for DirichletBVP

train_generator = ExampleGenerator(N, t_min=0.1, t_max=2, method='uniform')

solution, loss_history, internals = solve(
    ode=ode,
    condition=condition, 
    t_min=x_1, 
    t_max=x_2, 
    optimizer=adam,
    monitor=monitor, 
    max_epochs=5000,
    return_internal=True,
    train_generator=train_generator,
    valid_generator=valid_generator,
    batch_size=train_generator.size,
  )

Giving error like name 'adam' is not defined If remove optimizer=adam and run then giving below error TqdmKeyError: "Unknown argument(s): {'colour': 'blue'}"

Please look into this

shuheng-liu commented 2 years ago

The error is because you did not define the variable adam and python doesn't know that variable is. You need to try

adam = torch.optim.Adam(...)

before passing that to the solve function.

On another note, the solve function is deprecated long ago and you should stop using it because we'll stop supporting it in the future.

Arup-nit commented 2 years ago

Thank you