I recently came across a bug in a model where I was seeking to pass a stack() of TensorVariables to pymc. My issue boiled down to the following example:
a = pt.TensorType("float64", (3,))()
b = pt.TensorType("float64", (3,))()
c = pt.stack([a, b])
c.type
TensorType(float64, (?, ?))
I had expected that the shape information stored in the TensorType would be (2, 3). Instead, it seems that pytensor sets the shape information to be unknown/symbolic (hopefully I’m using the correct terminology there). Is there a reason for this?
And, follow-up, is it correct practice to use pt.specify_shape()
in the case where I know the fixed shape that the variable is going to take on?
Mainly asking for curiosity’s sake. (This is marked “v5” but the same behavior seems to occur at least in recent versions of aesara as well.) Thanks!