Example #1
0
                     help='proposal_type')
 parser.add_argument('--scale',
                     type=str,
                     default='scale_64',
                     help='scale_size')
 parser.add_argument('--noise', type=str, default='0.05', help='scale_size')
 parser.add_argument('--exp',
                     type=str,
                     default='inversion_16_64',
                     help='scale_size')
 args = parser.parse_args()
 device = torch.device("cuda:2" if torch.cuda.is_available() else "cpu")
 latent_c = latent_c(device)
 mean_c = np.loadtxt(os.getcwd() +
                     f'/Gaussian/prediction/inversion_16/mean.dat')
 init_c = latent_c.coarse_latent(args.exp, mean_c).reshape(16, )
 # load experiment data #
 obs = np.loadtxt(os.getcwd() + f'/Gaussian/test_data/obs_{args.noise}.dat')
 sigma = np.loadtxt(os.getcwd() +
                    f'/Gaussian/test_data/sigma_{args.noise}.dat')
 true_permeability = np.loadtxt(
     os.getcwd() +
     f'/Gaussian/test_data/true_permeability_{args.noise}.dat')
 true_pressure = np.loadtxt(
     os.getcwd() + f'/Gaussian/test_data/true_pressure_{args.noise}.dat')
 obs_position = np.loadtxt(
     os.getcwd() + f'/Gaussian/test_data/obs_position_{args.noise}.dat')
 inference = inference(args.steps, args.burn_in, args.dim, obs, sigma,
                       true_permeability, true_pressure, obs_position,
                       args.scale, device)
 np.random.seed(64)
Example #2
0
    '''
    plot MDGM with 2 scales(16-64),16 is single scale(vanilla VAE)
    '''
    # torch.random.manual_seed(68)
    torch.random.manual_seed(7)

    device = torch.device("cuda:3" if torch.cuda.is_available() else "cpu")
    latent_c = latent_c(device)
    prediction = Prediction('scale_64', device)
    nz_x, nz_y = 4, 4
    z = torch.randn(4, 1, nz_x, nz_y)
    model = prediction.model('inversion_16')
    gen_imgs = prediction.permeability('inversion_16', model, z)
    samples = np.squeeze(gen_imgs.data.cpu().numpy())
    img = np.loadtxt(os.getcwd() + f'/Channel/MDGM_plot/channel_16.dat')
    zc = latent_c.coarse_latent('inversion_16_64', img).reshape(16, )
    zc = (np.ones([3, 1, 4, 4])) * zc.reshape(4, 4)
    z64 = torch.randn(3, 1, 16, 16)
    model = prediction.model('inversion_16_64')
    gen_imgs1 = prediction.permeability('inversion_16_64', model, zc, zf=z64)
    samples1 = np.squeeze(gen_imgs1.data.cpu().numpy())
    samples2 = [
        samples[0], samples[1], samples[2], samples[3], img, samples1[0],
        samples1[1], samples1[2]
    ]
    filename = '/channel_MDGM_16_64.pdf'
    prediction.plot_ite(samples2, filename)
    '''
    plot MDGM with 3 scales(16-32-64), 16 is single scale(vanilla VAE) present above
    '''
Example #3
0
                    bbox_inches='tight',
                    dpi=1000,
                    pad_inches=0.0)
        plt.close()


if __name__ == "__main__":
    torch.random.manual_seed(10)
    device = torch.device("cuda:3" if torch.cuda.is_available() else "cpu")
    latent_c = latent_c(device)
    prediction = Prediction('scale_64', device)
    nz_x, nz_y = 4, 4
    z = torch.randn(4, 1, nz_x, nz_y)
    model = prediction.model('inversion_16')
    gen_imgs = prediction.permeability('inversion_16', model, z)
    samples = np.squeeze(gen_imgs.data.cpu().numpy())
    condition = np.loadtxt(os.getcwd() +
                           f'/Gaussian/MDGM_plot/gaussian_16.dat')
    zc = latent_c.coarse_latent('inversion_16_64', condition).reshape(16, )
    zc = (np.ones([3, 1, 4, 4])) * zc.reshape(4, 4)
    z64 = torch.randn(3, 1, 16, 16)
    model = prediction.model('inversion_16_64')
    gen_imgs1 = prediction.permeability('inversion_16_64', model, zc, zf=z64)
    samples1 = np.squeeze(gen_imgs1.data.cpu().numpy())
    samples2 = [
        samples[0], samples[1], samples[2], samples[3], condition, samples1[0],
        samples1[1], samples1[2]
    ]
    filename = '/gaussian_MDGM_16_64.pdf'
    prediction.plot_ite(samples2, filename)
Example #4
0
if __name__ == "__main__":
    '''
    plot MDGM with 2 scales(16-64),16 is single scale(vanilla VAE)
    '''
    torch.random.manual_seed(9)

    device = torch.device("cuda:3" if torch.cuda.is_available() else "cpu")
    latent_c = latent_c(device)
    prediction = Prediction('scale_64', device)
    nz_x, nz_y = 4, 4
    z = torch.randn(4, 1, nz_x, nz_y)
    model = prediction.model('inversion_16')
    gen_imgs = prediction.permeability('inversion_16', model, z)
    samples = np.squeeze(gen_imgs.data.cpu().numpy())
    img = np.loadtxt(os.getcwd() + f'/Channel/MDGM_plot/channel_16.dat')
    zc = latent_c.coarse_latent('inversion_16_64', img).reshape(16, )
    zc = (np.ones([3, 1, 4, 4])) * zc.reshape(4, 4)
    z64 = torch.randn(3, 1, 16, 16)
    model = prediction.model('inversion_16_64')
    gen_imgs1 = prediction.permeability('inversion_16_64', model, zc, zf=z64)
    samples1 = np.squeeze(gen_imgs1.data.cpu().numpy())
    samples2 = [
        samples[0], samples[1], samples[2], samples[3], img, samples1[0],
        samples1[1], samples1[2]
    ]
    filename = '/channel_MDGM_16_64.pdf'
    prediction.plot_ite(samples2, filename)
    '''
    plot MDGM with 3 scales(16-32-64), 16 is single scale(vanilla VAE) present above
    '''