I’m modeling a PDE for wildfire spread and want to use PyMC to recover parameters. I’m using a custom likelihood function that finds the Intersection Over Union metric comparing the predicted and observed burned areas. I want to use map these metrics to a Beta(5,1) distribution and use that as a likelihood estimate. The code should be something like what’s shown below. However, when I try to run it I get an error that the initial evaluation of the model at the starting point failed. These are the results given:

k_log__ -2.31

A_log__ -5.52

B_log__ -5.52

C_log__ 8.29

Cs_log__ -2.02

likelihood -inf

Any ideas for how to approach troubleshooting this would be appreciated.

```
def get_IoUs(T_preds, T_obs, burn=600):
'''
Calculates IOU score between observed and predicted
fire perimeters and maps it to a likelihood.
'''
n_per, n_data = T_obs.shape
burn_pred = T_preds >= burn
burn_obs = T_obs >= burn
IoUs = tt.zeros(n_per)
for p in range(n_per):
pred = burn_pred[p*n_data:(p+1)*n_data]
obs = burn_obs[p].flatten()
intersection = pred*obs
union = pred + obs
if tt.gt(union.sum(),0):
IoU = intersection.sum()/union.sum()
else:
IoU = 1
IoUs = tt.set_subtensor(IoUs[p], IoU)
return IoUs
with pm.Model() as model:
# Set prior distributions.
k = pm.Lognormal("k", mu=np.log(1), sigma=4, shape=(1,)) # Collision frequency
A = pm.Lognormal("A", mu=np.log(9000.), sigma=100, shape=(1,)) # Pre-exponential factor (rate)
B = pm.Lognormal("B", mu=np.log(300.), sigma=100, shape=(1,)) # Proportionality Coefficient/Activation Energy
C = pm.Lognormal("C", mu=np.log(1/10000), sigma=1/10000, shape=(1,)) # Scaled Heat Transfer Coefficient
Cs = pm.Lognormal("Cs", mu=np.log(3), sigma=3, shape=(1,)) # Fuel Relative Disappearance Rate
# Run the model.
T_preds = theano_fem_solver(k, A, B, C, Cs)
# Calculate the likelihood.
IoUs = pm.Deterministic("IoUs",get_IoUs(T_preds, Ts_observed))
likelihood = Beta('likelihood', alpha=5, beta=1, observed=IoUs)
# MCMC:
trace = pm.sample(tune=5, draws=5)
```