code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def randomDeterministic(Ts): """ Pick a random deterministic action for each state. """ numA = len(Ts) dim = len(Ts[0]) choices = (rand(dim) * numA).astype(int) policy = zeros((dim, numA)) for si, a in choices: policy[si, a] = 1 return policy, collapsedTransitions(Ts, policy)
Pick a random deterministic action for each state.
randomDeterministic
python
pybrain/pybrain
pybrain/rl/learners/modelbased/policyiteration.py
https://github.com/pybrain/pybrain/blob/master/pybrain/rl/learners/modelbased/policyiteration.py
BSD-3-Clause
def policyIteration(Ts, R, discountFactor, VEvaluator=None, initpolicy=None, maxIters=20): """ Given transition matrices (one per action), produce the optimal policy, using the policy iteration algorithm. A custom function that maps policies to value functions can be provided. """ if initpolicy is ...
Given transition matrices (one per action), produce the optimal policy, using the policy iteration algorithm. A custom function that maps policies to value functions can be provided.
policyIteration
python
pybrain/pybrain
pybrain/rl/learners/modelbased/policyiteration.py
https://github.com/pybrain/pybrain/blob/master/pybrain/rl/learners/modelbased/policyiteration.py
BSD-3-Clause
def getMaxAction(self, state): """ Return the action with the maximal value for the given state. """ values = self.params.reshape(self.numRows, self.numColumns)[int(state), :].flatten() action = where(values == max(values))[0] action = choice(action) return action
Return the action with the maximal value for the given state.
getMaxAction
python
pybrain/pybrain
pybrain/rl/learners/valuebased/interface.py
https://github.com/pybrain/pybrain/blob/master/pybrain/rl/learners/valuebased/interface.py
BSD-3-Clause
def _updateWeights(self, state, action, reward, next_state): """ state and next_state are vectors, action is an integer. """ td_error = reward + self.rewardDiscount * max(dot(self._theta, next_state)) - dot(self._theta[action], state) #print(action, reward, td_error,self._theta[action], state, ...
state and next_state are vectors, action is an integer.
_updateWeights
python
pybrain/pybrain
pybrain/rl/learners/valuebased/linearfa.py
https://github.com/pybrain/pybrain/blob/master/pybrain/rl/learners/valuebased/linearfa.py
BSD-3-Clause
def _updateWeights(self, state, action, reward, next_state, learned_policy=None): """ Policy is a function that returns a probability vector for all actions, given the current state(-features). """ if learned_policy is None: learned_policy = self._greedyPolicy self....
Policy is a function that returns a probability vector for all actions, given the current state(-features).
_updateWeights
python
pybrain/pybrain
pybrain/rl/learners/valuebased/linearfa.py
https://github.com/pybrain/pybrain/blob/master/pybrain/rl/learners/valuebased/linearfa.py
BSD-3-Clause
def learn(self): """ Learn on the current dataset, either for many timesteps and even episodes (batchMode = True) or for a single timestep (batchMode = False). Batch mode is possible, because Q-Learning is an off-policy method. In batchMode, the algorithm goes th...
Learn on the current dataset, either for many timesteps and even episodes (batchMode = True) or for a single timestep (batchMode = False). Batch mode is possible, because Q-Learning is an off-policy method. In batchMode, the algorithm goes through all the samples in the...
learn
python
pybrain/pybrain
pybrain/rl/learners/valuebased/q.py
https://github.com/pybrain/pybrain/blob/master/pybrain/rl/learners/valuebased/q.py
BSD-3-Clause
def _setModule(self, module): """ Set module and tell explorer about the module. """ if self.explorer: self.explorer.module = module self._module = module
Set module and tell explorer about the module.
_setModule
python
pybrain/pybrain
pybrain/rl/learners/valuebased/valuebased.py
https://github.com/pybrain/pybrain/blob/master/pybrain/rl/learners/valuebased/valuebased.py
BSD-3-Clause
def _setExplorer(self, explorer): """ Set explorer and tell it the module, if already available. """ self._explorer = explorer if self.module: self._explorer.module = self.module
Set explorer and tell it the module, if already available.
_setExplorer
python
pybrain/pybrain
pybrain/rl/learners/valuebased/valuebased.py
https://github.com/pybrain/pybrain/blob/master/pybrain/rl/learners/valuebased/valuebased.py
BSD-3-Clause
def __init__(self, constructor, dimensions, name = None, baserename = False): """:arg constructor: a constructor method that returns a module :arg dimensions: tuple of dimensions. """ self.dims = dimensions if name != None: self.name = name # a dict where the tuple of...
:arg constructor: a constructor method that returns a module :arg dimensions: tuple of dimensions.
__init__
python
pybrain/pybrain
pybrain/structure/modulemesh.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modulemesh.py
BSD-3-Clause
def constructWithLayers(layerclass, layersize, dimensions, name = None): """ create the mesh using constructors that build layers of a specified size and class. """ c = lambda: layerclass(layersize) return ModuleMesh(c, dimensions, name)
create the mesh using constructors that build layers of a specified size and class.
constructWithLayers
python
pybrain/pybrain
pybrain/structure/modulemesh.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modulemesh.py
BSD-3-Clause
def viewOnFlatLayer(layer, dimensions, name = None): """ Produces a ModuleMesh that is a mesh-view on a flat module. """ assert max(dimensions) > 1, "At least one dimension needs to be larger than one." def slicer(): nbunits = reduce(lambda x, y: x*y, dimensions, 1) insiz...
Produces a ModuleMesh that is a mesh-view on a flat module.
viewOnFlatLayer
python
pybrain/pybrain
pybrain/structure/modulemesh.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modulemesh.py
BSD-3-Clause
def __init__(self, base, inSliceFrom = 0, inSliceTo = None, outSliceFrom = 0, outSliceTo = None): """ :key base: the base module that is sliced """ if isinstance(base, ModuleSlice): # tolerantly handle the case of a slice of another slice self.base = base.base self.in...
:key base: the base module that is sliced
__init__
python
pybrain/pybrain
pybrain/structure/moduleslice.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/moduleslice.py
BSD-3-Clause
def __init__(self, paramdim = 0, **args): """ initialize all parameters with random values, normally distributed around 0 :key stdParams: standard deviation of the values (default: 1). """ self.setArgs(**args) self.paramdim = paramdim if paramdim > 0: sel...
initialize all parameters with random values, normally distributed around 0 :key stdParams: standard deviation of the values (default: 1).
__init__
python
pybrain/pybrain
pybrain/structure/parametercontainer.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/parametercontainer.py
BSD-3-Clause
def _setDerivatives(self, d, owner = None): """ :key d: an array of numbers of self.paramdim """ assert self.owner == owner assert size(d) == self.paramdim self._derivs = d
:key d: an array of numbers of self.paramdim
_setDerivatives
python
pybrain/pybrain
pybrain/structure/parametercontainer.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/parametercontainer.py
BSD-3-Clause
def resetDerivatives(self): """ :note: this method only sets the values to zero, it does not initialize the array. """ assert self.hasDerivatives self._derivs *= 0
:note: this method only sets the values to zero, it does not initialize the array.
resetDerivatives
python
pybrain/pybrain
pybrain/structure/parametercontainer.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/parametercontainer.py
BSD-3-Clause
def __init__(self, inmod, outmod, name = None, inSliceFrom = 0, inSliceTo = None, outSliceFrom = 0, outSliceTo = None): """ Every connection requires an input and an output module. Optionally, it is possible to define slices on the buffers. :arg inmod: input module :arg...
Every connection requires an input and an output module. Optionally, it is possible to define slices on the buffers. :arg inmod: input module :arg outmod: output module :key inSliceFrom: starting index on the buffer of inmod (default = 0) :key inSliceTo: ending index on...
__init__
python
pybrain/pybrain
pybrain/structure/connections/connection.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/connections/connection.py
BSD-3-Clause
def forward(self, inmodOffset=0, outmodOffset=0): """Propagate the information from the incoming module's output buffer, adding it to the outgoing node's input buffer, and possibly transforming it on the way. For this transformation use inmodOffset as an offset for the inmod and ...
Propagate the information from the incoming module's output buffer, adding it to the outgoing node's input buffer, and possibly transforming it on the way. For this transformation use inmodOffset as an offset for the inmod and outmodOffset as an offset for the outmodules offset.
forward
python
pybrain/pybrain
pybrain/structure/connections/connection.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/connections/connection.py
BSD-3-Clause
def backward(self, inmodOffset=0, outmodOffset=0): """Propagate the error found at the outgoing module, adding it to the incoming module's output-error buffer and doing the inverse transformation of forward propagation. For this transformation use inmodOffset as an offset for the inmod ...
Propagate the error found at the outgoing module, adding it to the incoming module's output-error buffer and doing the inverse transformation of forward propagation. For this transformation use inmodOffset as an offset for the inmod and outmodOffset as an offset for the outmodules offse...
backward
python
pybrain/pybrain
pybrain/structure/connections/connection.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/connections/connection.py
BSD-3-Clause
def __repr__(self): """A simple representation (this should probably be expanded by subclasses). """ params = { 'class': self.__class__.__name__, 'name': self.name, 'inmod': self.inmod.name, 'outmod': self.outmod.name } return "<%(c...
A simple representation (this should probably be expanded by subclasses).
__repr__
python
pybrain/pybrain
pybrain/structure/connections/connection.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/connections/connection.py
BSD-3-Clause
def newSimilarInstance(self): """ Generates a new Evolvable of the same kind.""" res = self.copy() res.randomize() return res
Generates a new Evolvable of the same kind.
newSimilarInstance
python
pybrain/pybrain
pybrain/structure/evolvables/evolvable.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/evolvables/evolvable.py
BSD-3-Clause
def params(self): """ returns an array with (usually) only the unmasked parameters """ if self.returnZeros: return self.pcontainer.params else: x = zeros(self.paramdim) paramcount = 0 for i in range(len(self.maskableParams)): if sel...
returns an array with (usually) only the unmasked parameters
params
python
pybrain/pybrain
pybrain/structure/evolvables/maskedparameters.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/evolvables/maskedparameters.py
BSD-3-Clause
def randomize(self, **args): """ an initial, random mask (with random params) with as many parameters enabled as allowed""" self.mask = zeros(self.pcontainer.paramdim, dtype=bool) onbits = [] for i in range(self.pcontainer.paramdim): if random() > self.maskOnProbabili...
an initial, random mask (with random params) with as many parameters enabled as allowed
randomize
python
pybrain/pybrain
pybrain/structure/evolvables/maskedparameters.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/evolvables/maskedparameters.py
BSD-3-Clause
def topologyMutate(self): """ flips some bits on the mask (but do not exceed the maximum of enabled parameters). """ for i in range(self.pcontainer.paramdim): if random() < self.maskFlipProbability: self.mask[i] = not self.mask[i] tooMany = sum(self.mask) - se...
flips some bits on the mask (but do not exceed the maximum of enabled parameters).
topologyMutate
python
pybrain/pybrain
pybrain/structure/evolvables/maskedparameters.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/evolvables/maskedparameters.py
BSD-3-Clause
def mutate(self): """ add some gaussian noise to all parameters.""" # CHECKME: could this be partly outsourced to the pcontainer directly? for i in range(self.pcontainer.paramdim): self.maskableParams[i] += gauss(0, self.mutationStdev) self._applyMask()
add some gaussian noise to all parameters.
mutate
python
pybrain/pybrain
pybrain/structure/evolvables/maskedparameters.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/evolvables/maskedparameters.py
BSD-3-Clause
def newSimilarInstance(self): """ generate a new Evolvable with the same topology """ res = self.copy() res.randomize() return res
generate a new Evolvable with the same topology
newSimilarInstance
python
pybrain/pybrain
pybrain/structure/evolvables/topology.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/evolvables/topology.py
BSD-3-Clause
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 + out...
Create an EvolinoNetwork with for sequences of dimension outdim and hiddim dimension of the RNN Layer.
__init__
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def washout(self, sequence): """ Force the network to process the sequence instead of the backprojection values. Used for adjusting the RNN's state. Returns the outputs of the RNN that are needed for linear regression.""" assert len(sequence) != 0 assert self.outdim == len(sequen...
Force the network to process the sequence instead of the backprojection values. Used for adjusting the RNN's state. Returns the outputs of the RNN that are needed for linear regression.
washout
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def _activateNetwork(self, input): """ Run the activate method of the underlying network.""" assert len(input) == self._network.indim output = array(self._network.activate(input)) self.offset = self._network.offset return output
Run the activate method of the underlying network.
_activateNetwork
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def extrapolate(self, sequence, length): """ Extrapolate 'sequence' for 'length' steps and return the extrapolated sequence as array. Extrapolating is realized by reseting the network, then washing it out with the supplied sequence, and then generating a sequence.""" self.reset...
Extrapolate 'sequence' for 'length' steps and return the extrapolated sequence as array. Extrapolating is realized by reseting the network, then washing it out with the supplied sequence, and then generating a sequence.
extrapolate
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def generate(self, length): """ Generate a sequence of specified length. Use .reset() and .washout() before.""" generated_sequence = [] #empty(length) for _ in range(length): backprojection = self._getLastOutput() backprojection *= self.backprojectionFactor ...
Generate a sequence of specified length. Use .reset() and .washout() before.
generate
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def _getLastOutput(self): """Return the current output of the linear output layer.""" if self.offset == 0: return zeros(self.outdim) else: return self._out_layer.outputbuffer[self.offset - 1]
Return the current output of the linear output layer.
_getLastOutput
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def _validateGenomeLayer(self, layer): """Validate the type and state of a layer.""" assert isinstance(layer, LSTMLayer) assert not layer.peepholes
Validate the type and state of a layer.
_validateGenomeLayer
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def _getGenomeOfLayer(self, layer): """Return the genome of a single layer.""" self._validateGenomeLayer(layer) connections = self._getInputConnectionsOfLayer(layer) layer_weights = [] # iterate cells of layer for cell_idx in range(layer.outdim): # todo: the...
Return the genome of a single layer.
_getGenomeOfLayer
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def _setGenomeOfLayer(self, layer, weights): """Set the genome of a single layer.""" self._validateGenomeLayer(layer) connections = self._getInputConnectionsOfLayer(layer) # iterate cells of layer for cell_idx in range(layer.outdim): # todo: the evolino paper uses a...
Set the genome of a single layer.
_setGenomeOfLayer
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def setOutputWeightMatrix(self, W): """Set the weight matrix of the linear output layer.""" c = self._hid_to_out_connection c.params[:] = W.flatten()
Set the weight matrix of the linear output layer.
setOutputWeightMatrix
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def getOutputWeightMatrix(self): """Return the weight matrix of the linear output layer.""" c = self._hid_to_out_connection p = c.params return reshape(p, (c.outdim, c.indim))
Return the weight matrix of the linear output layer.
getOutputWeightMatrix
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def _getInputConnectionsOfLayer(self, layer): """Return a list of all input connections for the layer.""" connections = [] all_cons = list(self._network.recurrentConns) all_cons += sum(list(self._network.connections.values()), []) for c in all_cons: if c.outmod is lay...
Return a list of all input connections for the layer.
_getInputConnectionsOfLayer
python
pybrain/pybrain
pybrain/structure/modules/evolinonetwork.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/evolinonetwork.py
BSD-3-Clause
def setSigma(self, sigma): """Wrapper method to set the sigmas (the parameters of the module) to a certain value. """ assert len(sigma) == self.indim self._params *= 0 self._params += sigma
Wrapper method to set the sigmas (the parameters of the module) to a certain value.
setSigma
python
pybrain/pybrain
pybrain/structure/modules/gaussianlayer.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/gaussianlayer.py
BSD-3-Clause
def _forwardImplementation(self, inbuf, outbuf): """ assigns one of the neurons to the input given in inbuf and writes the neuron's coordinates to outbuf. """ # calculate the winner neuron with lowest error (square difference) self.difference = self.neurons - tile(inbuf, (self.nNeuro...
assigns one of the neurons to the input given in inbuf and writes the neuron's coordinates to outbuf.
_forwardImplementation
python
pybrain/pybrain
pybrain/structure/modules/kohonen.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/kohonen.py
BSD-3-Clause
def _backwardImplementation(self, outerr, inerr, outbuf, inbuf): """ trains the kohonen map in unsupervised manner, moving the closest neuron and its neighbours closer to the input pattern. """ # calculate neighbourhood and limit to edge of matrix n = floor(self.neighbours) ...
trains the kohonen map in unsupervised manner, moving the closest neuron and its neighbours closer to the input pattern.
_backwardImplementation
python
pybrain/pybrain
pybrain/structure/modules/kohonen.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/kohonen.py
BSD-3-Clause
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 = [ ...
:arg dim: number of cells :key peepholes: enable peephole connections (from state to gates)?
__init__
python
pybrain/pybrain
pybrain/structure/modules/lstm.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/lstm.py
BSD-3-Clause
def meatSlice(self): """Return a moduleslice that wraps the meat part of the layer.""" return ModuleSlice(self, inSliceTo=self.dim * (3 + self.dimensions), outSliceTo=self.dim)
Return a moduleslice that wraps the meat part of the layer.
meatSlice
python
pybrain/pybrain
pybrain/structure/modules/mdlstm.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/mdlstm.py
BSD-3-Clause
def stateSlice(self): """Return a moduleslice that wraps the state transfer part of the layer. """ return ModuleSlice(self, inSliceFrom=self.dim * (3 + self.dimensions), outSliceFrom=self.dim)
Return a moduleslice that wraps the state transfer part of the layer.
stateSlice
python
pybrain/pybrain
pybrain/structure/modules/mdlstm.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/mdlstm.py
BSD-3-Clause
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 giv...
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 ...
__init__
python
pybrain/pybrain
pybrain/structure/modules/mdrnnlayer.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/mdrnnlayer.py
BSD-3-Clause
def __init__(self, dim, name = None, mix=5): """Initialize mixture density layer - mix gives the number of Gaussians to mix, dim is the dimension of the target(!) vector.""" nUnits = mix * (dim + 2) # mean vec + stddev and mixing coeff NeuronLayer.__init__(self, nUnits, name) se...
Initialize mixture density layer - mix gives the number of Gaussians to mix, dim is the dimension of the target(!) vector.
__init__
python
pybrain/pybrain
pybrain/structure/modules/mixturedensity.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/mixturedensity.py
BSD-3-Clause
def _forwardImplementation(self, inbuf, outbuf): """Calculate layer outputs (Gaussian parameters etc., not function values!) from given activations """ K = self.nGaussians # Mixing parameters and stddevs outbuf[0:K*2] = safeExp(inbuf[0:K*2]) outbuf[0:K] /= sum(ou...
Calculate layer outputs (Gaussian parameters etc., not function values!) from given activations
_forwardImplementation
python
pybrain/pybrain
pybrain/structure/modules/mixturedensity.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/mixturedensity.py
BSD-3-Clause
def _backwardImplementation(self, outerr, inerr, outbuf, inbuf): """Calculate the derivatives of output wrt. corresponding input activations.""" # Cannot calculate because we would need the targets! # ==> we just pass through the stuff from the trainer, who takes care # of the ...
Calculate the derivatives of output wrt. corresponding input activations.
_backwardImplementation
python
pybrain/pybrain
pybrain/structure/modules/mixturedensity.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/mixturedensity.py
BSD-3-Clause
def __init__(self, indim, outdim, name=None, **args): """Create a Module with an input dimension of indim and an output dimension of outdim.""" self.setArgs(name=name, **args) # Make sure that it does not matter whether Module.__init__ is called # before or after adding elements...
Create a Module with an input dimension of indim and an output dimension of outdim.
__init__
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def _resetBuffers(self, length=1): """Reset buffers to a length (in time dimension) of 1.""" for buffername, dim in self.bufferlist: setattr(self, buffername, zeros((length, dim))) if length==1: self.offset = 0
Reset buffers to a length (in time dimension) of 1.
_resetBuffers
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def _growBuffers(self): """Double the size of the modules buffers in its first dimension and keep the current values.""" currentlength = getattr(self, self.bufferlist[0][0]).shape[0] # Save the current buffers tmp = [getattr(self, n) for n, _ in self.bufferlist] Module._r...
Double the size of the modules buffers in its first dimension and keep the current values.
_growBuffers
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def backward(self): """Produce the input error from the output error.""" self._backwardImplementation(self.outputerror[self.offset], self.inputerror[self.offset], self.outputbuffer[self.offset], ...
Produce the input error from the output error.
backward
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def reset(self): """Set all buffers, past and present, to zero.""" self.offset = 0 for buffername, l in self.bufferlist: buf = getattr(self, buffername) buf[:] = zeros(l)
Set all buffers, past and present, to zero.
reset
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def shift(self, items): """Shift all buffers up or down a defined number of items on offset axis. Negative values indicate backward shift.""" if items == 0: return self.offset += items for buffername, _ in self.bufferlist: buf = getattr(self, buffername) ...
Shift all buffers up or down a defined number of items on offset axis. Negative values indicate backward shift.
shift
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def activateOnDataset(self, dataset): """Run the module's forward pass on the given dataset unconditionally and return the output.""" dataset.reset() self.reset() out = zeros((len(dataset), self.outdim)) for i, sample in enumerate(dataset): # FIXME: Can we alw...
Run the module's forward pass on the given dataset unconditionally and return the output.
activateOnDataset
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def activate(self, inpt): """Do one transformation of an input and return the result.""" assert len(self.inputbuffer[self.offset]) == len(inpt), str((len(self.inputbuffer[self.offset]), len(inpt))) self.inputbuffer[self.offset] = inpt self.forward() return self.outputbuffer[self....
Do one transformation of an input and return the result.
activate
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def backActivate(self, outerr): """Do one transformation of an output error outerr backward and return the error on the input.""" self.outputerror[self.offset] = outerr self.backward() return self.inputerror[self.offset].copy()
Do one transformation of an output error outerr backward and return the error on the input.
backActivate
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def _backwardImplementation(self, outerr, inerr, outbuf, inbuf): """Converse of the module's transformation function. Can be overwritten in subclasses, does not have to. Should also compute the derivatives of the parameters."""
Converse of the module's transformation function. Can be overwritten in subclasses, does not have to. Should also compute the derivatives of the parameters.
_backwardImplementation
python
pybrain/pybrain
pybrain/structure/modules/module.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/module.py
BSD-3-Clause
def whichNeuron(self, inputIndex=None, outputIndex=None): """Determine which neuron a position in the input/output buffer corresponds to. """ if inputIndex is not None: return inputIndex if outputIndex is not None: return outputIndex
Determine which neuron a position in the input/output buffer corresponds to.
whichNeuron
python
pybrain/pybrain
pybrain/structure/modules/neuronlayer.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/neuronlayer.py
BSD-3-Clause
def __init__(self, indim=0, outdim=0, model=None): """ Initializes as empty module. If `model` is given, initialize using this LIBSVM model instead. `indim` and `outdim` are for compatibility only, and ignored.""" self.reset() # set some dummy input/ouput dimensions - these beco...
Initializes as empty module. If `model` is given, initialize using this LIBSVM model instead. `indim` and `outdim` are for compatibility only, and ignored.
__init__
python
pybrain/pybrain
pybrain/structure/modules/svmunit.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/svmunit.py
BSD-3-Clause
def forwardPass(self, values=False): """ Produce the output from the current input vector, or process a dataset. If `values` is False or 'class', output is set to the number of the predicted class. If True or 'raw', produces decision values instead. These are stored in a diction...
Produce the output from the current input vector, or process a dataset. If `values` is False or 'class', output is set to the number of the predicted class. If True or 'raw', produces decision values instead. These are stored in a dictionary for multi-class SVM. If `prob`, class ...
forwardPass
python
pybrain/pybrain
pybrain/structure/modules/svmunit.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/svmunit.py
BSD-3-Clause
def activateOnDataset(self, dataset, values=False): """ Run the module's forward pass on the given dataset unconditionally and return the output as a list. :arg dataset: A non-sequential supervised data set. :key values: Passed trough to forwardPass() method.""" out = [] ...
Run the module's forward pass on the given dataset unconditionally and return the output as a list. :arg dataset: A non-sequential supervised data set. :key values: Passed trough to forwardPass() method.
activateOnDataset
python
pybrain/pybrain
pybrain/structure/modules/svmunit.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/svmunit.py
BSD-3-Clause
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 se...
initialize with the number of rows and columns. the table values are all set to zero.
__init__
python
pybrain/pybrain
pybrain/structure/modules/table.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/modules/table.py
BSD-3-Clause
def __init__(self, predefined = None, **kwargs): """ For the current implementation, the sequence length needs to be fixed, and given at construction time. """ if predefined is not None: self.predefined = predefined else: self.predefined = {} FeedForwardNe...
For the current implementation, the sequence length needs to be fixed, and given at construction time.
__init__
python
pybrain/pybrain
pybrain/structure/networks/bidirectional.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/bidirectional.py
BSD-3-Clause
def _canonicForm(self, tup, dim): """ determine if there is a symmetrical tuple of lower coordinates :key dim: the removed coordinate. """ if not self.symmetricdimensions: return tup canonic = [] for dim, maxval in enumerate(tupleRemoveItem(self.dims, dim)): ...
determine if there is a symmetrical tuple of lower coordinates :key dim: the removed coordinate.
_canonicForm
python
pybrain/pybrain
pybrain/structure/networks/borderswiping.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/borderswiping.py
BSD-3-Clause
def _extrapolateBorderAt(self, t, using): """ maybe we can use weights that are similar to neighboring borderconnections as initialization. """ closest = reachable(decrementAny, [t], list(using.keys())) if len(closest) > 0: params = zeros(using[list(closest.keys())[0]].paramd...
maybe we can use weights that are similar to neighboring borderconnections as initialization.
_extrapolateBorderAt
python
pybrain/pybrain
pybrain/structure/networks/borderswiping.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/borderswiping.py
BSD-3-Clause
def _permsForSwiping(self): """Return the correct permutations of blocks for all swiping direction. """ # We use an identity permutation to generate the permutations from by # slicing correctly. return [self._standardPermutation()]
Return the correct permutations of blocks for all swiping direction.
_permsForSwiping
python
pybrain/pybrain
pybrain/structure/networks/mdrnn.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/mdrnn.py
BSD-3-Clause
def __init__(self, dims, **args): """ The one required argument specifies the sizes of each dimension (minimum 2) """ SwipingNetwork.__init__(self, dims = dims, **args) pdims = product(dims) # the input is a 2D-mesh (as a view on a flat input layer) inmod = LinearLayer(self.ins...
The one required argument specifies the sizes of each dimension (minimum 2)
__init__
python
pybrain/pybrain
pybrain/structure/networks/multidimensional.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/multidimensional.py
BSD-3-Clause
def __getitem__(self, name): """Return the module with the given name.""" for m in self.modules: if m.name == name: return m return None
Return the module with the given name.
__getitem__
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def _containerIterator(self): """Return an iterator over the non-empty ParameterContainers of the network. The order IS deterministic.""" for m in self.modulesSorted: if m.paramdim: yield m for c in self.connections[m]: if c.paramd...
Return an iterator over the non-empty ParameterContainers of the network. The order IS deterministic.
_containerIterator
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def addModule(self, m): """Add the given module to the network.""" if isinstance(m, ModuleSlice): m = m.base if m not in self.modules: self.modules.add(m) if not m in self.connections: self.connections[m] = [] if m.paramdim > 0: m.o...
Add the given module to the network.
addModule
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def addInputModule(self, m): """Add the given module to the network and mark it as an input module. """ if isinstance(m, ModuleSlice): m = m.base if m not in self.inmodules: self.inmodules.append(m) self.addModule(m)
Add the given module to the network and mark it as an input module.
addInputModule
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def addOutputModule(self, m): """Add the given module to the network and mark it as an output module. """ if isinstance(m, ModuleSlice): m = m.base if m not in self.outmodules: self.outmodules.append(m) self.addModule(m)
Add the given module to the network and mark it as an output module.
addOutputModule
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def addConnection(self, c): """Add the given connection to the network.""" if not c.inmod in self.connections: self.connections[c.inmod] = [] self.connections[c.inmod].append(c) if isinstance(c, SharedConnection): if c.mother not in self.motherconnections: ...
Add the given connection to the network.
addConnection
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def reset(self): """Reset all component modules and the network.""" Module.reset(self) for m in self.modules: m.reset()
Reset all component modules and the network.
reset
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def _setParameters(self, p, owner=None): """ put slices of this array back into the modules """ ParameterContainer._setParameters(self, p, owner) index = 0 for x in self._containerIterator(): x._setParameters(self.params[index:index + x.paramdim], self) index += x...
put slices of this array back into the modules
_setParameters
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def _topologicalSort(self): """Update the network structure and make .modulesSorted a topologically sorted list of the modules.""" # Algorithm: R. E. Tarjan (1972), stolen from: # http://www.bitformation.com/art/python_toposort.html # Create a directed graph, including a cou...
Update the network structure and make .modulesSorted a topologically sorted list of the modules.
_topologicalSort
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
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...
Prepare the network for activation by sorting the internal datastructure. Needs to be called before activation.
sortModules
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def convertToFastNetwork(self): """ Attempt to transform the network into a fast network. If fast networks are not available, or the network cannot be converted, it returns None. """ from pybrain.structure.networks import FeedForwardNetwork, RecurrentNetwork try: from arac.p...
Attempt to transform the network into a fast network. If fast networks are not available, or the network cannot be converted, it returns None.
convertToFastNetwork
python
pybrain/pybrain
pybrain/structure/networks/network.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/network.py
BSD-3-Clause
def _constructParameterInfo(self): """ construct a dictionnary with information about each parameter: The key is the index in self.params, and the value is a tuple containing (inneuron, outneuron), where a neuron is a tuple of it's module and an index. """ self.paramInfo = {} ...
construct a dictionnary with information about each parameter: The key is the index in self.params, and the value is a tuple containing (inneuron, outneuron), where a neuron is a tuple of it's module and an index.
_constructParameterInfo
python
pybrain/pybrain
pybrain/structure/networks/neurondecomposable.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/neurondecomposable.py
BSD-3-Clause
def getDecomposition(self): """ return a list of arrays, each corresponding to one neuron's relevant parameters """ res = [] for neuron in self._neuronIterator(): nIndices = self.decompositionIndices[neuron] if len(nIndices) > 0: tmp = zeros(len(nIndices))...
return a list of arrays, each corresponding to one neuron's relevant parameters
getDecomposition
python
pybrain/pybrain
pybrain/structure/networks/neurondecomposable.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/neurondecomposable.py
BSD-3-Clause
def setDecomposition(self, decomposedParams): """ set parameters by neuron decomposition, each corresponding to one neuron's relevant parameters """ nindex = 0 for neuron in self._neuronIterator(): nIndices = self.decompositionIndices[neuron] if len(nIndices) > 0:...
set parameters by neuron decomposition, each corresponding to one neuron's relevant parameters
setDecomposition
python
pybrain/pybrain
pybrain/structure/networks/neurondecomposable.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/neurondecomposable.py
BSD-3-Clause
def convertNormalNetwork(n): """ convert a normal network into a decomposable one """ if isinstance(n, RecurrentNetwork): res = RecurrentDecomposableNetwork() for c in n.recurrentConns: res.addRecurrentConnection(c) else: res = FeedForwardDecom...
convert a normal network into a decomposable one
convertNormalNetwork
python
pybrain/pybrain
pybrain/structure/networks/neurondecomposable.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/neurondecomposable.py
BSD-3-Clause
def fromDims(cls, visibledim, hiddendim, params=None, biasParams=None): """Return a restricted Boltzmann machine of the given dimensions with the given distributions.""" net = FeedForwardNetwork() bias = BiasUnit('bias') visible = LinearLayer(visibledim, 'visible') hidden...
Return a restricted Boltzmann machine of the given dimensions with the given distributions.
fromDims
python
pybrain/pybrain
pybrain/structure/networks/rbm.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/rbm.py
BSD-3-Clause
def addRecurrentConnection(self, c): """Add a connection to the network and mark it as a recurrent one.""" if isinstance(c, SharedConnection): if c.mother not in self.motherconnections: self.motherconnections.append(c.mother) c.mother.owner = self elif...
Add a connection to the network and mark it as a recurrent one.
addRecurrentConnection
python
pybrain/pybrain
pybrain/structure/networks/recurrent.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/recurrent.py
BSD-3-Clause
def forward(self): """Produce the output from the input.""" if not (self.offset + 1 < self.inputbuffer.shape[0]): self._growBuffers() super(RecurrentNetworkComponent, self).forward() self.offset += 1 self.maxoffset = max(self.offset, self.maxoffset)
Produce the output from the input.
forward
python
pybrain/pybrain
pybrain/structure/networks/recurrent.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/recurrent.py
BSD-3-Clause
def _verifyDimensions(self, inmesh, hiddenmesh, outmesh): """ verify dimension matching between the meshes """ assert self.dims == inmesh.dims assert outmesh.dims == self.dims assert tuple(hiddenmesh.dims[:-1]) == self.dims, '%s <-> %s' % ( hiddenmesh.dims[:-1], self.dims...
verify dimension matching between the meshes
_verifyDimensions
python
pybrain/pybrain
pybrain/structure/networks/swiping.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/swiping.py
BSD-3-Clause
def _buildSwipingStructure(self, inmesh, hiddenmesh, outmesh): """ :key inmesh: a mesh of input units :key hiddenmesh: a mesh of hidden units :key outmesh: a mesh of output units """ self._verifyDimensions(inmesh, hiddenmesh, outmesh) # add the modules fo...
:key inmesh: a mesh of input units :key hiddenmesh: a mesh of hidden units :key outmesh: a mesh of output units
_buildSwipingStructure
python
pybrain/pybrain
pybrain/structure/networks/swiping.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/swiping.py
BSD-3-Clause
def _printPredefined(self, dic=None, indent=0): """ print the weights of the Motherconnections in the self.predefined dictionary (recursively)""" if dic == None: dic = self.predefined for k, val in sorted(dic.items()): print((' ' * indent, k,)) if isinstance(v...
print the weights of the Motherconnections in the self.predefined dictionary (recursively)
_printPredefined
python
pybrain/pybrain
pybrain/structure/networks/swiping.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/swiping.py
BSD-3-Clause
def __init__(self, **args): """ :key clusterssize: the side of the square for clustering: if > 1, an extra layer for cluster-construction is added :key clusteroverlap: by how much should the cluster overlap (default = 0) :key directlink: should connections from the input directly to the ...
:key clusterssize: the side of the square for clustering: if > 1, an extra layer for cluster-construction is added :key clusteroverlap: by how much should the cluster overlap (default = 0) :key directlink: should connections from the input directly to the bottleneck be included?
__init__
python
pybrain/pybrain
pybrain/structure/networks/custom/capturegame.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/custom/capturegame.py
BSD-3-Clause
def _generateName(self): """ generate a quasi unique name, using construction parameters """ name = self.__class__.__name__ #if self.size != 5: name += '-s'+str(self.size) name += '-h'+str(self.hsize) if self.directlink: name += '-direct' if self.compo...
generate a quasi unique name, using construction parameters
_generateName
python
pybrain/pybrain
pybrain/structure/networks/custom/capturegame.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/custom/capturegame.py
BSD-3-Clause
def resizedTo(self, newsize): """ Produce a copy of the network, with a different size but with the same (shared) weights, extrapolating on the borders as necessary. """ if newsize == self.size: return self.copy() else: import copy # TODO: ugly hack! ...
Produce a copy of the network, with a different size but with the same (shared) weights, extrapolating on the borders as necessary.
resizedTo
python
pybrain/pybrain
pybrain/structure/networks/custom/capturegame.py
https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/custom/capturegame.py
BSD-3-Clause
def __init__(self, evolino_network, dataset, **kwargs): """ :key evolino_network: an instance of NetworkWrapper() :key dataset: The evaluation dataset :key evalfunc: Compares output to target values and returns a scalar, denoting the fitness. Defaults to -mse...
:key evolino_network: an instance of NetworkWrapper() :key dataset: The evaluation dataset :key evalfunc: Compares output to target values and returns a scalar, denoting the fitness. Defaults to -mse(output, target). :key wtRatio: Float array of two valu...
__init__
python
pybrain/pybrain
pybrain/supervised/evolino/filter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/filter.py
BSD-3-Clause
def _evaluateNet(self, net, dataset, wtRatio): """ Evaluates the performance of net on the given dataset. Returns the fitness value. :key net: Instance of EvolinoNetwork to evaluate :key dataset: Sequences to test the net on :key wtRatio: See __init__ """...
Evaluates the performance of net on the given dataset. Returns the fitness value. :key net: Instance of EvolinoNetwork to evaluate :key dataset: Sequences to test the net on :key wtRatio: See __init__
_evaluateNet
python
pybrain/pybrain
pybrain/supervised/evolino/filter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/filter.py
BSD-3-Clause
def apply(self, population): """ Evaluate each individual, and store fitness inside population. Also calculate and set the weight matrix W of the linear output layer. :arg population: Instance of EvolinoPopulation """ net = self.network dataset = self.dataset ...
Evaluate each individual, and store fitness inside population. Also calculate and set the weight matrix W of the linear output layer. :arg population: Instance of EvolinoPopulation
apply
python
pybrain/pybrain
pybrain/supervised/evolino/filter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/filter.py
BSD-3-Clause
def apply(self, population): """ The subpopulations of the EvolinoPopulation are iterated and forwarded to the EvolinoSubSelection() operator. :arg population: object of type EvolinoPopulation """ self.sub_selection.nParents = self.nParents for sp in population.g...
The subpopulations of the EvolinoPopulation are iterated and forwarded to the EvolinoSubSelection() operator. :arg population: object of type EvolinoPopulation
apply
python
pybrain/pybrain
pybrain/supervised/evolino/filter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/filter.py
BSD-3-Clause
def __init__(self, **kwargs): """ :key **kwargs: will be forwarded to the EvolinoSubReproduction constructor """ Filter.__init__(self) self._kwargs = kwargs
:key **kwargs: will be forwarded to the EvolinoSubReproduction constructor
__init__
python
pybrain/pybrain
pybrain/supervised/evolino/filter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/filter.py
BSD-3-Clause
def apply(self, population): """ The subpopulations of the EvolinoPopulation are iterated and forwarded to the EvolinoSubReproduction() operator. :arg population: object of type EvolinoPopulation """ sps = population.getSubPopulations() reproduction = EvolinoSubR...
The subpopulations of the EvolinoPopulation are iterated and forwarded to the EvolinoSubReproduction() operator. :arg population: object of type EvolinoPopulation
apply
python
pybrain/pybrain
pybrain/supervised/evolino/filter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/filter.py
BSD-3-Clause
def apply(self, population): """ Keeps just the best fitting individual of each subpopulation. All other individuals are erased. After that, the kept best fitting individuals will be used for reproduction, in order to refill the sub-populations. """ sps = popu...
Keeps just the best fitting individual of each subpopulation. All other individuals are erased. After that, the kept best fitting individuals will be used for reproduction, in order to refill the sub-populations.
apply
python
pybrain/pybrain
pybrain/supervised/evolino/filter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/filter.py
BSD-3-Clause
def apply(self, population): """ Simply removes some individuals with lowest fitness values """ n = population.getIndividualsN() if self.nParents is None: nKeep = n // 4 else: nKeep = self.nParents assert nKeep >= 0 assert nKeep <= n ...
Simply removes some individuals with lowest fitness values
apply
python
pybrain/pybrain
pybrain/supervised/evolino/filter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/filter.py
BSD-3-Clause
def __init__(self, **kwargs): """ :key verbosity: Verbosity level :key mutationVariate: Variate used for mutation. Defaults to None :key mutation: Defaults to EvolinoSubMutation """ Filter.__init__(self) ap = KWArgsProcessor(self, kwargs) ap.add('verbosit...
:key verbosity: Verbosity level :key mutationVariate: Variate used for mutation. Defaults to None :key mutation: Defaults to EvolinoSubMutation
__init__
python
pybrain/pybrain
pybrain/supervised/evolino/filter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/filter.py
BSD-3-Clause