Problems encountered in derivation with tensorflow

Viewed 19

I have some problem when derivate with tensorflow. My code is:

def pde(x,y):
    x = dde.config.real.set_float64()
    u,k = y[:,0:1],y[:,1:2]
    du_x = tf.gradients(u,x)[0]
    du_x,du_y= du_x[:,0:1],du_x[:,1:2]
    du_xx = tf.gradients(du_x,x)[0][:,0:1]
    du_yy = tf.gradients(du_y,x)[0][:,1:2]
    return k*du_xx + k*du_yy

and the error is:

 f = self.pde(inputs, outputs_pde)
    File "d:/VS_CODE/AI_code/experiment/seepage_rectangle_bc.py", line 22, in pde  *
        du_x = tf.gradients(u,x)[0]

    AttributeError: 'NoneType' object has no attribute 'op'

How can I solve this problem?

1 Answers

In the first line of your function, you are overwriting x

x = dde.config.real.set_float64()

Change it to

def pde(x,y):
    dde.config.real.set_float64()
    u,k = y[:,0:1],y[:,1:2]
Related