text: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  
  import numpy as np
  
  import deepxde as dde
  from deepxde.backend import tf
  
  
  def main():
      def pde(x, y):
          dy_x = tf.gradients(y, x)[0]
          dy_x, dy_t = dy_x[:, 0:1], dy_x[:, 1:]
          dy_xx = tf.gradients(dy_x, x)[0][:, 0:1]
          return (
              dy_t
              - dy_xx
              + tf.exp(-x[:, 1:])
              * (tf.sin(np.pi * x[:, 0:1]) - np.pi ** 2 * tf.sin(np.pi * x[:, 0:1]))
          )
  
      def func(x):
          return np.sin(np.pi * x[:, 0:1]) * np.exp(-x[:, 1:])
  
      geom = dde.geometry.Interval(-1, 1)
      timedomain = dde.geometry.TimeDomain(0, 1)
      geomtime = dde.geometry.GeometryXTime(geom, timedomain)
  
      data = dde.data.TimePDE(
          geomtime,
          pde,
          [],
          num_domain=40,
          solution=func,
          num_test=10000,
      )
  
      layer_size = [2] + [32] * 3 + [1]
      activation = "tanh"
      initializer = "Glorot uniform"
      net = dde.maps.FNN(layer_size, activation, initializer)
      net.apply_output_transform(
          lambda x, y: x[:, 1:2] * (1 - x[:, 0:1] ** 2) * y + tf.sin(np.pi * x[:, 0:1])
      )
  
      model = dde.Model(data, net)
  
      model.compile("adam", lr=0.001, metrics=["l2 relative error"])
      losshistory, train_state = model.train(epochs=10000)
  
      dde.saveplot(losshistory, train_state, issave=True, isplot=True)
  
  
  if __name__ == "__main__":
      main()
  