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 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 activate(self, inpt):
"""Do one transformation of an input and return the result."""
self.reset()
return super(FeedForwardNetworkComponent, self).activate(inpt) | Do one transformation of an input and return the result. | activate | python | pybrain/pybrain | pybrain/structure/networks/feedforward.py | https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/feedforward.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 _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.
identity = scipy.array(list(range(self.sequenceLength)))
identity.shape = tup... | 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 _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 +... | put slices of this array back into the modules | _setDerivatives | 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 activate(self, inpt):
"""Do one transformation of an input and return the result."""
self.inputbuffer[self.offset] = inpt
self.forward()
if self.forget:
return self.outputbuffer[self.offset].copy()
else:
return self.outputbuffer[self.offset - 1].copy() | Do one transformation of an input and return the result. | activate | python | pybrain/pybrain | pybrain/structure/networks/recurrent.py | https://github.com/pybrain/pybrain/blob/master/pybrain/structure/networks/recurrent.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 - 1] = 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/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 __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):
""" 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 |
def apply(self, population):
""" First determines the number of individuals to be created.
Then clones the fittest individuals (=parents), mutates these clones
and adds them to the population.
"""
max_n = population.getMaxNIndividuals()
n = population.getIndividua... | First determines the number of individuals to be created.
Then clones the fittest individuals (=parents), mutates these clones
and adds them to the population.
| 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):
""" :key kwargs: See setArgs() method documentation
"""
SimpleGenomeManipulation.__init__(self)
self.mutationVariate = GaussianVariate()
self.mutationVariate.alpha = 0.1
self.verbosity = 0 | :key kwargs: See setArgs() method documentation
| __init__ | python | pybrain/pybrain | pybrain/supervised/evolino/gfilter.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/gfilter.py | BSD-3-Clause |
def _manipulateValue(self, value):
""" Implementation of the abstract method of class SimpleGenomeManipulation
Set's the x0 value of the variate to value and takes a new sample
value and returns it.
"""
self.mutationVariate.x0 = value
newval = self.mutationVariate... | Implementation of the abstract method of class SimpleGenomeManipulation
Set's the x0 value of the variate to value and takes a new sample
value and returns it.
| _manipulateValue | python | pybrain/pybrain | pybrain/supervised/evolino/gfilter.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/gfilter.py | BSD-3-Clause |
def getSortedIndividualList(self):
""" Returns a sorted list of all individuals with descending fitness values. """
fitness = self._fitness
return sorted(iter(fitness.keys()), key=lambda k:-fitness[k]) | Returns a sorted list of all individuals with descending fitness values. | getSortedIndividualList | python | pybrain/pybrain | pybrain/supervised/evolino/gpopulation.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/gpopulation.py | BSD-3-Clause |
def getGenome(self):
""" Returns the genome created by concatenating the chromosomes supplied
by the sub-individuals.
"""
genome = []
for sub_individual in self._sub_individuals:
genome.append(deepcopy(sub_individual.getGenome()))
return genome | Returns the genome created by concatenating the chromosomes supplied
by the sub-individuals.
| getGenome | python | pybrain/pybrain | pybrain/supervised/evolino/individual.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/individual.py | BSD-3-Clause |
def __init__(self, genome):
""" :key genome: Any kind of nested iteratable container containing
floats as leafs
"""
self.setGenome(genome)
self.id = EvolinoSubIndividual._next_id
EvolinoSubIndividual._next_id += 1 | :key genome: Any kind of nested iteratable container containing
floats as leafs
| __init__ | python | pybrain/pybrain | pybrain/supervised/evolino/individual.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/individual.py | BSD-3-Clause |
def _validateGenomeLayer(self, layer):
""" Validates the type and state of a layer
"""
assert isinstance(layer, LSTMLayer)
assert not layer.peepholes | Validates the type and state of a layer
| _validateGenomeLayer | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def _getGenomeOfLayer(self, layer):
""" Returns the genome of a single layer.
"""
self._validateGenomeLayer(layer)
dim = layer.outdim
layer_weights = []
connections = self._getInputConnectionsOfLayer(layer)
for cell_idx in range(dim):
# todo: the ev... | Returns the genome of a single layer.
| _getGenomeOfLayer | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def _setGenomeOfLayer(self, layer, weights):
""" Sets the genome of a single layer.
"""
self._validateGenomeLayer(layer)
dim = layer.outdim
connections = self._getInputConnectionsOfLayer(layer)
for cell_idx in range(dim):
cell_weights = weights.pop(0)
... | Sets the genome of a single layer.
| _setGenomeOfLayer | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def setOutputWeightMatrix(self, W):
""" Sets the weight matrix of the output layer's input connection.
"""
c = self._hid_to_out_connection
c.params[:] = W.flatten() | Sets the weight matrix of the output layer's input connection.
| setOutputWeightMatrix | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def getOutputWeightMatrix(self):
""" Sets the weight matrix of the output layer's input connection.
"""
c = self._hid_to_out_connection
p = c.getParameters()
return reshape(p, (c.outdim, c.indim)) | Sets the weight matrix of the output layer's input connection.
| getOutputWeightMatrix | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def _getInputConnectionsOfLayer(self, layer):
""" Returns a list of all input connections for the layer. """
connections = []
for c in sum(list(self._network.connections.values()), []):
if c.outmod is layer:
if not isinstance(c, FullConnection):
ra... | Returns a list of all input connections for the layer. | _getInputConnectionsOfLayer | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def __init__(self, network):
""" :key network: The network to be wrapped
"""
self.network = network
self._output_connection = None
self._last_hidden_layer = None
self._first_hidden_layer = None
self._establishRecurrence() | :key network: The network to be wrapped
| __init__ | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def _establishRecurrence(self):
""" Adds a recurrent full connection from the output layer to the first
hidden layer.
"""
network = self.network
outlayer = self.getOutputLayer()
hid1layer = self.getFirstHiddenLayer()
network.addRecurrentConnection(FullConnecti... | Adds a recurrent full connection from the output layer to the first
hidden layer.
| _establishRecurrence | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def _validateGenomeLayer(self, layer):
""" Validates the type and state of a layer
"""
assert isinstance(layer, LSTMLayer)
assert not layer.peepholes | Validates the type and state of a layer
| _validateGenomeLayer | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def getGenome(self):
""" Returns the Genome of the network.
See class description for more details.
"""
weights = []
for layer in self.getHiddenLayers():
if isinstance(layer, LSTMLayer):
# if layer is not self._recurrence_layer:
wei... | Returns the Genome of the network.
See class description for more details.
| getGenome | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def setGenome(self, weights):
""" Sets the Genome of the network.
See class description for more details.
"""
weights = deepcopy(weights)
for layer in self.getHiddenLayers():
if isinstance(layer, LSTMLayer):
# if layer is not self._recurrence_layer:
... | Sets the Genome of the network.
See class description for more details.
| setGenome | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def _getGenomeOfLayer(self, layer):
""" Returns the genome of a single layer.
"""
self._validateGenomeLayer(layer)
dim = layer.outdim
layer_weights = []
connections = self._getInputConnectionsOfLayer(layer)
for cell_idx in range(dim):
# todo: the ev... | Returns the genome of a single layer.
| _getGenomeOfLayer | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def _setGenomeOfLayer(self, layer, weights):
""" Sets the genome of a single layer.
"""
self._validateGenomeLayer(layer)
dim = layer.outdim
connections = self._getInputConnectionsOfLayer(layer)
for cell_idx in range(dim):
cell_weights = weights.pop(0)
... | Sets the genome of a single layer.
| _setGenomeOfLayer | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
def setOutputWeightMatrix(self, W):
""" Sets the weight matrix of the output layer's input connection.
"""
c = self.getOutputConnection()
p = c.getParameters()
p[:] = W.flatten() | Sets the weight matrix of the output layer's input connection.
| setOutputWeightMatrix | python | pybrain/pybrain | pybrain/supervised/evolino/networkwrapper.py | https://github.com/pybrain/pybrain/blob/master/pybrain/supervised/evolino/networkwrapper.py | BSD-3-Clause |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves Python code examples from Django repository that contain 'django' in the code, which helps identify Django-specific code snippets but provides limited analytical insights beyond basic filtering.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.