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

Python parametercontainer.ParameterContainer类代码示例

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

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



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

示例1: __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:DanSGraham,项目名称:code,代码行数:26,代码来源:lstm.py


示例2: __init__

    def __init__(self, dim, sigma=0.0):
        Explorer.__init__(self, dim, dim)
        self.dim = dim

        # initialize parameters to sigma
        ParameterContainer.__init__(self, dim, stdParams=0)
        self.sigma = [sigma] * dim
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:7,代码来源:normal.py


示例3: _setInitEvaluable

 def _setInitEvaluable(self, evaluable):
     if evaluable is None:
         # if there is no initial point specified, we start at one that's sampled 
         # normally around the origin.
         if self.numParameters is not None:
             evaluable = randn(self.numParameters)
         else:
             raise ValueError('Could not determine the dimensionality of the evaluator. '+\
                              'Please provide an initial search point.')   
     if isinstance(evaluable, list):
         evaluable = array(evaluable)
     
     # If the evaluable is provided as a list of numbers or as an array,
     # we wrap it into a ParameterContainer.
     if isinstance(evaluable, ndarray):            
         pc = ParameterContainer(len(evaluable))
         pc._setParameters(evaluable)
         self._wasWrapped = True
         evaluable = pc
     self._initEvaluable = evaluable
     if isinstance(self._initEvaluable, ParameterContainer):
         if self.numParameters is None:            
             self.numParameters = len(self._initEvaluable)
         elif self.numParameters != len(self._initEvaluable):
             raise ValueError("Parameter dimension mismatch: evaluator expects "+str(self.numParameters)\
                              +" but the evaluable has "+str(len(self._initEvaluable))+".")
开发者ID:PatrickHunter,项目名称:pybrain,代码行数:26,代码来源:optimizer.py


示例4: _setParameters

 def _setParameters(self, p, owner = None):
     ParameterContainer._setParameters(self, p, owner)
     nrNeurons = self.outdim
     first, second = 0, 0
     first, second = second, second + indim*nrNeurons
     self.ingateConns = self.params[first:second]
     first, second = second, second + indim*nrNeurons
     self.forgetgateConns = self.params[first:second]
     first, second = second, second + indim*nrNeurons
     self.cellConns = self.params[first:second]
     first, second = second, second + indim*nrNeurons
     self.outgateConns = self.params[first:second]
     first, second = second, second + nrNeurons*nrNeurons
     self.ingateRecConns = self.params[first:second]
     first, second = second, second + nrNeurons*nrNeurons
     self.forgetgateRecConns = self.params[first:second]
     first, second = second, second + nrNeurons*nrNeurons
     self.cellRecConns = self.params[first:second]
     first, second = second, second + nrNeurons*nrNeurons
     self.outgateRecConns = self.params[first:second]
     if self.peep:
         first, second = second, second + nrNeurons
         self.ingatePeepWeights = self.params[first:second]
         first, second = second, second + nrNeurons
         self.forgetgatePeepWeights = self.params[first:second]
         first, second = second, second + nrNeurons
         self.outgatePeepWeights = self.params[first:second]
开发者ID:HKou,项目名称:pybrain,代码行数:27,代码来源:lstmrtrlblock.py


示例5: _setDerivatives

 def _setDerivatives(self, d, owner = None):
     ParameterContainer._setDerivatives(self, d, owner)
     nrNeurons = self.outdim
     first, second = 0, 0
     first, second = second, second + indim*nrNeurons
     self.ingateConnDerivs = self.derivs[first:second]
     first, second = second, second + indim*nrNeurons
     self.forgetgateConnDerivs = self.derivs[first:second]
     first, second = second, second + indim*nrNeurons
     self.cellConnDerivs = self.derivs[first:second]
     first, second = second, second + indim*nrNeurons
     self.outgateConnDerivs = self.derivs[first:second]
     first, second = second, second + nrNeurons*nrNeurons
     self.ingateRecConnDerivs = self.derivs[first:second]
     first, second = second, second + nrNeurons*nrNeurons
     self.forgetgateRecConnDerivs = self.derivs[first:second]
     first, second = second, second + nrNeurons*nrNeurons
     self.cellRecConnDerivs = self.derivs[first:second]
     first, second = second, second + nrNeurons*nrNeurons
     self.outgateRecConnDerivs = self.derivs[first:second]
     if self.peep:
         first, second = second, second + nrNeurons
         self.ingatePeepDerivs = self.derivs[first:second]
         first, second = second, second + nrNeurons
         self.forgetgatePeepDerivs = self.derivs[first:second]
         first, second = second, second + nrNeurons
         self.outgatePeepDerivs = self.derivs[first:second]
