Hello everyone!
I am trying to work with the following likelyhood:
I think it has a technical name but I don’t remember it, would love if anyone could tell me
I have set it up in the following way:
def logp_exp_lag(t, tau_0, tau):
return T.log(T.switch(t < tau_0, 1E-20,T.exp( - (t - tau_0) / tau)/ tau ))
with pm.Model() as my_model:
tau = pm.Uniform('tau', 0.1, 10, shape=1)
tau_0 = pm.Uniform('tau_0', 0.1, 5, shape=1)
like = DensityDist('like', logp_exp_lag, observed= { 't': df['tp (ns)'].to_numpy(),
'tau' : tau,
'tau_0' : tau_0
}
, shape=1
)
with my_model:
my_model_trace = pm.sample(1000, random_seed=RANDOM_SEED, cores=1)
And I get the following error:
MissingInputError Traceback (most recent call last)
<ipython-input-42-5fde18f3ad5a> in <module>
1 with my_model:
----> 2 my_model_trace = pm.sample(1000, random_seed=RANDOM_SEED, cores=1)
3 #ppc = pm.sample_posterior_predictive(my_model_trace, var_names=["like"], random_seed=RANDOM_SEED, cores=1 )
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/pymc3/sampling.py in sample(draws, step, init, n_init, start, trace, chain_idx, chains, cores, tune, progressbar, model, random_seed, discard_tuned_samples, compute_convergence_checks, **kwargs)
496 warnings.warn("The number of samples is too small to check convergence reliably.")
497 else:
--> 498 trace.report._run_convergence_checks(trace, model)
499
500 trace.report._log_summary()
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/pymc3/backends/report.py in _run_convergence_checks(self, trace, model)
82 varnames.append(rv_name)
83
---> 84 self._ess = ess = ess(trace, var_names=varnames)
85 self._rhat = rhat = rhat(trace, var_names=varnames)
86
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/pymc3/stats/__init__.py in wrapped(*args, **kwargs)
22 )
23 kwargs[new] = kwargs.pop(old)
---> 24 return func(*args, **kwargs)
25
26 return wrapped
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/arviz/stats/diagnostics.py in ess(data, var_names, method, relative, prob)
186 raise TypeError(msg)
187
--> 188 dataset = convert_to_dataset(data, group="posterior")
189 var_names = _var_names(var_names, dataset)
190
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/arviz/data/converters.py in convert_to_dataset(obj, group, coords, dims)
175 xarray.Dataset
176 """
--> 177 inference_data = convert_to_inference_data(obj, group=group, coords=coords, dims=dims)
178 dataset = getattr(inference_data, group, None)
179 if dataset is None:
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/arviz/data/converters.py in convert_to_inference_data(obj, group, coords, dims, **kwargs)
89 return from_pystan(**kwargs)
90 elif obj.__class__.__name__ == "MultiTrace": # ugly, but doesn't make PyMC3 a requirement
---> 91 return from_pymc3(trace=kwargs.pop(group), **kwargs)
92 elif obj.__class__.__name__ == "EnsembleSampler": # ugly, but doesn't make emcee a requirement
93 return from_emcee(sampler=kwargs.pop(group), **kwargs)
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/arviz/data/io_pymc3.py in from_pymc3(trace, prior, posterior_predictive, log_likelihood, coords, dims, model, save_warmup)
538 dims=dims,
539 model=model,
--> 540 save_warmup=save_warmup,
541 ).to_inference_data()
542
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/arviz/data/io_pymc3.py in __init__(self, trace, prior, posterior_predictive, log_likelihood, predictions, coords, dims, model, save_warmup)
159 self.dims = {**model_dims, **self.dims}
160
--> 161 self.observations, self.multi_observations = self.find_observations()
162
163 def find_observations(self) -> Tuple[Optional[Dict[str, Var]], Optional[Dict[str, Var]]]:
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/arviz/data/io_pymc3.py in find_observations(self)
172 elif hasattr(obs, "data"):
173 for key, val in obs.data.items():
--> 174 multi_observations[key] = val.eval() if hasattr(val, "eval") else val
175 return observations, multi_observations
176
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/theano/gof/graph.py in eval(self, inputs_to_values)
520 inputs = tuple(sorted(inputs_to_values.keys(), key=id))
521 if inputs not in self._fn_cache:
--> 522 self._fn_cache[inputs] = theano.function(inputs, self)
523 args = [inputs_to_values[param] for param in inputs]
524
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/theano/compile/function.py in function(inputs, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input)
315 on_unused_input=on_unused_input,
316 profile=profile,
--> 317 output_keys=output_keys)
318 return fn
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/theano/compile/pfunc.py in pfunc(params, outputs, mode, updates, givens, no_default_updates, accept_inplace, name, rebuild_strict, allow_input_downcast, profile, on_unused_input, output_keys)
484 accept_inplace=accept_inplace, name=name,
485 profile=profile, on_unused_input=on_unused_input,
--> 486 output_keys=output_keys)
487
488
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/theano/compile/function_module.py in orig_function(inputs, outputs, mode, accept_inplace, name, profile, on_unused_input, output_keys)
1837 on_unused_input=on_unused_input,
1838 output_keys=output_keys,
-> 1839 name=name)
1840 with theano.change_flags(compute_test_value="off"):
1841 fn = m.create(defaults)
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/theano/compile/function_module.py in __init__(self, inputs, outputs, mode, accept_inplace, function_builder, profile, on_unused_input, fgraph, output_keys, name)
1485 # OUTPUT VARIABLES)
1486 fgraph, additional_outputs = std_fgraph(inputs, outputs,
-> 1487 accept_inplace)
1488 fgraph.profile = profile
1489 else:
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/theano/compile/function_module.py in std_fgraph(input_specs, output_specs, accept_inplace)
179
180 fgraph = gof.fg.FunctionGraph(orig_inputs, orig_outputs,
--> 181 update_mapping=update_mapping)
182
183 for node in fgraph.apply_nodes:
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/theano/gof/fg.py in __init__(self, inputs, outputs, features, clone, update_mapping)
173
174 for output in outputs:
--> 175 self.__import_r__(output, reason="init")
176 for i, output in enumerate(outputs):
177 output.clients.append(('output', i))
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/theano/gof/fg.py in __import_r__(self, variable, reason)
344 # Imports the owners of the variables
345 if variable.owner and variable.owner not in self.apply_nodes:
--> 346 self.__import__(variable.owner, reason=reason)
347 elif (variable.owner is None and
348 not isinstance(variable, graph.Constant) and
~/data_partition/bin2/anaconda3/envs/electroporation_modeling/lib/python3.7/site-packages/theano/gof/fg.py in __import__(self, apply_node, check, reason)
389 "for more information on this error."
390 % (node.inputs.index(r), str(node)))
--> 391 raise MissingInputError(error_msg, variable=r)
392
393 for node in new_nodes:
MissingInputError: Input 0 of the graph (indices start from 0), used to compute sigmoid(tau_interval__), was not provided and not given a value. Use the Theano flag exception_verbosity='high', for more information on this error.
This happens after the sampling. Does anyone have suggestions?
By the way, is there a way to add a 0 instead of a 1E-20 it is very hacky.
Thanks a lot!
Best,
Sergio