def shape(input, name=None, out_type=dtypes.float32): """ Returns the shape of a tensor. This operation returns a 1-D integer tensor representing the shape of `input`. For example: ```python # 't' is [[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]]] shape(t) ==> [2, 2, 3] ``` Args: input: A `Tensor`. name: A name for the operation (optional). out_type: (Enforce) The specified output type of the operation. Now only support tf.float32. Returns: A `Tensor` of type `out_type`. """ return ops.Shape(input, name=None)
def Setup(self, bottom): super(BilinearResizeLayer, self).Setup(bottom) input = bottom[0] if isinstance(bottom, list) else bottom if isinstance(bottom, list) and len(bottom) > 1: dshape = ops.Shape(bottom[1]) self._param['dsize'] = (dshape[2], dshape[3]) return ops.BilinearResize(input, **self._param)
def ones_like(model, dtype=None, **kwargs): """Initialize a tensor with ones, refer the shape of another tensor. The values can be access only after the run of graph. If dtype is ``None``, use ``config.floatX``. Parameters ---------- model : Tensor The tensor to refer shape. dtype : str The data type of Tensor. Returns ------- Tensor The initialized tensor. """ if dtype is None: dtype = config.floatX else: raise TypeError("Unsupported data type: {}".format(dtype)) return ops.Fill(shape=ops.Shape(model), value=1)
def shape(input, name=None, out_type=dtypes.float32): return ops.Shape(input, name=None)