-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Labels
Description
Issue with current documentation:
Hey all! Excited to get to know pyMC! I copied the second example (hearing impairment dataset) from the website to get familiar, and ran into some issues with that code. Just thought I'd flag in case it should be updated. I fully appreciate that these might be newcomer mistakes, but thought I'd share in case. Thanks in advance! Happy to provide anything else that might be useful.
- I'm unable to sample from the prior predictive distribution without reshaping the dot product in the output
scores
. I seem to have to do
scores = pm.Normal("scores", (beta0 + pt.dot(X.values, beta)).reshape((N, 1)), sigma, observed=y.values)
in order for
with test_score_model:
prior_samples = pm.sample_prior_predictive()
to run. If I don't do the reshape, I get an error:
ValueError: Output size (101, 1) is not compatible with broadcast dimensions of inputs (101, 101).
Apply node that caused the error: normal_rv{"(),()->()"}(RNG(<Generator(PCG64) at 0x12F753D80>), [101 1], Add.0, ExpandDims{axes=[0, 1]}.0)
Toposort index: 21
Inputs types: [RandomGeneratorType, TensorType(int64, shape=(2,)), TensorType(float64, shape=(1, 101)), TensorType(float64, shape=(1, 1))]
Inputs shapes: ['No shapes', (2,), (1, 101), (1, 1)]
Inputs strides: ['No strides', (8,), (8, 8), (8, 8)]
Inputs values: [Generator(PCG64) at 0x12F753D80, array([101, 1]), 'not shown', array([[0.3688817]])]
Outputs clients: [[output[14](normal_rv{"(),()->()"}.0)], [output[4](scores)]]
- Drawing graphviz does make an image close to what is shown in the docs, but throws an ugly error:
ERROR (pytensor.graph.rewriting.basic): Rewrite failure due to: random_make_inplace
ERROR (pytensor.graph.rewriting.basic): node: t_rv{"(),(),()->()"}(*0-<RandomGeneratorType>, *1-<NoneTypeT>, *2-<Scalar(int8, shape=())>, 0.0, *3-<Scalar(float64, shape=())>)
ERROR (pytensor.graph.rewriting.basic): TRACEBACK:
ERROR (pytensor.graph.rewriting.basic): Traceback (most recent call last):
File "/Users/spencer/Dropbox/Cypress/.venv/lib/python3.13/site-packages/pytensor/graph/rewriting/basic.py", line 1922, in process_node
replacements = node_rewriter.transform(fgraph, node)
File "/Users/spencer/Dropbox/Cypress/.venv/lib/python3.13/site-packages/pytensor/graph/rewriting/basic.py", line 1086, in transform
return self.fn(fgraph, node)
~~~~~~~^^^^^^^^^^^^^^
...
TypeError: Tensor type field must be a TensorType; found <class 'pytensor.tensor.type_other.NoneTypeT'>.
Idea or request for content:
No response