You can get the value of a shared variable like this:
w.get_value()
Then this would work:
w.get_value().shape
But this will copy the shared variable content. To remove the copy you can use the borrow parameter like this:
w.get_value(borrow=True).shape
But if the shared variable is on the GPU, this will still copy the data from the GPU to the CPU. To don't do this:
w.get_value(borrow=True, return_internal_type=True).shape
Their is a simpler way to do this, compile a Theano function that return the shape:
w.shape.eval()
w.shape
return a symbolic variable. .eval() will compile a Theano function and return the value of shape.
If you want to know more about how Theano handle the memory, check this web page: http://www.deeplearning.net/software/theano/tutorial/aliasing.html