tensor.utils – Tensor Utils

  • theano.tensor.utils.hashfrom_ndarray(_data)[source]
  • Return a hash from an ndarray.

It takes care of the data, shapes, strides and dtype.

  • theano.tensor.utils.shapeof_variables(_fgraph, input_shapes)[source]
  • Compute the numeric shape of all intermediate variables given input shapes.

Parameters:

  • fgraph – The theano.FunctionGraph in question.
  • input_shapes (dict) – A dict mapping input to shape.Returns:
  • shapes (dict) – A dict mapping variable to shape
  • .. warning:: This modifies the fgraph. Not pure.

Examples

  1. >>> import theano
  2. >>> x = theano.tensor.matrix('x')
  3. >>> y = x[512:]; y.name = 'y'
  4. >>> fgraph = theano.FunctionGraph([x], [y], clone=False)
  5. >>> d = shape_of_variables(fgraph, {x: (1024, 1024)})
  6. >>> d[y]
  7. (array(512), array(1024))
  8. >>> d[x]
  9. (array(1024), array(1024))