• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python module.Module类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pybrain.structure.modules.module.Module的典型用法代码示例。如果您正苦于以下问题:Python Module类的具体用法?Python Module怎么用?Python Module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Module类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    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,代码行数:25,代码来源:kohonen.py


示例2: __init__

 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,代码行数:26,代码来源:lstm.py


示例3: __init__

    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,代码行数:26,代码来源:gfnn.py


示例4: __init__

    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,代码行数:25,代码来源:networkwrapper.py


示例5: __init__

    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,代码行数:9,代码来源:table.py


示例6: __init__

    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,代码行数:13,代码来源:boltzmann.py


示例7: activate

 def activate(self, state, action):
     """ The super class commonly ignores the state and simply passes the
         action through the module. implement _forwardImplementation()
         in subclasses.
     """
     self.state = state
     return Module.activate(self, action)
开发者ID:Boblogic07,项目名称:pybrain,代码行数:7,代码来源:sde.py


示例8: sortModules

    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,代码行数:45,代码来源:network.py


示例9: __init__

 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,代码行数:24,代码来源:mdlstm.py


示例10: __init__

    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,代码行数:36,代码来源:evolinonetwork.py


示例11: __init__

    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,代码行数:75,代码来源:mdrnnlayer.py


示例12: __init__

 def __init__(self, dim, name=None):
     Module.__init__(self, dim, dim * 2, name)
     self.setArgs(dim=dim, name=self.name)
开发者ID:davidmiller,项目名称:pybrain,代码行数:3,代码来源:gate.py


示例13: reset

 def reset(self):
     """Reset all component modules and the network."""
     Module.reset(self)
     for m in self.modules:
         m.reset()
开发者ID:fh-wedel,项目名称:pybrain,代码行数:5,代码来源:network.py


示例14: __init__

 def __init__(self, name=None):
     Module.__init__(self, 0, 1, name = name)
开发者ID:Angeliqe,项目名称:pybrain,代码行数:2,代码来源:biasunit.py


示例15: __init__

 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,代码行数:4,代码来源:neuronlayer.py


示例16: __init__

 def __init__(self, dim, name=None):
     Module.__init__(self, dim, dim * 2, name)
开发者ID:HKou,项目名称:pybrain,代码行数:2,代码来源:gate.py



注:本文中的pybrain.structure.modules.module.Module类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python feedforward.FeedForwardNetwork类代码示例发布时间:2022-05-25
下一篇:
Python structure.RecurrentNetwork类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap