示例#1
0
    def __init__(self, V, chol, randobs):
        '''
        Parameters:
            V - FEniCS FunctionSpace
            chol - Covariance matrix to define Gaussian field over V
        '''
        self._V = V
        self._solver = Fin(self._V, randobs)
        self._pred_k = dl.Function(self._V)

        # Setup synthetic observations
        self.k_true = dl.Function(self._V)

        # Random Gaussian field as true function
        #  norm = np.random.randn(len(chol))
        #  nodal_vals = np.exp(0.5 * chol.T @ norm)

        nodal_vals = np.load('res_x.npy')
        self.k_true.vector().set_local(nodal_vals)

        w, y, A, B, C = self._solver.forward(self.k_true)
        self.obs_data = self._solver.qoi_operator(w)

        # Setup DL error model
        #  self._err_model = load_parametric_model_avg('elu', Adam,
        #0.0003, 5, 58, 200, 2000, V.dim())
        self._err_model = load_bn_model(randobs)

        # Initialize reduced order model
        self.phi = np.loadtxt('../data/basis_nine_param.txt', delimiter=",")
        self._solver_r = AffineROMFin(self._V, self._err_model, self.phi,
                                      randobs)
        self._solver_r.set_data(self.obs_data)
# ROMML imports
from fom.forward_solve_exp import Fin
from fom.thermal_fin import get_space
from rom.averaged_affine_ROM import AffineROMFin
from deep_learning.dl_model import load_parametric_model_avg, load_bn_model
from gaussian_field import make_cov_chol

randobs = True

resolution = 40
V = get_space(resolution)
chol = make_cov_chol(V, length=1.2)

# Setup DL error model
#  err_model = load_parametric_model_avg('elu', Adam, 0.0003, 5, 58, 200, 2000, V.dim())
err_model = load_bn_model()

# Initialize reduced order model
phi = np.loadtxt('../data/basis_nine_param.txt', delimiter=",")
solver_r = AffineROMFin(V, err_model, phi, randobs)

# Setup synthetic observations
solver = Fin(V, randobs)
z_true = dl.Function(V)

#Generate random Gaussian field
#  norm = np.random.randn(len(chol))
#  nodal_vals = np.exp(0.5 * chol.T @ norm)

#Load random Gaussian field
nodal_vals = np.load('res_x.npy')
示例#3
0
from fom.forward_solve import Fin
from fom.thermal_fin import get_space
from rom.averaged_affine_ROM import AffineROMFin 
from deep_learning.dl_model import load_bn_model, load_surrogate_model
from bayesian_inference.gaussian_field import make_cov_chol

#  randobs = True
randobs = True

resolution = 40
V = get_space(resolution)
chol = make_cov_chol(V, length=1.6)

# Setup DL error model
#  err_model = load_parametric_model_avg('elu', Adam, 0.0003, 5, 58, 200, 2000, V.dim())
err_model = load_bn_model(randobs)
surrogate_model = load_surrogate_model(randobs)

# Initialize reduced order model
phi = np.loadtxt('../data/basis_nine_param.txt',delimiter=",")
solver_r = AffineROMFin(V, err_model, phi, randobs)

# Setup synthetic observations
solver = Fin(V, randobs)
z_true = dl.Function(V)

prior_covariance = np.load('prior_covariance_0.07_0.07.npy')
L = np.linalg.cholesky(prior_covariance)
#  draw = np.random.randn(V.dim())
#  nodal_vals = np.dot(L, draw)