With the following code I get a (none, none) tensor containing a matrix rather than a 3x4 matrix turned into a 3x4 tensor:
import numpy as np
from aesara import shared
x_test = shared(np.random.randn(3,4))
print(x_test)
<TensorType(float64, (None, None))>
How can I make this a Tensor type with the shape 3x4
What am I doing wrong?
I think some related discussion came up here.
You can pass a shape argument to the shared constructor. Otherwise shared variables are resizeable by default.
x = shared(np.zeros((3, 4)), shape=(3, 4))
1 Like
Thank you. Though this raises a second question:
If I try and get the transpose of x_test.T, what I get back is InplaceDimShuffle{1,0}.0. Which is something that produces no values when I use the get_value() attribute. What is happening here?
Get value only exists for shared variables. Once you perform operations on the variables you get back non shared variables. If you want to check what they evaluate to you must compile a function and evaluate them or for debugging purposes you can call .eval()
on them.
For PyMC you should just use them directly without compiling or evaluating them.