def __init__(self, inmod, outmod, learnParams=None, c0=None, **kwargs): # 2nd half for int connections kwargs['outSliceFrom'] = outmod.dim kwargs['outSliceTo'] = outmod.dim*2 Connection.__init__(self, inmod, outmod, **kwargs) if isinstance(outmod, GFNNLayer): outmod.conns.append(self) if learnParams is None: learnParams = {'learn': True, 'w': 0.05, 'l': 0, 'm1': -1, 'm2': -50, 'e': 4, 'k': 1 } # Critical learning rule if 'type' not in learnParams: learnParams['type'] = 'allfreq' self.setArgs(learnParams=learnParams, c0=c0) self.setLearnParams(learnParams) if c0 is not None: self.c0 = np.zeros((self.outdim, self.indim), np.complex64) self.c0[:] = c0 self.c = np.zeros((self.outdim, self.indim), np.complex64) if inmod == outmod: # Don't learn self-connections # This could be inverted guassian too self.mask = 1-eye(self.outdim, self.indim) # ParameterContainer.__init__(self, self.indim*self.outdim) self.k *= self.mask self.kSteps = np.zeros((4, self.outdim, self.indim), np.complex64) self.randomize() self.reset()
def __init__(self, weight, maxIndex, *args, **kwargs): Connection.__init__(self, *args, **kwargs) assert self.indim == self.outdim, \ "Indim (%i) does not equal outdim (%i)" % ( self.indim, self.outdim) self.weight = weight self.maxIndex = maxIndex
def __init__(self, inmod, outmod, name=None, inSliceFrom=0, inSliceTo=None, outSliceFrom=0, outSliceTo=None): if outSliceTo is None: outSliceTo = outmod.indim size = outSliceTo - outSliceFrom Connection.__init__(self, inmod, outmod, name, inSliceFrom, inSliceTo, outSliceFrom, outSliceTo) ParameterContainer.__init__(self, size)
def __init__(self, inmod, outmod, name=None, inSliceFrom=0, inSliceTo=None, outSliceFrom=0, outSliceTo=None): if inSliceTo is None: inSliceTo = inmod.outdim size = inSliceTo - inSliceFrom Connection.__init__(self, inmod, outmod, name, inSliceFrom, inSliceTo, outSliceFrom, outSliceTo) ParameterContainer.__init__(self, size)
def __init__(self, inmod, outmod, permutation, blocksize, *args, **kwargs): Connection.__init__(self, inmod, outmod, *args, **kwargs) if self.indim != self.outdim: raise ValueError("Indim (%i) does not equal outdim (%i)" % ( self.indim, self.outdim)) if len(permutation) * blocksize != self.indim: raise ValueError( "Permutation has wrong size: should be %i but is %i." %( (self.indim / blocksize), len(permutation))) self.permutation = array(permutation) self.invpermutation = permute(list(range(len(permutation))), permutation) self.blocksize = blocksize
def __init__(self, inmod, outmod, permutation, blocksize, *args, **kwargs): Connection.__init__(self, inmod, outmod, *args, **kwargs) if self.indim != self.outdim: raise ValueError("Indim (%i) does not equal outdim (%i)" % (self.indim, self.outdim)) if len(permutation) * blocksize != self.indim: raise ValueError( "Permutation has wrong size: should be %i but is %i." % ((self.indim / blocksize), len(permutation))) self.permutation = array(permutation) self.invpermutation = permute(range(len(permutation)), permutation) self.blocksize = blocksize
def __init__(self, inmod, outmod, name=None, inSliceFrom=0, inSliceTo=None, outSliceFrom=0, outSliceTo=None): if inSliceTo is None: inSliceTo = inmod.outdim size = inSliceTo - inSliceFrom # FIXME: call `super()` with named kwargs so that cooperative inhertiance will work, otherwise... # >>> isinstance(LinearConnection, Connection) # False # >>> isinstance(LinearConnection, ParameterContainer) # False Connection.__init__(self, inmod, outmod, name, inSliceFrom, inSliceTo, outSliceFrom, outSliceTo) ParameterContainer.__init__(self, size)
def __init__(self, dx, dy, *args, **kwargs): Connection.__init__(self, *args, **kwargs) self.dx = dx self.dy = dy ParameterContainer.__init__(self, 4 * self.outdim) for i in xrange(0, self.outdim): self.params[2 + i * 4] = dx / 6.0 self.params[3 + i * 4] = dx / 4.0 self.xx = numpy.repeat([numpy.arange(0, self.dx, 1)], self.dy, axis=0).T self.yy = numpy.repeat([numpy.arange(0, self.dy, 1)], self.dx, axis=0) assert self.indim == self.dx * self.dy, "Indim (%i) does not equal dx * dy (%i %i)" % ( self.indim, self.dx, self.dy, )
def __init__(self, inmod, outmod, name=None, inSliceFrom=0, inSliceTo=None, outSliceFrom=0, outSliceTo=None): size = inSliceTo - inSliceFrom Connection.__init__(self, inmod, outmod, name, inSliceFrom, inSliceTo, outSliceFrom, outSliceTo) ParameterContainer.__init__(self, size)
def __init__(self, *args, **kwargs): Connection.__init__(self, *args, **kwargs) assert self.indim == self.outdim, \ "Indim (%i) does not equal outdim (%i)" % ( self.indim, self.outdim)
def __init__(self, *args, r=0.1, **kwargs): Connection.__init__(self, *args, **kwargs) ParameterContainer.__init__(self, self.indim * self.outdim) self.r = r self.dropoutMask = np.random.binomial(1, (1 - r), (self.indim))
def __init__(self, inmod, outmod, gain=1.0, **kwargs): Connection.__init__(self, inmod, outmod, **kwargs) self.gain = gain self.setArgs(gain = self.gain)
def __init__(self, mother, *args, **kwargs): Connection.__init__(self, *args, **kwargs) self._replaceParamsByMother(mother)
def __init__(self, *args, **kwargs): Connection.__init__(self, *args, **kwargs)
def __init__(self, inmod, outmod, **kwargs): # 1st inputs are for external connection kwargs['outSliceTo'] = outmod.dim Connection.__init__(self, inmod, outmod, **kwargs)
def __init__(self, *args, **kwargs): Connection.__init__(self, *args, **kwargs) ParameterContainer.__init__(self, self.indim * self.outdim)
def __init__(self, *args, **kwargs): Connection.__init__(self, *args, **kwargs) n = self.outdim # self.indim*self.outdim # connect only 1 input neuron to random output # self.params = np.random.random_integers(0, 1, n) self.params = np.ones(n)
def __init__(self, *args, **kwargs): Connection.__init__(self, *args, **kwargs) ParameterContainer.__init__(self, self.indim*self.outdim)