deepxde icon indicating copy to clipboard operation
deepxde copied to clipboard

How to ignore reference solution

Open divyanshjnv1 opened this issue 1 year ago • 2 comments

i am replicating for euler beam code given in deepxde library.

It is mentioned that if i don't have reference solution then i can ignore it, but I'm not able to figure it out. When i comment out func (reference solution) it show error in 'data' block . if i remove 'solution = func' from data block also it shows error in this line losshistory, train_state = model.train(iterations=10000)

(this issue is occurring for me in all the available codes)

reference code is this

"""Backend supported: tensorflow.compat.v1, tensorflow, pytorch, paddle""" import deepxde as dde import numpy as np

def ddy(x, y): return dde.grad.hessian(y, x)

def dddy(x, y): return dde.grad.jacobian(ddy(x, y), x)

def pde(x, y): dy_xx = ddy(x, y) dy_xxxx = dde.grad.hessian(dy_xx, x) return dy_xxxx + 1

def boundary_l(x, on_boundary): return on_boundary and dde.utils.isclose(x[0], 0)

def boundary_r(x, on_boundary): return on_boundary and dde.utils.isclose(x[0], 1)

def func(x): return -(x4) / 24 + x3 / 6 - x**2 / 4

geom = dde.geometry.Interval(0, 1)

bc1 = dde.icbc.DirichletBC(geom, lambda x: 0, boundary_l) bc2 = dde.icbc.NeumannBC(geom, lambda x: 0, boundary_l) bc3 = dde.icbc.OperatorBC(geom, lambda x, y, _: ddy(x, y), boundary_r) bc4 = dde.icbc.OperatorBC(geom, lambda x, y, _: dddy(x, y), boundary_r)

data = dde.data.PDE( geom, pde, [bc1, bc2, bc3, bc4], num_domain=10, num_boundary=2, solution=func, num_test=100, ) layer_size = [1] + [20] * 3 + [1] activation = "tanh" initializer = "Glorot uniform" net = dde.nn.FNN(layer_size, activation, initializer)

model = dde.Model(data, net) model.compile("adam", lr=0.001, metrics=["l2 relative error"]) losshistory, train_state = model.train(iterations=10000)

dde.saveplot(losshistory, train_state, issave=True, isplot=True)

please resolve the issue. thanks .

divyanshjnv1 avatar Nov 17 '23 13:11 divyanshjnv1

If you choose to ignore your reference solution, then you must leave out the metric in the model.compile line. Otherwise, DeepXDE is looking to calculate a metric against a quantity that is non-existent.

jdellag avatar Nov 20 '23 15:11 jdellag

Seems like i forgot to thank you , Really thanks for the response .

divyanshjnv1 avatar Mar 12 '24 04:03 divyanshjnv1