Closed
Description
Description
from pytensor.graph.replace import vectorize_graph
import pytensor.tensor as pt
mu = pt.tensor("mu", shape=(5, 3))
sigma = pt.tensor("sigma", shape=())
x = pt.random.normal(mu, sigma)
new_x = vectorize_graph(
x,
replace={
mu: pt.tensor("mu", shape=(10, 5, 3)),
sigma: pt.tensor("sigma", shape=(10,)),
}
)
ValueError: Could not broadcast dimensions. Incompatible shapes were [(ScalarConstant(ScalarType(int64), data=10), ScalarConstant(ScalarType(int64), data=5), ScalarConstant(ScalarType(int64), data=3)), (ScalarConstant(ScalarType(int64), data=1), ScalarConstant(ScalarType(int64), data=1), ScalarConstant(ScalarType(int64), data=10))].
With size we get another error
x = pt.random.normal(mu, sigma, size=mu.shape)
new_x = vectorize_graph(
x,
replace={
mu: pt.tensor("mu", shape=(10, 5, 3)),
sigma: pt.tensor("sigma", shape=(10,)),
}
)
ValueError: Tensor of type Matrix(int64, shape=(10, 2)) could not be cast to have 1 dimensions