开发者ID:HKou,项目名称:pybrain,代码行数:27,代码来源:lstmrtrlblock.py


示例6: __init__

 def __init__(self, dim, name=None):
     NeuronLayer.__init__(self, dim, name)
     # initialize sigmas to 0
     ParameterContainer.__init__(self, dim, stdParams=0)
     # if autoalpha is set to True, alpha_sigma = alpha_mu = alpha*sigma^2
     self.autoalpha = False
     self.enabled = True
开发者ID:icoz,项目名称:pybrain,代码行数:7,代码来源:gaussianlayer.py


示例7: _setDerivatives

 def _setDerivatives(self, d, owner=None):
     """ put slices of this array back into the modules """
     ParameterContainer._setDerivatives(self, d, owner)
     index = 0
     for x in self._containerIterator():
         x._setDerivatives(self.derivs[index:index + x.paramdim], self)
         index += x.paramdim
开发者ID:fh-wedel,项目名称:pybrain,代码行数:7,代码来源:network.py


示例8: __init__

 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)
开发者ID:Angeliqe,项目名称:pybrain,代码行数:8,代码来源:linear.py


示例9: _setDerivatives

 def _setDerivatives(self, d, owner=None):
     ParameterContainer._setDerivatives(self, d, owner)
     size = self.dim
     self.ingatePeepDerivs = self.derivs[:size]
     self.forgetgatePeepDerivs = \
         self.derivs[size:size * (1 + self.dimensions)]
     self.outgatePeepDerivs = \
         self.derivs[size * (1 + self.dimensions):]        
开发者ID:HKou,项目名称:pybrain,代码行数:8,代码来源:mdlstm.py


示例10: __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


示例11: __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


示例12: __init__

    def __init__(self, statedim, actiondim, sigma= -2.):
        Explorer.__init__(self, actiondim, actiondim)
        self.statedim = statedim
        self.actiondim = actiondim

        # initialize parameters to sigma
        ParameterContainer.__init__(self, actiondim, stdParams=0)
        self.sigma = [sigma] * actiondim

        # exploration matrix (linear function)
        self.explmatrix = random.normal(0., expln(self.sigma), (statedim, actiondim))

        # store last state
        self.state = None
开发者ID:Boblogic07,项目名称:pybrain,代码行数:14,代码来源:sde.py


示例13: __init__

    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,
        )
开发者ID:ioam,项目名称:svn-history,代码行数:17,代码来源:pybrainstuff.py


示例14: 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


示例15: __init__

 def __init__(self, name=None, **args):
     ParameterContainer.__init__(self, **args)
     self.name = name
     # Due to the necessity of regular testing for membership, modules are
     # stored in a set.
     self.modules = set()
     self.modulesSorted = []
     # The connections are stored in a dictionary: the key is the module
     # where the connection leaves from, the value is a list of the
     # corresponding connections.
     self.connections = {}
     self.inmodules = []
     self.outmodules = []
     # Special treatment of weight-shared connections.
     self.motherconnections = []
     # This flag is used to make sure that the modules are reordered when
     # new connections are added.
     self.sorted = False
开发者ID:fh-wedel,项目名称:pybrain,代码行数:18,代码来源:network.py


示例16: __init__

    def __init__(self, dim, module, name=None, onesigma=True):
        NeuronLayer.__init__(self, dim, name)
        self.exploration = zeros(dim, float)
        self.state = None
        self.onesigma = onesigma

        if self.onesigma:
            # one single parameter: sigma
            ParameterContainer.__init__(self, 1)
        else:
            # sigmas for all parameters in the exploration module
            ParameterContainer.__init__(self, module.paramdim)

        # a module for the exploration
        assert module.outdim == dim, "Passed module does not have right dimension"
        self.module = module
        self.autoalpha = False
        self.enabled = True
