Closed SK-Math closed 2 years ago
Hi @SK-Math , you can easily achieve this by implementing your own torch module.
import torch
from neurodiffeq.networks import FCNN
class MyActivation(torch.nn.Module):
def forward(self, x):
return torch.cos(1.75 * x) * torch.exp(-x**2 / 2)
fcnn = FCNN(hidden_units=(50, 50), actv=MyActivation)
Let me know if there are further questions.
Thnka you @shuheng-liu for your quick responce
def forward(self, x):
return x*torch.exp(0.5)
when calling in solver getting error like TypeError: exp(): argument 'input' (position 1) must be Tensor, not float how to fix it
exp(0.5)
is just a constant. You can use np.exp
or math.exp
instead of torch.exp
, which only works for pytorch tensors (similar to numpy arrays)
Hi @shuheng-liu
How can I use Butterfly Optimization Algorithm instead of default ADAM optimization?
As I see torch.optim.
has not Butterfly Optimization .
How to plot Loss and validation graph during training ?
Thank you
I haven't heard of the butterfly optimization algorithm. If you really want to try it out, you probably have to implement your own Optimizer. Here is an article.
Can you be a little bit more specific as to "Loss and validation graph"? In general, you can inject behavior, including custom plotting and logging using the callback feature.
Hi, Can I write ode= 0.5*u''(x) + u'(0.5x) + u(x)* like `ode= lambda u, t: [ 0.5 diff(u, t, order=2) + diff(u, t/2) + u]` Just want to confirm writing of this term u'(0.5x)** please check.
Is neurodiffeq support fractional order diff. eq?
Thank you
Hi,
Can I write ode= 0.5u''(x) + u'(0.5x) + u(x) like ode= lambda u, t: [ 0.5 diff(u, t, order=2) + diff(u, t/2) + u] Just want to confirm writing of this term u'(0.5x) please check.
Is neurodiffeq support fractional order diff. eq?
Thank you
Hi, the first equation is, by definition, not a differential equation. It is a generic functional equation with differential operators. Hence, NeuroDiffEq cannot be used to solve this equation out of the box. But you can still solve it with neural networks, you just have to write some codes by yourself.
At the moment, NeuroDiffEq doesn't support fractional derivatives.
Hi,
I am pretty new to neurodiffeq, thank you very much for an excellent library. I want to use special type activation function in particular f(x)=
cos(1.75 x)* exp (-x**2/2)
so how I will define the class for using this activation function? and how to call this function in this linefcnn=FCNN(hidden_units=(50,50, ), actv=nn.Tanh)
Thank you in advance