lululxvi / deepxde

A library for scientific machine learning and physics-informed learning
https://deepxde.readthedocs.io
GNU Lesser General Public License v2.1
2.47k stars 712 forks source link

Cannot convert a symbolic tf.Tensor (Placeholder_6:0) to a numpy array #1724

Open yuan743470957 opened 2 months ago

yuan743470957 commented 2 months ago
def pde2(x, y):
    dy_x = dde.grad.jacobian(y, x, i=0, j=0)
    dy_t = dde.grad.jacobian(y, x, i=0, j=1)
    dy_xx = dde.grad.hessian(y, x, i=0, j=0)
    y_pred_value = model.predict(x)
    return dy_t + y_pred_value * dy_x - 0.01 / np.pi * dy_xx

NotImplementedError: Cannot convert a symbolic tf.Tensor (Placeholder_6:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported.

praksharma commented 2 months ago

This is the problem.

y_pred_value = model.predict(x)

Can you show me your PDE please?

yuan743470957 commented 1 month ago
def pde(x, y):
    dy_x = dde.grad.jacobian(y, x, i=0, j=0)
    dy_t = dde.grad.jacobian(y, x, i=0, j=1)

    dy_xx = dde.grad.hessian(y, x, i=0, j=0)
    return  dy_t + y * dy_x - 0.01 / np.pi * dy_xx
lululxvi commented 1 week ago

You cannot use model.predict in PDE definition.

yuan743470957 commented 1 week ago

You cannot use model.predict in PDE definition.

I want to use two networks, where the prediction value of one network appears in the loss function of the other network. How should I write the code for this