def sample_weights(sizeX, sizeY, sparsity, scale, rng):
 sizeX = int(sizeX)
 sizeY = int(sizeY)
 sparsity = numpy.minimum(sizeY, sparsity)
 values = numpy.zeros((sizeX, sizeY), dtype=theano.config.floatX)
 for dx in xrange(sizeX):
  perm = rng.permutation(sizeY)
  new_vals = rng.uniform(low=(- scale), high=scale, size=(sparsity,))
  vals_norm = numpy.sqrt((new_vals ** 2).sum())
  new_vals = ((scale * new_vals) / vals_norm)
  values[(dx, perm[:sparsity])] = new_vals
 (_, v, _) = numpy.linalg.svd(values)
 values = ((scale * values) / v[0])
 return values.astype(theano.config.floatX)

def sample_weights ( sizeX , sizeY , sparsity , scale , rng ) : sizeX = int ( sizeX ) sizeY = int ( sizeY ) sparsity = numpy . minimum ( sizeY , sparsity ) values = numpy . zeros ( ( sizeX , sizeY ) , dtype = theano . config . floatX ) for dx in xrange ( sizeX ) : perm = rng . permutation ( sizeY ) new_vals = rng . uniform ( low = ( - scale ) , high = scale , size = ( sparsity , ) ) vals_norm = numpy . sqrt ( ( new_vals ** 2 ) . sum ( ) ) new_vals = ( ( scale * new_vals ) / vals_norm ) values [ ( dx , perm [ : sparsity ] ) ] = new_vals ( _ , v , _ ) = numpy . linalg . svd ( values ) values = ( ( scale * values ) / v [ 0 ] ) return values . astype ( theano . config . floatX )
initialization that fixes the largest singular value .