I have the following model of which I have trained using pm.Minibatch
on batches of size 256.
n_features = 150
n_competitors = 10
init_1 = np.random.randn(n_features, 1)
with pm.Model() as linear_model:
w1 = pm.Normal('w1', 0, sd=1, shape=(n_features, 1), testval=init_1)
w1_repeat = pm.math.block_diagonal([w1]*n_competitors)
act_out = tt.nnet.softmax(tt.dot(X, w1_repeat))
pm.Deterministic('p', act_out)
out = pm.Categorical('out', act_out, observed=Y)
approx = pm.fit(100000,
callbacks=[pm.callbacks.CheckParametersConvergence(tolerance=1e-4)])
In order to get the inference I tried the following, but the output is of size 256 (the length of the batch):
trace = approx.sample(draws=1000)
X.set_value(X_test)
Y.set_value(np.zeros(len(X_test)))
with linear_model:
ppc = pm.sample_ppc(trace, samples=100)
I know this answer is supposed to help somehow but I can’t seem to figure it out. I also tried the following which doesn’t exactly give me an output:
with linear_model:
test_probs = approx.sample_node(act_out,
more_replacements={X:X_test},
size=100
)
- Any thoughts on how to solve this?
- In the previous block when I tried ppc, I only had access to
ppc['out']
and could not get access to ppc[‘p’]. I thought doingpm.Deterministic('p', act_out)
would have given me access to the actual probabilities.
Thanks in advance,
Sachin