def __call__(self, shape, name=None): flat_shape = (shape[0], np.prod(shape[1:])) a = self.rng.normal(0.0, 1.0, flat_shape) u, _, v = np.linalg.svd(a, full_matrices=False) # pick the one with the correct shape q = u if u.shape == flat_shape else v q = q.reshape(shape) return sharedX(self.scale * q[:shape[0], :shape[1]], name=name)
def __call__(self, shape, name=None): return sharedX(self.rng.randn(*shape) * self.scale, name=name)
def __call__(self, shape, name=None): return sharedX(self.rng.uniform(low=-self.scale, high=self.scale, size=shape), name=name)
def __call__(self, shape, name=None): if len(shape) != 2 or shape[0] != shape[1]: raise Exception("Identity matrix initialization can only be used for 2D square matrices") else: return sharedX(self.scale * np.identity(shape[0]), name=name)
def __call__(self, shape, name=None): return sharedX(self.scale * np.ones(shape), dtype=theano.config.floatX, name=name)