當前位置: 首頁>>代碼示例>>Python>>正文


Python Module.__init__方法代碼示例

本文整理匯總了Python中pybrain.structure.modules.module.Module.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python Module.__init__方法的具體用法?Python Module.__init__怎麽用?Python Module.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pybrain.structure.modules.module.Module的用法示例。


在下文中一共展示了Module.__init__方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
    def __init__(self, indim, outdim, hiddim=6):
        Module.__init__(self, indim, outdim)

        self._network = Network()
        self._in_layer = LinearLayer(indim + outdim)
        self._hid_layer = LSTMLayer(hiddim)
        self._out_layer = LinearLayer(outdim)
        self._bias = BiasUnit()

        self._network.addInputModule(self._in_layer)
        self._network.addModule(self._hid_layer)
        self._network.addModule(self._bias)
        self._network.addOutputModule(self._out_layer)


        self._hid_to_out_connection = FullConnection(self._hid_layer , self._out_layer)
        self._in_to_hid_connection = FullConnection(self._in_layer  , self._hid_layer)
        self._network.addConnection(self._hid_to_out_connection)
        self._network.addConnection(self._in_to_hid_connection)
        self._network.addConnection(FullConnection(self._bias, self._hid_layer))

        self._network.sortModules()

        self.time = self._network.time
        self.backprojectionFactor = 0.01
開發者ID:ZachPhillipsGary,項目名稱:CS200-NLP-ANNsProject,代碼行數:27,代碼來源:networkwrapper.py

示例2: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
    def __init__(self, dim, nNeurons, name=None, outputFullMap=False):
        if outputFullMap:
            outdim = nNeurons ** 2
        else:
            outdim = 2
        Module.__init__(self, dim, outdim, name)

        # switch modes
        self.outputFullMap = outputFullMap

        # create neurons
        self.neurons = random.random((nNeurons, nNeurons, dim))
        self.difference = zeros(self.neurons.shape)
        self.winner = zeros(2)
        self.nInput = dim
        self.nNeurons = nNeurons
        self.neighbours = nNeurons
        self.learningrate = 0.01
        self.neighbourdecay = 0.9999

        # distance matrix
        distx, disty = mgrid[0:self.nNeurons, 0:self.nNeurons]
        self.distmatrix = zeros((self.nNeurons, self.nNeurons, 2))
        self.distmatrix[:, :, 0] = distx
        self.distmatrix[:, :, 1] = disty
開發者ID:Angeliqe,項目名稱:pybrain,代碼行數:27,代碼來源:kohonen.py

示例3: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
 def __init__(self, dim, peepholes = False, name = None):
     """ 
     :arg dim: number of cells
     :key peepholes: enable peephole connections (from state to gates)? """
     self.setArgs(dim = dim, peepholes = peepholes)
     
     # Internal buffers, created dynamically:
     self.bufferlist = [
         ('ingate', dim),
         ('outgate', dim),
         ('forgetgate', dim),
         ('ingatex', dim),
         ('outgatex', dim),
         ('forgetgatex', dim),
         ('state', dim),
         ('ingateError', dim),
         ('outgateError', dim),
         ('forgetgateError', dim),
         ('stateError', dim),
     ]
     
     Module.__init__(self, 4*dim, dim, name)
     if self.peepholes:
         ParameterContainer.__init__(self, dim*3)
         self._setParameters(self.params)
         self._setDerivatives(self.derivs)
開發者ID:pachkun,項目名稱:Machine_learning,代碼行數:28,代碼來源:lstm.py

示例4: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
    def __init__(self, dim, oscParams=None, freqDist=None, name=None):
        """Create a layer with dim number of units."""
        Module.__init__(self, dim*2, dim, name=name)

        if oscParams is None:
            oscParams = { 'a': 0, 'b1': -1, 'b2': -1, 'd1': 0, 'd2': 0, 'e': 1 }

        if freqDist is None:
            freqDist = {
                'fspac': 'log',
                'min': .5,
                'max': 8
            }
        freqDist['min_r'] = freqDist['min'] * TWO_PI
        freqDist['max_r'] = freqDist['max'] * TWO_PI

        self.conns = []

        self.setArgs(dim=dim, oscParams=oscParams, freqDist=freqDist)

        self.setFreqs(freqDist)

        self.z0 = np.zeros(dim, dtype=np.complex64)
        self._ranomiseOscs()
        self.kSteps = np.zeros((4, dim), dtype=np.complex64)
        self.t = np.float32(0.)
開發者ID:andyr0id,項目名稱:PyGFNN,代碼行數:28,代碼來源:gfnn.py

