You can get the value of a shared variable as follows:
w.get_value()
Then it will work:
w.get_value().shape
But this will copy the contents of the shared variable. To delete a copy, you can use the borrow option as follows:
w.get_value(borrow=True).shape
But if the shared variable is on the GPU, it will still copy the data from the GPU to the CPU. To not do this:
w.get_value(borrow=True, return_internal_type=True).shape
This is an easier way to do this, compile the Anano function, which returns the form:
w.shape.eval()
w.shape returns a symbolic variable..eval () compiles the Anano function and returns the form value.
If you want to know more about how Theano handles memory, check out this web page: http://www.deeplearning.net/software/theano/tutorial/aliasing.html
nouiz source share