Hi, I have rewritten the code, it is almost there, but it came across an error.
class Simulator1DOp(Op):
# __props__ = ('H', 'windowNum', 'fmin', 'fmax', 'pulse', 't', 'matchFilter', 'f', 'tmf')
def __init__(self, H, windowNum, fmin, fmax, pulse, t, matchFilter, f, tmf):
...
def make_node(self, eps, lossTangent, thicknesses):
eps = pt.as_tensor_variable(eps)
lossTangent = pt.as_tensor_variable(lossTangent)
thicknesses = pt.as_tensor_variable(thicknesses)
return Apply(self, [eps, lossTangent, thicknesses], [pt.matrix()])
def perform(self, node, inputs, outputs):
eps, lossTangent, thicknesses = inputs
result = self.run_sim(eps, lossTangent, thicknesses)
outputs = np.asarray(result)
def run_sim(self, eps, lossTangent, thicknesses): # the main simulation function
...
with pm.Model() as model:
eps = pm.Uniform('eps', lower=3.0, upper=10.0, shape=3)
simulated_data = simulator_op(eps, true_loss_tangent, true_thicknesses)
sigma = pm.HalfNormal('sigma', sigma=1.0)
pm.Normal('obs', mu=simulated_data, sigma=sigma, observed=synthetic_data)
trace = pm.sample(5000, tune=1000, progressbar=True, return_inferencedata=True)
The error occurred as:
The tested instance of Simulator1DOp cliass is
Simulator1DOp [id A] <Matrix(float64, shape=(?, ?))>
├─ [3.8 8. 3. ] [id B] <Vector(float64, shape=(3,))>
├─ [0.0001 0. … 02 0.0003] [id C] <Vector(float64, shape=(3,))>
└─ [30 40] [id D] <Vector(int32, shape=(2,))>
Could you give me some advice? Thank you very much!