示例5: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
    def __init__(self, numRows, numColumns, name=None):
        """ initialize with the number of rows and columns. the table
            values are all set to zero.
        """
        Module.__init__(self, 2, 1, name)
        ParameterContainer.__init__(self, numRows*numColumns)

        self.numRows = numRows
        self.numColumns = numColumns
開發者ID:DanSGraham,項目名稱:code,代碼行數:11,代碼來源:table.py

示例6: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
    def __init__(self, actionnum, T, theta, **args):
        self.feadim = len(theta)
        Module.__init__(self, self.feadim * actionnum, 1, **args)
        ParameterContainer.__init__(self, self.feadim)
        self.T = T
        self.g = None
        self.bf = None

        # feadimx1 vector.
        self.theta = theta
        self.actionnum = actionnum

        self.cachedActionProb = None
開發者ID:hbhzwj,項目名稱:librl,代碼行數:15,代碼來源:boltzmann.py

示例7: sortModules

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
    def sortModules(self):
        """Prepare the network for activation by sorting the internal
        datastructure.

        Needs to be called before activation."""
        if self.sorted:
            return
        # Sort the modules.
        self._topologicalSort()
        # Sort the connections by name.
        for m in self.modules:
            self.connections[m].sort(key=lambda x: x.name)
        self.motherconnections.sort(key=lambda x: x.name)

        # Create a single array with all parameters.
        tmp = [pc.params for pc in self._containerIterator()]
        total_size = sum(scipy.size(i) for i in tmp)
        ParameterContainer.__init__(self, total_size)
        if total_size > 0:
            self.params[:] = scipy.concatenate(tmp)
            self._setParameters(self.params)

            # Create a single array with all derivatives.
            tmp = [pc.derivs for pc in self._containerIterator()]
            self.resetDerivatives()
            self.derivs[:] = scipy.concatenate(tmp)
            self._setDerivatives(self.derivs)

        # TODO: make this a property; indim and outdim are invalid before
        # .sortModules is called!
        # Determine the input and output dimensions of the network.
        self.indim = sum(m.indim for m in self.inmodules)
        self.outdim = sum(m.outdim for m in self.outmodules)

        self.indim = 0
        for m in self.inmodules:
            self.indim += m.indim
        self.outdim = 0
        for m in self.outmodules:
            self.outdim += m.outdim

        # Initialize the network buffers.
        self.bufferlist = []
        Module.__init__(self, self.indim, self.outdim, name=self.name)
        self.sorted = True
開發者ID:fh-wedel,項目名稱:pybrain,代碼行數:47,代碼來源:network.py

示例8: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
    def __init__(self, outdim, hiddim=15):
        """ Create an EvolinoNetwork with for sequences of dimension outdim and
        hiddim dimension of the RNN Layer."""
        indim = 0
        Module.__init__(self, indim, outdim)

        self._network = RecurrentNetwork()
        self._in_layer = LinearLayer(indim + outdim)
        self._hid_layer = LSTMLayer(hiddim)
        self._out_layer = LinearLayer(outdim)
        self._bias = BiasUnit()

        self._network.addInputModule(self._in_layer)
        self._network.addModule(self._hid_layer)
        self._network.addModule(self._bias)
        self._network.addOutputModule(self._out_layer)

        self._in_to_hid_connection = FullConnection(self._in_layer,
                                                    self._hid_layer)
        self._bias_to_hid_connection = FullConnection(self._bias,
                                                      self._hid_layer)
        self._hid_to_out_connection = FullConnection(self._hid_layer,
                                                     self._out_layer)
        self._network.addConnection(self._in_to_hid_connection)
        self._network.addConnection(self._bias_to_hid_connection)
        self._network.addConnection(self._hid_to_out_connection)

        self._recurrent_connection = FullConnection(self._hid_layer,
                                                    self._hid_layer)
        self._network.addRecurrentConnection(self._recurrent_connection)

        self._network.sortModules()
        self._network.reset()

        self.offset = self._network.offset
        self.backprojectionFactor = 0.01
開發者ID:DanSGraham,項目名稱:code,代碼行數:38,代碼來源:evolinonetwork.py

示例9: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
 def __init__(self, dim, dimensions=1, peepholes=False, name=None):
     self.setArgs(dim=dim, peepholes=peepholes, dimensions=dimensions)
     
     # Internal buffers:
     self.bufferlist = [
         ('ingate', dim),
         ('outgate', dim),
         ('forgetgate', dim * dimensions),
         ('ingatex', dim),
         ('outgatex', dim),
         ('forgetgatex', dim * dimensions),
         ('state', dim),
         ('ingateError', dim),
         ('outgateError', dim),
         ('forgetgateError', dim * dimensions),
         ('stateError', dim),
     ]
     
     Module.__init__(self, (3 + 2 * dimensions) * dim, dim * 2, name)
     
     if self.peepholes:
         ParameterContainer.__init__(self, dim * (2 + dimensions))
         self._setParameters(self.params)
         self._setDerivatives(self.derivs)        
