Skip to content

Instantly share code, notes, and snippets.

@benjaminkaplanphd
Created September 13, 2019 15:12
Show Gist options
  • Save benjaminkaplanphd/17d0161fd2da1ded8f12d8df64cbc971 to your computer and use it in GitHub Desktop.
Save benjaminkaplanphd/17d0161fd2da1ded8f12d8df64cbc971 to your computer and use it in GitHub Desktop.
Print Theano Tensor Shape
import numpy as np
from theano import function, printing, shared, tensor as T
PRINT = printing.Print('Theano shape: ', attrs=['shape'])
def example():
array = np.ones((3, 4))
print(f'Numpy shape: {array.shape}')
x = T.dmatrix()
printed_x = PRINT(x)
f = function([x], printed_x)
f(array)
example()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment