jdtoscano94 / Learning-Scientific_Machine_Learning_Residual_Based_Attention_PINNs_DeepONets

Physics Informed Machine Learning Tutorials (Pytorch and Jax)
436 stars 164 forks source link

Wrong derivative on DeepONet example #6

Open Daniel-EST opened 1 year ago

Daniel-EST commented 1 year ago

On the DeepONet anti-derivative notebook, the last example shows how to approximate the anti-derivative for $u(x)=cos(2\pi x),∀x\in[0,1]$. However, the u_fn lambda is defined as $u(x)=-cos(2\pi x),∀x\in[0,1]$.

From what I could understand $s(x)$ would be equals to $-\frac{1}{2\pi}sin(2\pi x)$ in this case.

Actual text:


Let's obtain the anti-derivative of a trigonometric function. However, remember that this neural operator works for $x\in[0,1]$ when the antiderivative's initial value ($s(0)=0$). To fulfill that conditions, we will use $u(x)=cos(2\pi x),∀x\in[0,1]$.

  #u_fn = lambda x, t: np.interp(t, X.flatten(), gp_sample)
  u_fn = lambda t, x: -np.cos(2*np.pi*x) # Should be np.cos(2*np.pi*x)
  # Input sensor locations and measurements
  x = np.linspace(0, 1, m)
  u = u_fn(None,x)
  # Output sensor locations and measurements
  y =random.uniform(key_train, (m,)).sort()
jdtoscano94 commented 1 year ago

You are right; there is a typo in the code; it should say.

u_fn = lambda t, x: np.cos(2np.pix)

Thanks for noticing it!

Sincerely,

Juan

Daniel-EST commented 1 year ago

You are welcome. Also, thanks for the great examples I was having trouble understanding DeepONet models, your examples made it clear.

PS.: I reopened the issue so you can close it by yourself when the typo is fixed.