Hello, I am recently doing some Bayesian curve fitting examples. My code works anyway, but… there are a lot of error messages following the result. Could you let me know what is the problem and whether I can believe my result?
Especially, I was wondering what “ERROR (aesara.graph.rewriting.basic): Rewrite failure due to: transform_values” and “NotImplementedError: These Op
s should be removed from graphs used for computation.” messages mean…
Code:
num_data = 35
x_data, y_data = create_sampledata(num_data)
df = pd.DataFrame()
df['x'] = x_data.flatten().tolist()
df['y'] = y_data.flatten().tolist()
n = 5 # number of polynomial coefficients
lmd = 0
with pm.Model() as model:
x = pm.MutableData("x", df.x)
w_mu = pm.Normal('w_mu', mu=0., sigma = 1)
w_sigma = pm.HalfNormal('w_sigma', sigma = 10 )
w = pm.Normal('w', mu= w_mu, sigma = w_sigma, shape=n)
mu = pm.Deterministic("mu", sum(((w[i]*(x**i)) for i in range(n))))
likelihood_sigma = pm.HalfNormal('likelihood_sigma', sigma = 10)
likelihood = pm.Normal("y", mu = mu, sigma = likelihood_sigma, observed = df.y)
with model:
step = pm.Metropolis()
samples = pm.sample()
pm.plot_trace(samples)
Error Message:
ERROR (aesara.graph.rewriting.basic): Rewrite failure due to: transform_values
ERROR (aesara.graph.rewriting.basic): node: halfnormal_rv{0, (0, 0), floatX, False}(RandomGeneratorSharedVariable(<Generator(PCG64) at 0x2A9ADAC80>), TensorConstant{}, TensorConstant{11}, TensorConstant{0.0}, TensorConstant{10.0})
ERROR (aesara.graph.rewriting.basic): TRACEBACK:
ERROR (aesara.graph.rewriting.basic): Traceback (most recent call last):
File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/rewriting/basic.py”, line 1933, in process_node
replacements = node_rewriter.transform(fgraph, node)
File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/rewriting/basic.py”, line 1092, in transform
return self.fn(fgraph, node)
File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aeppl/transforms.py”, line 158, in transform_values
new_value_var = transformed_variable(
File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/op.py”, line 300, in call
compute_test_value(node)
File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/op.py”, line 138, in compute_test_value
thunk()
File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/op.py”, line 543, in rval
r = p(n, [x[0] for x in i], o)
File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aeppl/transforms.py”, line 56, in perform
raise NotImplementedError(
NotImplementedError: These Op
s should be removed from graphs used for computation.
ERROR (aesara.graph.rewriting.basic): Rewrite failure due to: transform_values
ERROR (aesara.graph.rewriting.basic): node: halfnormal_rv{0, (0, 0), floatX, False}(RandomGeneratorSharedVariable(<Generator(PCG64) at 0x2A9A09BA0>), TensorConstant{}, TensorConstant{11}, TensorConstant{0.0}, TensorConstant{10.0})
ERROR (aesara.graph.rewriting.basic): TRACEBACK:
ERROR (aesara.graph.rewriting.basic): Traceback (most recent call last):
File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/rewriting/basic.py”, line 1933, in process_node
…
NotImplementedError: These Op
s should be removed from graphs used for computation.
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [w_mu, w_sigma, w, likelihood_sigma]
Output exceeds the size limit. Open the full output data in a text editor
Sampling 4 chains for 1_000 tune and 2_000 draw iterations (4_000 + 8_000 draws total) took 115 seconds. There were 2 divergences after tuning. Increase target_accept
or reparameterize. There were 17 divergences after tuning. Increase target_accept
or reparameterize. There were 30 divergences after tuning. Increase target_accept
or reparameterize. There were 3 divergences after tuning. Increase target_accept
or reparameterize. ERROR (aesara.graph.rewriting.basic): Rewrite failure due to: transform_values ERROR (aesara.graph.rewriting.basic): node: halfnormal_rv{0, (0, 0), floatX, False}(RandomGeneratorSharedVariable(<Generator(PCG64) at 0x2A9A09BA0>), TensorConstant{}, TensorConstant{11}, TensorConstant{0.0}, TensorConstant{10.0}) ERROR (aesara.graph.rewriting.basic): TRACEBACK: ERROR (aesara.graph.rewriting.basic): Traceback (most recent call last): File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/rewriting/basic.py”, line 1933, in process_node replacements = node_rewriter.transform(fgraph, node) File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/rewriting/basic.py”, line 1092, in transform return self.fn(fgraph, node) File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aeppl/transforms.py”, line 158, in transform_values new_value_var = transformed_variable( File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/op.py”, line 300, in call compute_test_value(node) File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/op.py”, line 138, in compute_test_value thunk() File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aesara/graph/op.py”, line 543, in rval r = p(n, [x[0] for x in i], o) File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aeppl/transforms.py”, line 56, in perform raise NotImplementedError( NotImplementedError: These Op
s should be removed from graphs used for computation.
…
File “/Users/jinyoungko/anaconda3/lib/python3.9/site-packages/aeppl/transforms.py”, line 56, in perform raise NotImplementedError( NotImplementedError: These Op
s should be removed from graphs used for computation.