Dear UQWorld community,
I am trying to use the Bayesian inversion module of UQ[py]Lab to solve an inverse problem based on synthetic data.
I will describe briefly the error I encounter and then try to be as precise as possible about my test case so you can help me out. ![]()
The error : when trying to run uq.createAnalysis(BayesOpts), I get the following error : âMOMap of data group 1 is not consistent with supplied dataâ
Description of my test case :
I have 5 forward models, which are PCE (already validated), reproducing the output of my physically based forward model for 5 output variables of interest (geophysical signals for 5 different acquisition parametrization).
The 5 PCE metamodels use the same set of input parameters (the parameters of my physically based forward model) and return a time-series of signals (numpy array of size Nout=66).
It is a synthetic test case in the sense that I used my forward model with a âTrueâ set of parameters to produce the data that I am using in the inversion. And I am trying to recover the âTrueâ parameter set with Bayesian inversion.
Here is how I setup the UQ[py]Lab inversion :
Forward model definition :
forwardModels = [
{
'Model' : myPCE['Name']
},
{
'Model' : myPCE_E2['Name']
},
{
'Model' : myPCE_E3['Name']
},
{
'Model' : myPCE_E4['Name']
},
{
'Model' : myPCE_E5['Name']
}
]
Parameters prior distributions :
myPriorDist = uq.createInput(InputOpts)
(with InputOpts describing the prior for each parameter of the models (18 parameters)).
Measurement data:
myData = [
# Data group 1
{
'y': [Y_E1_true.tolist()],
'Name': 'E0(q1)',
'MOMap': MOmap1.astype(int).tolist() # Model Output map
},
# Data group 2
{
'y': [Y_E2_true.tolist()],
'Name': 'E0(q2)',
'MOMap': MOmap2.astype(int).tolist() # Model Output map
},
# Data group 3
{
'y': [Y_E3_true.tolist()],
'Name': 'E0(q3)',
'MOMap': MOmap3.astype(int).tolist() # Model Output map
},
# Data group 4
{
'y': [Y_E4_true.tolist()],
'Name': 'E0(q4)',
'MOMap': MOmap4.astype(int).tolist() # Model Output map
},
# Data group 5
{
'y': [Y_E5_true.tolist()],
'Name': 'E0(q5)',
'MOMap': MOmap5.astype(int).tolist() # Model Output map
},
]
With each data array âY_EX_trueâ a numpy array containing the outputs of the forward model for the âtrueâ parametrization and for acquisition setup X.
And MOmapX defined as follows :
nt = Y_E1_true.shape[0]
MOmap = np.ones((nt,2))
Nout = np.array(range(nt))+1
MOmap[:,1] = Nout
MOmap1 = cp.deepcopy(MOmap)
MOmap2 = cp.deepcopy(MOmap)
MOmap2[:,0] = 2*MOmap2[:,0]
...
Which gives :
MOmap1 = [ [1,1], [1,2], âŚ, [1,66] ]
MOmap2 = [ [2,1], [2,2], âŚ, [2,66] ]
âŚ
I have checked that the size of the list correspond:
len(Y_EX_true.tolist()) returns 66
and len(MOmapX.astype(int).tolist()) returns 66
For the discrepancy model, I chose unknown discrepancy: i.i.d Gaussian with unknown variance (which prior is uniform in [0,50])
SigmaOpts = {
'Marginals': [
{
'Name': 'Sigma2E1',
'Type': 'Uniform',
'Parameters': [0,50] # (nV^2)
}
]
}
SigmaDistE1 = uq.createInput(SigmaOpts)
SigmaOpts['Marginals'][0]['Name'] = 'Sigma2E2'
SigmaDistE2 = uq.createInput(SigmaOpts)
SigmaOpts['Marginals'][0]['Name'] = 'Sigma2E3'
SigmaDistE3 = uq.createInput(SigmaOpts)
SigmaOpts['Marginals'][0]['Name'] = 'Sigma2E4'
SigmaDistE4 = uq.createInput(SigmaOpts)
SigmaOpts['Marginals'][0]['Name'] = 'Sigma2E5'
SigmaDistE5 = uq.createInput(SigmaOpts)
DiscrepancyOpts = [
{
'Type': 'Gaussian',
'Prior': SigmaDistE1['Name']
},
{
'Type': 'Gaussian',
'Prior': SigmaDistE2['Name']
},
{
'Type': 'Gaussian',
'Prior': SigmaDistE3['Name']
},
{
'Type': 'Gaussian',
'Prior': SigmaDistE4['Name']
},
{
'Type': 'Gaussian',
'Prior': SigmaDistE5['Name']
}
]
By the way, does this work ? Or should I define a discrepancy model for each output of each model ?
Finally, here are the options I set for the inversion :
Solver = {
'Type': 'MCMC',
'MCMC': {
'Sampler': 'AIES',
'Steps': 300,
'NChains': 100
}
}
BayesOpts = {
"Type": "Inversion",
"Name": "TC1_1",
"Prior": myPriorDist['Name'],
"ForwardModel": forwardModels,
"Data": myData,
"Discrepancy": DiscrepancyOpts,
"Solver": Solver
}
I hope this is detailed enough.
Maybe I got the concept of MOmap wrong⌠Since the example proposed in the âMultiple forward modelsâ example is only for scalar outputs (with multiple measurements). Here I have several models, and multidimensional output (despite a single measurement), and this case is not explicitely treated in the examples.
Thanks in advance for your help in fixing this problem.
I can bring more details on my problem if needed.
Best regards,
Guillaume Gru
PhD student at ITES, Strasbourg University, France