def zeros(shape, dtype=None): """Initialize a tensor with zeros. If dtype is *None*, use *config.floatX*. Parameters ---------- shape : sequence of int The shape of Tensor. dtype : str, optional The data type of Tensor. Returns ------- Tensor The initialized tensor. """ if dtype is None: dtype = _cfg.floatX return _ops.Fill(shape=shape, value=0, dtype=dtype)
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 ones(shape, dtype=dtypes.float32, name=None): return ops.Fill(shape, value=1.0, name=name)
def zeros(shape, dtype=dtypes.float32, name=None): return ops.Fill(shape, value=0.0, name=name)
def __call__(self, shape, dtype=None, **kwargs): if dtype is None: dtype = self.dtype return _ops.Fill(shape, value=self.value, dtype=dtype.name)
def __call__(self, shape, dtype=None): if dtype is None: dtype = self.dtype return ops.Fill(shape, value=self.value)