ODE的深度学习

时间:2020-01-27 14:45:26

标签: tensorflow deep-learning

我已经根据Maziar Raissi(PINNs)编写的代码为一维ODE编写了代码。网络的近似解决方案与精确解不匹配。我无法解决问题。这是代码

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import scipy.io
from scipy.interpolate import griddata
from mpl_toolkits.axes_grid1 import make_axes_locatable
import matplotlib.gridspec as gridspec
import time

np.random.seed(1234)
tf.set_random_seed(1234)
class ODE:
# Initialize the class
def __init__(self, x, layers):



    self.x = x

    self.layers = layers

    # Initialize NNs
    self.weights, self.biases = self.initialize_NN(layers)

    # tf placeholders and graph
    self.sess = tf.Session(config=tf.ConfigProto(allow_soft_placement=True,

                             log_device_placement=True))

    # Initialize parameters

    self.x_tf = tf.placeholder(tf.float32)

    self.d_g_t = self.d_g_t(self.x_tf)
    self.func = self.func(self.x_tf)


    self.loss = tf.reduce_mean(tf.square(self.d_g_t - self.func)) 

    self.optimizer = tf.contrib.opt.ScipyOptimizerInterface(self.loss, 
                              method = 'L-BFGS-B', 
                              options = {'maxiter': 5000,
                                         'maxfun': 50000,
                                         'maxcor': 50,                                               
                  'ftol' : 1.0 * np.finfo(float).eps})

    self.optimizer_Adam = tf.train.AdamOptimizer()
    self.train_op_Adam = self.optimizer_Adam.minimize(self.loss)

    init = tf.global_variables_initializer()
    self.sess.run(init)

0 个答案:

没有答案