开发者ID:avain,项目名称:pybrain,代码行数:18,代码来源:statedependentlayer.py


示例17: __init__

 def __init__(self, indim, outdim, peepholes = False, name = None):
     nrNeurons = outdim
     self.peep = peepholes
     # internal buffers:
     self.ingate = zeros((0,nrNeurons))
     self.outgate = zeros((0,nrNeurons))
     self.forgetgate = zeros((0,nrNeurons))
     self.cell = zeros((0,nrNeurons))
     self.ingatex = zeros((0,nrNeurons))
     self.outgatex = zeros((0,nrNeurons))
     self.forgetgatex = zeros((0,nrNeurons))
     self.cellx = zeros((0,nrNeurons))
     self.state = zeros((0,nrNeurons))
     self.ingateError = zeros((0,nrNeurons))
     self.outgateError = zeros((0,nrNeurons))
     self.forgetgateError = zeros((0,nrNeurons))
     self.stateError = zeros((0,nrNeurons))
     self.Sin = zeros((0,indim*nrNeurons))
     self.Sforget = zeros((0,indim*nrNeurons))
     self.Scell = zeros((0,indim*nrNeurons))
     self.SinRec = zeros((0,nrNeurons*nrNeurons))
     self.SforgetRec = zeros((0,nrNeurons*nrNeurons))
     self.ScellRec = zeros((0,nrNeurons*nrNeurons))
     
     Module.__init__(self, indim, outdim, name)
     if self.peep:
         ParameterContainer.__init__(self, nrNeurons*3 + (4*indim+nrNeurons)*nrNeurons)
         self.Sin_peep = zeros((0,nrNeurons))
         self.Sforget_peep = zeros((0,nrNeurons))
         self.Scell_peep = zeros((0,nrNeurons))
     else:
         ParameterContainer.__init__(self, (4*indim+nrNeurons)*nrNeurons)
     self._setParameters(self.params)
     self._setDerivatives(self.derivs)
         
     # transfer functions and their derivatives
     self.f = sigmoid
     self.fprime = sigmoidPrime
     self.g = lambda x: 2*tanh(x)
     self.gprime = lambda x: 2*tanhPrime(x)
     self.h = self.g
     self.hprime = self.gprime
开发者ID:HKou,项目名称:pybrain,代码行数:42,代码来源:lstmrtrlblock.py


示例18: __init__

 def __init__(self, dim, peepholes = False, name = None):
     self.setArgs(dim = dim, peepholes = peepholes)
     
     # Internal buffers:
     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:HKou,项目名称:pybrain,代码行数:23,代码来源:lstm.py


示例19: __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:anurive,项目名称:pybrain,代码行数:24,代码来源:mdlstm.py


示例20: list

task.N = 10
# for the simple evolvable class defined below
evoEval = lambda e: e.x


# starting points
# ----------------------
xlist1 = [2.]
xlist2 = [0.2, 10]
xlist100 = list(range(12, 112))

xa1 = array(xlist1)
xa2 = array(xlist2)
xa100 = array(xlist100)

pc1 = ParameterContainer(1)
pc2 = ParameterContainer(2)
pc100 = ParameterContainer(100)
pc1._setParameters(xa1)
pc2._setParameters(xa2)
pc100._setParameters(xa100)

# for the task object, we need a module
nnet = buildNetwork(task.outdim, 2, task.indim)

# a mimimalistic Evolvable subclass that is not (like usual) a ParameterContainer
class SimpleEvo(Evolvable):
    def __init__(self, x): self.x = x
    def mutate(self):      self.x += random() - 0.3
    def copy(self):        return SimpleEvo(self.x)
    def randomize(self):   self.x = 10 * random() - 2
开发者ID:Boblogic07,项目名称:pybrain,代码行数:31,代码来源:optimizationtest.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python supervised.BackpropTrainer类代码示例发布时间:2022-05-25
下一篇:
Python feedforward.FeedForwardNetwork类代码示例发布时间: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