開發者ID:pachkun,項目名稱:Machine_learning,代碼行數:26,代碼來源:mdlstm.py

示例10: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
    def __init__(self, timedim, shape,
                 hiddendim, outsize, blockshape=None, name=None):
        """Initialize an MdrnnLayer.

        The dimensionality of the sequence - for example 2 for a
        picture or 3 for a video - is given by `timedim`, while the sidelengths
        along each dimension are given by the tuple `shape`.

        The layer will have `hiddendim` hidden units per swiping direction. The
        number of swiping directions is given by 2**timedim, which corresponds
        to one swipe from each corner to its opposing corner and back.

        To indicate how many outputs per timesteps are used, you have to specify
        `outsize`.

        In order to treat blocks of the input and not single voxels, you can
        also specify `blockshape`. For example the layer will then feed (2, 2)
        chunks into the network at each timestep which correspond to the (2, 2)
        rectangles that the input can be split into.
        """
        self.timedim = timedim
        self.shape = shape
        blockshape = tuple([1] * timedim) if blockshape is None else blockshape
        self.blockshape = shape
        self.hiddendim = hiddendim
        self.outsize = outsize
        self.indim = reduce(operator.mul, shape, 1)
        self.blocksize = reduce(operator.mul, blockshape, 1)
        self.sequenceLength = self.indim / self.blocksize
        self.outdim = self.sequenceLength * self.outsize

        self.bufferlist = [('cellStates', self.sequenceLength * self.hiddendim)]

        Module.__init__(self, self.indim, self.outdim, name=name)

        # Amount of parameters that are required for the input to the hidden
        self.num_in_params = self.blocksize * self.hiddendim * (3 + self.timedim)

        # Amount of parameters that are needed for the recurrent connections.
        # There is one of the parameter for every time dimension.
        self.num_rec_params = outsize * hiddendim * (3 + self.timedim)

        # Amount of parameters that are needed for the output.
        self.num_out_params = outsize * hiddendim

        # Amount of parameters that are needed from the bias to the hidden and
        # the output
        self.num_bias_params = (3 + self.timedim) * self.hiddendim + self.outsize

        # Total list of parameters.
        self.num_params = sum((self.num_in_params,
                               self.timedim * self.num_rec_params,
                               self.num_out_params,
                               self.num_bias_params))

        ParameterContainer.__init__(self, self.num_params)

        # Some layers for internal use.
        self.hiddenlayer = MDLSTMLayer(self.hiddendim, self.timedim)

        # Every point in the sequence has timedim predecessors.
        self.predlayers = [LinearLayer(self.outsize) for _ in range(timedim)]

        # We need a single layer to hold the input. We will swipe a connection
        # over the corrects part of it, in order to feed the correct input in.
        self.inlayer = LinearLayer(self.indim)
        # Make some layers the same to save memory.
        self.inlayer.inputbuffer = self.inlayer.outputbuffer = self.inputbuffer

        # In order to allocate not too much memory, we just set the size of the
        # layer to 1 and correct it afterwards.
        self.outlayer = LinearLayer(self.outdim)
        self.outlayer.inputbuffer = self.outlayer.outputbuffer = self.outputbuffer

        self.bias = BiasUnit()
開發者ID:fh-wedel,項目名稱:pybrain,代碼行數:77,代碼來源:mdrnnlayer.py

示例11: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
 def __init__(self, dim, name=None):
     Module.__init__(self, dim, dim * 2, name)
     self.setArgs(dim=dim, name=self.name)
開發者ID:davidmiller,項目名稱:pybrain,代碼行數:5,代碼來源:gate.py

示例12: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
 def __init__(self, dim, name=None):
     """Create a layer with dim number of units."""
     Module.__init__(self, dim, dim, name=name)
     self.setArgs(dim=dim)
開發者ID:pachkun,項目名稱:Machine_learning,代碼行數:6,代碼來源:neuronlayer.py

示例13: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
 def __init__(self, name=None):
     Module.__init__(self, 0, 1, name = name)
開發者ID:Angeliqe,項目名稱:pybrain,代碼行數:4,代碼來源:biasunit.py

示例14: __init__

# 需要導入模塊: from pybrain.structure.modules.module import Module [as 別名]
# 或者: from pybrain.structure.modules.module.Module import __init__ [as 別名]
 def __init__(self, dim, name=None):
     Module.__init__(self, dim, dim * 2, name)
開發者ID:HKou,項目名稱:pybrain,代碼行數:4,代碼來源:gate.py


注:本文中的pybrain.structure.modules.module.Module.__init__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。