Documentation for residual-based adaptive sampling #968
Unanswered
SamanHooshyar
asked this question in
Q&A
Replies: 2 comments 3 replies
-
Beta Was this translation helpful? Give feedback.
2 replies
-
|
@SamanHooshyar DeepXDE has an example of doing RAR in their examples, it follows this structure: n_new = 1000 # number of new samples
x, y = np.linspace(0, 1, 101), np.linspace(0, 1, 101)
x, y = np.meshgrid(x, y) # test distribution
X = np.stack([x.flatten(), y.flatten()], axis=-1)
for i in range(5):
f = np.array(model.predict(X, operator=<your pde system>)) # get residuals from PDE system
e = np.square(f)
e = np.sum(e, axis = 0) # aggregate across the multiple losses for each point using SE
x_id = np.argsort(e, axis = 0)[:n_new] # sort and select n_new worst performing points
new_points = np.squeeze(X[x_id])
print("Adding ",len(x_id)," new points. \n")
solver.add_anchors(new_points) # add them as anchors
solver.resample_train_points() # optional
model.compile("adam", lr = 1e-4)
loss_history, train_state = model.train(iterations=10000, display_every = 10000) # train again
# repeat until certain condition met or for a certain amount of resamples (5 here)
dde.saveplot(loss_history, train_state, issave=False, isplot=True) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Thank you for constructing and publishing the DeepXDE package. I was wondering if you could tell me where I can find documentation on implementing residual-based adaptive sampling and gradient-enhanced PINN. I am trying different methods of sampling collocation points to improve my network accuracy.
Thanks,
Beta Was this translation helpful? Give feedback.
All reactions