예제 #1
0
파일: gfnn.py 프로젝트: andyr0id/PyGFNN
    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()
예제 #2
0
 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
예제 #3
0
 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)
예제 #4
0
파일: linear.py 프로젝트: Angeliqe/pybrain
 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)
예제 #5
0
    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
예제 #6
0
    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)
예제 #8
0
    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,
        )
예제 #9
0
 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)
예제 #10
0
 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)
예제 #11
0
파일: dropout.py 프로젝트: godofalb/pybrain
 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))
예제 #12
0
파일: gain.py 프로젝트: andyr0id/PyGFNN
 def __init__(self, inmod, outmod, gain=1.0, **kwargs):
     Connection.__init__(self, inmod, outmod, **kwargs)
     self.gain = gain
     self.setArgs(gain = self.gain)
예제 #13
0
 def __init__(self, mother, *args, **kwargs):
     Connection.__init__(self, *args, **kwargs)
     self._replaceParamsByMother(mother)
예제 #14
0
 def __init__(self, *args, **kwargs):
     Connection.__init__(self, *args, **kwargs)
예제 #15
0
파일: gfnn.py 프로젝트: andyr0id/PyGFNN
 def __init__(self, inmod, outmod, **kwargs):
     # 1st inputs are for external connection
     kwargs['outSliceTo'] = outmod.dim
     Connection.__init__(self, inmod, outmod, **kwargs)
예제 #16
0
 def __init__(self, *args, **kwargs):
     Connection.__init__(self, *args, **kwargs)
예제 #17
0
 def __init__(self, *args, **kwargs):
     Connection.__init__(self, *args, **kwargs)
     ParameterContainer.__init__(self, self.indim * self.outdim)
예제 #18
0
 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)
예제 #19
0
 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)
예제 #20
0
 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)
예제 #21
0
파일: shared.py 프로젝트: Angeliqe/pybrain
 def __init__(self, mother, *args, **kwargs):
     Connection.__init__(self, *args, **kwargs)
     self._replaceParamsByMother(mother)
예제 #22
0
파일: full.py 프로젝트: Boblogic07/pybrain
 def __init__(self, *args, **kwargs):
     Connection.__init__(self, *args, **kwargs)
     ParameterContainer.__init__(self, self.indim*self.outdim)