In a simple model with 42 data, I can predict on hold-out data. but In another complex model with 126 data, the model throw the error:
’’ ValueError: Input dimension mis-match. (input[1].shape[0] = 126, input[2].shape[0] = 3)
Apply node that caused the error: Elemwise{Composite{exp((i0 + (i1 * i2) + (i3 * i4) + i5))}}[(0, 1)](InplaceDimShuffle{x}.0, AdvancedSubtensor1.0, <TensorType(int64, vector)>, InplaceDimShuffle{x}.0, <TensorType(int64, vector)>, AdvancedSubtensor1.0)
Toposort index: 5
Inputs types: [TensorType(float64, (True,)), TensorType(float64, vector), TensorType(int64, vector), TensorType(float64, (True,)), TensorType(int64, vector), TensorType(float64, vector)]
Inputs shapes: [(1,), (126,), (3,), (1,), (3,), (126,)]
Inputs strides: [(8,), (8,), (8,), (8,), (8,), (8,)]
Inputs values: [array([-0.]), ‘not shown’, array([5, 6, 7], dtype=int64), array([-0.]), array([40, 40, 40], dtype=int64), ‘not shown’]
Outputs clients: [[‘output’]]
HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag ‘optimizer=fast_compile’. If that does not work, Theano optimizations can be disabled with ‘optimizer=None’.
HINT: Use the Theano flag ‘exception_verbosity=high’ for a debugprint and storage map footprint of this apply node. ‘’
My model like this:
x_shared = shared(elec_year)
x_shared1 = shared(elec_tem)
y_shared = shared(elec_faults)
with pm.Model() as unpooled_model:
sigma = pm.HalfCauchy('sigma', 8, testval=1.)
beta = pm.Normal('beta', 0, 10)
beta1 = pm.Gamma('beta1', 2, 10, shape=companiesABC)
beta2 = pm.Normal('beta2', 0, 10)
sita = pm.Gamma('sita', 1, 100000)
u = pm.Normal('u', 0, sita, shape=companiesABC)
mu = pm.Deterministic('mu', tt.exp(beta + beta1[companyABC]*x_shared + beta2*x_shared1 + u[companyABC]))
Observed = pm.Weibull("Observed", alpha=mu, beta=sigma, observed=y_shared)
start = pm.find_MAP()
trace2 = pm.sample(4000, start=start)
x_shared.set_value([5, 6, 7])
x_shared1.set_value([40, 40, 40])
y_shared.set_value([0, 0, 0])
with unpooled_model:
post_pred = pm.sample_ppc(trace2, samples=500)
post_pred['Observed'].mean(axis=0)
whether I have to change the x_shared.set_value([5, 6, 7]) into a 126 length data?