I am sorry to bother you. But, in my case, it does not work. To be more specific, I was facing this kind of problem.
I want to get initial values from my each model (however, model.initial_point gives me an address of initial values.)
Even though I use the initial_values
import pymc as pm
import aesara.tensor as at
with pm.Model() as model:
p1 = pm.Uniform(‘p’, 0, 1)
p2 = 1 - p1
p = at.stack([p1, p2]) # Vectorize p1 and p2.
print(type(p))
print(np.shape(p))
assignment = pm.Categorical(“assignment”,
p,
shape = data.shape[0],
testval = np.random.randint(0,2,data.shape[0]))
print(“prior assignment, with p = %.2f:” % p1.tag.test_value)
print(assignment.tag.test_value[:10])
A result is:
AttributeError: ‘ValidatingScratchpad’ object has no attribute ‘test_value’
Even though I add some lines,
print(model.initial_point)
print(model.initial_values)
<bound method Model.initial_point of <pymc.model.Model object at 0x14e9e2410>>
{p: None, assignment: array([0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1,
1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1,
0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1,
1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1,
0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0,
0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1,
1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1,
0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0,
0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1,
1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1,
1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1,
1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0,
0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1,
0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1])}
Since I need to get a single real number (0.5) from p1.tag.test_value in PyMC3, model.initial_point or model.initial_values do not work in this case…
How can I exactly get a test value from a distribution?