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 _calculateJobs(self): """ Calculate and return the metaparameter settings to be validated (=jobs). """ ndim = len(self._min_params) linspaces = [] for i in range(ndim): linspaces.append( self._permuteSequence( list(linspace(self...
Calculate and return the metaparameter settings to be validated (=jobs).
_calculateJobs
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def _permuteSequence(self, seq): """ Helper function for calculating the job list """ n = len(seq) if n <= 1: return seq mid = int(n / 2) left = self._permuteSequence(seq[:mid]) right = self._permuteSequence(seq[mid + 1:]) ret = [seq[mid]] while ...
Helper function for calculating the job list
_permuteSequence
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def search(self): """ The main search method, that validates all calculated metaparameter settings by calling the abstract _validate() method. """ self._n_params = len(self._min_params) center = self._min_params + self._range / 2. for level in range(self._n_iteration...
The main search method, that validates all calculated metaparameter settings by calling the abstract _validate() method.
search
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def _validateWrapper(self, params): """ Helper function that wraps the _validate() method. """ perf = self._validate(params) if self._verbosity > 0: print(("validated:", params, " performance = ", perf)) self._performances[tuple(params)] = perf return perf
Helper function that wraps the _validate() method.
_validateWrapper
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def _calcGrid(self, center, level): """ Calculate the next grid to validate. :arg center: The central position of the grid :arg level: The iteration number """ local_range = self._range / (self._refine_factor ** level) scale = local_range / 2 translation...
Calculate the next grid to validate. :arg center: The central position of the grid :arg level: The iteration number
_calcGrid
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def _moveGridIntoBounds(self, grid): """ If the calculated grid is out of bounds, this method moves it back inside, and returns the new grid. """ grid = array(grid) local_min_params = grid.min(axis=0) local_max_params = grid.max(axis=0) tosmall_idxs, = where(l...
If the calculated grid is out of bounds, this method moves it back inside, and returns the new grid.
_moveGridIntoBounds
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def __init__(self, trainer, dataset, min_params=[-5, -15], max_params=[15, 3], n_steps=7, **kwargs): """ The parameter boundaries are specified in log2-space. :arg trainer: The SVM trainer including the SVM module. (Could be any kind of trainer and module) :a...
The parameter boundaries are specified in log2-space. :arg trainer: The SVM trainer including the SVM module. (Could be any kind of trainer and module) :arg dataset: Dataset used for crossvalidation
__init__
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def setArgs(self, **kwargs): """ :key **kwargs: nfolds : Number of folds of crossvalidation max_epochs: Maximum number of epochs for training verbosity : set verbosity """ for key, value in list(kwargs.items()): if key in ("folds", "...
:key **kwargs: nfolds : Number of folds of crossvalidation max_epochs: Maximum number of epochs for training verbosity : set verbosity
setArgs
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def _validate(self, params): """ The overridden validate function, that uses cross-validation in order to determine the params' performance value. """ trainer = self._getTrainerForParams(params) return CrossValidator(trainer, self._dataset, self._n_folds, **self._validator_kw...
The overridden validate function, that uses cross-validation in order to determine the params' performance value.
_validate
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def _getTrainerForParams(self, params): """ Returns a trainer, loaded with the supplied metaparameters. """ trainer = copy.deepcopy(self._trainer) trainer.setArgs(cost=2 ** params[0], gamma=2 ** params[1], ver=0) return trainer
Returns a trainer, loaded with the supplied metaparameters.
_getTrainerForParams
python
pybrain/pybrain
pybrain/tools/gridsearch.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/gridsearch.py
BSD-3-Clause
def leftordered(M): """ Returns the given matrix in left-ordered-form. """ l = list(M.T) l.sort(key=tuple) return array(l)[::-1].T
Returns the given matrix in left-ordered-form.
leftordered
python
pybrain/pybrain
pybrain/tools/ibp.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/ibp.py
BSD-3-Clause
def testIBP(): """ Plot matrices generated by an IBP, for a few different settings. """ from pybrain.tools.plotting.colormaps import ColorMap import pylab # always 50 customers n = 50 # define parameter settings ps = [(10, 0.1), (10,), (50,), (50, 0.5), ] ...
Plot matrices generated by an IBP, for a few different settings.
testIBP
python
pybrain/pybrain
pybrain/tools/ibp.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/ibp.py
BSD-3-Clause
def __init__(self, DS, **kwargs): """ Initialize with the training data set DS. All keywords given are set as member variables. The following are particularly important: :key hidden: number of hidden units :key TDS: test data set for checking convergence :key VDS: validation dat...
Initialize with the training data set DS. All keywords given are set as member variables. The following are particularly important: :key hidden: number of hidden units :key TDS: test data set for checking convergence :key VDS: validation data set for final performance evaluation ...
__init__
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def initGraphics(self, ymax=10, xmax= -1): """ initialize the interactive graphics output window, and return a handle to the plot """ if xmax < 0: xmax = self.maxepochs figure(figsize=[12, 8]) ion() draw() #self.Graph = MultilinePlotter(autoscale=1.2 ) #xlim=[...
initialize the interactive graphics output window, and return a handle to the plot
initGraphics
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def saveTrainingCurve(self, learnfname): """ save the training curves into a file with the given name (CSV format) """ logging.info('Saving training curves into ' + learnfname) if self.trainCurve is None: logging.error('No training curve available for saving!') learnf = open(...
save the training curves into a file with the given name (CSV format)
saveTrainingCurve
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def saveNetwork(self, fname): """ save the trained network to a file """ NetworkWriter.writeToFile(self.Trainer.module, fname) logging.info("Network saved to: " + fname)
save the trained network to a file
saveNetwork
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def setupNN(self, trainer=RPropMinusTrainer, hidden=None, **trnargs): """ Constructs a 3-layer FNN for regression. Optional arguments are passed on to the Trainer class. """ if hidden is not None: self.hidden = hidden logging.info("Constructing FNN with following config:") FN...
Constructs a 3-layer FNN for regression. Optional arguments are passed on to the Trainer class.
setupNN
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def runTraining(self, convergence=0, **kwargs): """ Trains the network on the stored dataset. If convergence is >0, check after that many epoch increments whether test error is going down again, and stop training accordingly. CAVEAT: No support for Sequential datasets!""" assert isinstan...
Trains the network on the stored dataset. If convergence is >0, check after that many epoch increments whether test error is going down again, and stop training accordingly. CAVEAT: No support for Sequential datasets!
runTraining
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def __init__(self, DS, **kwargs): """ Initialize the classifier: the least we need is the dataset to be classified. All keywords given are set as member variables. """ if not isinstance(DS, ClassificationDataSet): raise TypeError('Need a ClassificationDataSet to do classification!') ...
Initialize the classifier: the least we need is the dataset to be classified. All keywords given are set as member variables.
__init__
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def _convertAllDataToOneOfMany(self, values=[0, 1]): """ converts all datasets associated with self into 1-out-of-many representations, e.g. with original classes 0 to 4, the new target for class 1 would be [0,1,0,0,0], or accordingly with other upper and lower bounds, as given by the values key...
converts all datasets associated with self into 1-out-of-many representations, e.g. with original classes 0 to 4, the new target for class 1 would be [0,1,0,0,0], or accordingly with other upper and lower bounds, as given by the values keyword
_convertAllDataToOneOfMany
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def setupNN(self, trainer=RPropMinusTrainer, hidden=None, **trnargs): """ Setup FNN and trainer for classification. """ self._convertAllDataToOneOfMany() if hidden is not None: self.hidden = hidden FNN = buildNetwork(self.DS.indim, self.hidden, self.DS.outdim, outclass=Softma...
Setup FNN and trainer for classification.
setupNN
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def setupRNN(self, trainer=BackpropTrainer, hidden=None, **trnargs): """ Setup an LSTM RNN and trainer for sequence classification. """ if hidden is not None: self.hidden = hidden self._convertAllDataToOneOfMany() RNN = buildNetwork(self.DS.indim, self.hidden, self.DS.outdim...
Setup an LSTM RNN and trainer for sequence classification.
setupRNN
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def runTraining(self, convergence=0, **kwargs): """ Trains the network on the stored dataset. If convergence is >0, check after that many epoch increments whether test error is going down again, and stop training accordingly. """ assert isinstance(self.Trainer, Trainer) if self.Graph is ...
Trains the network on the stored dataset. If convergence is >0, check after that many epoch increments whether test error is going down again, and stop training accordingly.
runTraining
python
pybrain/pybrain
pybrain/tools/neuralnets.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/neuralnets.py
BSD-3-Clause
def crowding_distance(individuals, fitnesses): """ Crowding distance-measure for multiple objectives. """ distances = collections.defaultdict(lambda: 0) individuals = list(individuals) # Infer the number of objectives by looking at the fitness of the first. n_obj = len(fitnesses[individuals[0]]) ...
Crowding distance-measure for multiple objectives.
crowding_distance
python
pybrain/pybrain
pybrain/tools/nondominated.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/nondominated.py
BSD-3-Clause
def _non_dominated_front_old(iterable, key=lambda x: x, allowequality=True): """Return a subset of items from iterable which are not dominated by any other item in iterable.""" items = list(iterable) keys = dict((i, key(i)) for i in items) dim = len(list(keys.values())[0]) if any(dim != len(k) f...
Return a subset of items from iterable which are not dominated by any other item in iterable.
_non_dominated_front_old
python
pybrain/pybrain
pybrain/tools/nondominated.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/nondominated.py
BSD-3-Clause
def _non_dominated_front_fast(iterable, key=lambda x: x, allowequality=True): """Return a subset of items from iterable which are not dominated by any other item in iterable. Faster version. """ items = list(iterable) keys = dict((i, key(i)) for i in items) dim = len(list(keys.values())[0])...
Return a subset of items from iterable which are not dominated by any other item in iterable. Faster version.
_non_dominated_front_fast
python
pybrain/pybrain
pybrain/tools/nondominated.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/nondominated.py
BSD-3-Clause
def _non_dominated_front_arr(iterable, key=lambda x: x, allowequality=True): """Return a subset of items from iterable which are not dominated by any other item in iterable. Faster version, based on boolean matrix manipulations. """ items = list(iterable) fits = list(map(key, items)) l = le...
Return a subset of items from iterable which are not dominated by any other item in iterable. Faster version, based on boolean matrix manipulations.
_non_dominated_front_arr
python
pybrain/pybrain
pybrain/tools/nondominated.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/nondominated.py
BSD-3-Clause
def non_dominated_sort(iterable, key=lambda x: x, allowequality=True): """Return a list that is sorted in a non-dominating fashion. Keys have to be n-tuple.""" items = set(iterable) fronts = [] while items: front = non_dominated_front(items, key, allowequality) items -= front ...
Return a list that is sorted in a non-dominating fashion. Keys have to be n-tuple.
non_dominated_sort
python
pybrain/pybrain
pybrain/tools/nondominated.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/nondominated.py
BSD-3-Clause
def rankedFitness(R): """ produce a linear ranking of the fitnesses in R. (The highest rank is the best fitness)""" #l = sorted(list(enumerate(R)), cmp = lambda a,b: cmp(a[1],b[1])) #l = sorted(list(enumerate(l)), cmp = lambda a,b: cmp(a[1],b[1])) #return array(map(lambda (r, dummy): r, l)) res...
produce a linear ranking of the fitnesses in R. (The highest rank is the best fitness)
rankedFitness
python
pybrain/pybrain
pybrain/tools/rankingfunctions.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rankingfunctions.py
BSD-3-Clause
def __call__(self, R): """ :key R: one-dimensional array containing fitnesses. """ res = rankedFitness(R) return res / float(max(res))
:key R: one-dimensional array containing fitnesses.
__call__
python
pybrain/pybrain
pybrain/tools/rankingfunctions.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rankingfunctions.py
BSD-3-Clause
def adaptAgent(agent_klass): """Return a factory function that instantiates a pybrain agent and adapts it to the rlglue framework interface. :type agent_klass: subclass of some pybrain agent :key agent_klass: Some class that is to be adapted to the rlglue framework ...
Return a factory function that instantiates a pybrain agent and adapts it to the rlglue framework interface. :type agent_klass: subclass of some pybrain agent :key agent_klass: Some class that is to be adapted to the rlglue framework
adaptAgent
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def adaptAgentObject(agent_object): """Return an object that adapts a pybrain agent to the rlglue interface. """ # This is pretty hacky: We first take a bogus agent with a bogus module # for our function adaptAgent to work, then substitue the bogus agent with # our actual agent. agent = adaptAge...
Return an object that adapts a pybrain agent to the rlglue interface.
adaptAgentObject
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def __init__(self, klass, *args, **kwargs): """ Create an object that adapts an object of class klass to the protocol of rlglue agents. :type klass: subclass of some pybrain agent :key klass: Some class that is to be adapted to the rlglue frame...
Create an object that adapts an object of class klass to the protocol of rlglue agents. :type klass: subclass of some pybrain agent :key klass: Some class that is to be adapted to the rlglue framework
__init__
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def agent_init(self, task_specification=None): """Give the agent a specification of the action and state space. Since pybrain agents are not using task specifications (they are already set up to the problem domain) the task_specification parameter is only there for API consistency, but ...
Give the agent a specification of the action and state space. Since pybrain agents are not using task specifications (they are already set up to the problem domain) the task_specification parameter is only there for API consistency, but it will be ignored. The specification for the spe...
agent_init
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def agent_step(self, reward, observation): """ Return an action depending on an observation and a reward. :type reward: number :type firstObservation: Observation """ self._giveReward(reward) self._integrateObservation(observation) retur...
Return an action depending on an observation and a reward. :type reward: number :type firstObservation: Observation
agent_step
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def agent_end(self, reward): """ Give the last reward to the agent. :type reward: number """ self._giveReward(reward) self.agent.newEpisode() self.episodeCount += 1 if self.episodeCount % self.learnCycle == 0: self.agent.learn() se...
Give the last reward to the agent. :type reward: number
agent_end
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def agent_cleanup(self): """This is called when an episode ends. Should be in one ratio to agent_init."""
This is called when an episode ends. Should be in one ratio to agent_init.
agent_cleanup
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def _getAction(self): """ Return a RLGlue action that is made out of a numpy array yielded by the hold pybrain agent. """ action = RLGlueAction() action.doubleArray = self.agent.getAction().tolist() action.intArray = [] return action
Return a RLGlue action that is made out of a numpy array yielded by the hold pybrain agent.
_getAction
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def __init__(self, path, port=None, autoreconnect=None): """Instantiate an object with the given variables.""" if os.name not in ('posix', 'mac'): raise NotImplementedError( "Killing processes under win32 not supported") self.path = path self.port = port ...
Instantiate an object with the given variables.
__init__
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def run(self): """Run the benchmark. All agents are tested loop times against the environment and statistics for each run are saved into the benchmark directory benchmarkDir. """ # Create benchmark directory: the desired name plus the current date # and time. try...
Run the benchmark. All agents are tested loop times against the environment and statistics for each run are saved into the benchmark directory benchmarkDir.
run
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def testAgent(path, agent, port=DEFAULT_PORT): """Test an agent once on a rlcompetition experiment. Path specifies the executable file of the rl competition. """ agent = adaptAgentObject(BenchmarkingAgent(agent)) experiment = RLCExperiment(path, str(port)) experiment.start() # This method ...
Test an agent once on a rlcompetition experiment. Path specifies the executable file of the rl competition.
testAgent
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def __init__(self, agent): """Return a wrapper around the given agent.""" if hasattr(agent, 'benchmark') or hasattr(agent, 'agent'): raise ValueError("Wrapped agent must not define a benchmark or" + "an agent attribute.") self.agent = agent self....
Return a wrapper around the given agent.
__init__
python
pybrain/pybrain
pybrain/tools/rlgluebridge.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/rlgluebridge.py
BSD-3-Clause
def buildNetwork(*layers, **options): """Build arbitrarily deep networks. `layers` should be a list or tuple of integers, that indicate how many neurons the layers should have. `bias` and `outputbias` are flags to indicate whether the network should have the corresponding biases; both default to Tr...
Build arbitrarily deep networks. `layers` should be a list or tuple of integers, that indicate how many neurons the layers should have. `bias` and `outputbias` are flags to indicate whether the network should have the corresponding biases; both default to True. To adjust the classes for the layers...
buildNetwork
python
pybrain/pybrain
pybrain/tools/shortcuts.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/shortcuts.py
BSD-3-Clause
def _buildNetwork(*layers, **options): """This is a helper function to create different kinds of networks. `layers` is a list of tuples. Each tuple can contain an arbitrary number of layers, each being connected to the next one with IdentityConnections. Due to this, all layers have to have the same dim...
This is a helper function to create different kinds of networks. `layers` is a list of tuples. Each tuple can contain an arbitrary number of layers, each being connected to the next one with IdentityConnections. Due to this, all layers have to have the same dimension. We call these tuples 'parts.' ...
_buildNetwork
python
pybrain/pybrain
pybrain/tools/shortcuts.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/shortcuts.py
BSD-3-Clause
def loadData(self, fname): """ decide which format the data is in """ self.filename = fname if fname.find('.mat') >= 0: self.loadMATdata(fname) elif fname.find('.svm') >= 0: self.loadSVMdata(fname) else: # dataset consists of raw ascii columns ...
decide which format the data is in
loadData
python
pybrain/pybrain
pybrain/tools/svmdata.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/svmdata.py
BSD-3-Clause
def loadMATdata(self, fname): """ read Matlab file containing one variable called 'data' which is an array nSamples x nFeatures+1 and contains the class in the first column """ from mlabwrap import mlab #@UnresolvedImport from numpy import float d = mlab.load(fname) s...
read Matlab file containing one variable called 'data' which is an array nSamples x nFeatures+1 and contains the class in the first column
loadMATdata
python
pybrain/pybrain
pybrain/tools/svmdata.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/svmdata.py
BSD-3-Clause
def loadSVMdata(self, fname): """ read svm sparse format from file 'fname' (with labels only) output: [attributes[], labels[]] """ x = [] y = [] nFeatMax = 0 for line in open(fname, 'r').readlines(): # format is: # <class> <featnr>:<featval> ...
read svm sparse format from file 'fname' (with labels only) output: [attributes[], labels[]]
loadSVMdata
python
pybrain/pybrain
pybrain/tools/svmdata.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/svmdata.py
BSD-3-Clause
def getTargets(self): """ return the targets of the dataset, preserving the current sample pointer """ self.storePointer() self.reset() targets = [] while not self.endOfSequences(): input, target, dummy = self.getSample() targets.append(target) sel...
return the targets of the dataset, preserving the current sample pointer
getTargets
python
pybrain/pybrain
pybrain/tools/svmdata.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/svmdata.py
BSD-3-Clause
def classificationPerformance(cls, output, target): """ Returns the hit rate of the outputs compared to the targets. :arg output: array of output values :arg target: array of target values """ output = array(output) target = array(target) assert len(outpu...
Returns the hit rate of the outputs compared to the targets. :arg output: array of output values :arg target: array of target values
classificationPerformance
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def MSE(cls, output, target, importance=None): """ Returns the mean squared error. The multidimensional arrays will get flattened in order to compare them. :arg output: array of output values :arg target: array of target values :key importance: each squared error...
Returns the mean squared error. The multidimensional arrays will get flattened in order to compare them. :arg output: array of output values :arg target: array of target values :key importance: each squared error will be multiplied with its corresponding...
MSE
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def getSequenceEnds(cls, dataset): """ Returns the indices of the last elements of the sequences stored inside dataset. :arg dataset: Must implement :class:`SequentialDataSet` """ sequence_ends = delete(dataset.getField('sequence_index') - 1, 0) sequence_ends = a...
Returns the indices of the last elements of the sequences stored inside dataset. :arg dataset: Must implement :class:`SequentialDataSet`
getSequenceEnds
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def getSequenceEndsImportance(cls, dataset): """ Returns the importance values of the last elements of the sequences stored inside dataset. :arg dataset: Must implement :class:`ImportanceDataSet` """ importance = zeros(dataset.getLength()) importance[cls.getSeque...
Returns the importance values of the last elements of the sequences stored inside dataset. :arg dataset: Must implement :class:`ImportanceDataSet`
getSequenceEndsImportance
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def classificationPerformance(cls, module, dataset): """ Returns the hit rate of the module's output compared to the targets stored inside dataset. :arg module: Object of any subclass of pybrain's Module type :arg dataset: Dataset object at least containing the fields ...
Returns the hit rate of the module's output compared to the targets stored inside dataset. :arg module: Object of any subclass of pybrain's Module type :arg dataset: Dataset object at least containing the fields 'input' and 'target' (for example SupervisedDataSet) ...
classificationPerformance
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def MSE(cls, module, dataset): """ Returns the mean squared error. :arg module: Object of any subclass of pybrain's Module type :arg dataset: Dataset object at least containing the fields 'input' and 'target' (for example SupervisedDataSet) """ return Mod...
Returns the mean squared error. :arg module: Object of any subclass of pybrain's Module type :arg dataset: Dataset object at least containing the fields 'input' and 'target' (for example SupervisedDataSet)
MSE
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def validate(cls, valfunc, module, dataset): """ Abstract validate function, that is heavily used by this class. First, it calculates the module's output on the dataset. In advance, it compares the output to the target values of the dataset through the valfunc function and re...
Abstract validate function, that is heavily used by this class. First, it calculates the module's output on the dataset. In advance, it compares the output to the target values of the dataset through the valfunc function and returns the result. :arg valfunc: A function ...
validate
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def _calculateModuleOutputSequential(cls, module, dataset): """ Calculates the module's output on the dataset. Especially designed for datasets storing sequences. After a sequence is fed to the module, it has to be resetted. :arg dataset: Dataset object of type SequentialDat...
Calculates the module's output on the dataset. Especially designed for datasets storing sequences. After a sequence is fed to the module, it has to be resetted. :arg dataset: Dataset object of type SequentialDataSet or subclass.
_calculateModuleOutputSequential
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def calculateModuleOutput(cls, module, dataset): """ Calculates the module's output on the dataset. Can be called with any type of dataset. :arg dataset: Any Dataset object containing an 'input' field. """ if isinstance(dataset, SequentialDataSet) or isinstance(dataset, ...
Calculates the module's output on the dataset. Can be called with any type of dataset. :arg dataset: Any Dataset object containing an 'input' field.
calculateModuleOutput
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def __init__(self, trainer, dataset, n_folds=5, valfunc=ModuleValidator.classificationPerformance, **kwargs): """ :arg trainer: Trainer containing a module to be trained :arg dataset: Dataset for training and testing :key n_folds: Number of pieces, the dataset will be splitted to ...
:arg trainer: Trainer containing a module to be trained :arg dataset: Dataset for training and testing :key n_folds: Number of pieces, the dataset will be splitted to :key valfunc: Validation function. Should expect a module and a dataset. E.g. ModuleVali...
__init__
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def setArgs(self, **kwargs): """ Set the specified member variables. :key max_epochs: maximum number of epochs the trainer should train the module for. :key verbosity: set verbosity level """ for key, value in list(kwargs.items()): if key in ("verbose", "ver", "v"): ...
Set the specified member variables. :key max_epochs: maximum number of epochs the trainer should train the module for. :key verbosity: set verbosity level
setArgs
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def validate(self): """ The main method of this class. It runs the crossvalidation process and returns the validation result (e.g. performance). """ dataset = self._dataset trainer = self._trainer n_folds = self._n_folds l = dataset.getLength() inp = d...
The main method of this class. It runs the crossvalidation process and returns the validation result (e.g. performance).
validate
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def testOnSequenceData(module, dataset): """ Fetch targets and calculate the modules output on dataset. Output and target are in one-of-many format. The class for each sequence is determined by first summing the probabilities for each individual sample over the sequence, and then finding its maximum."""...
Fetch targets and calculate the modules output on dataset. Output and target are in one-of-many format. The class for each sequence is determined by first summing the probabilities for each individual sample over the sequence, and then finding its maximum.
testOnSequenceData
python
pybrain/pybrain
pybrain/tools/validation.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/validation.py
BSD-3-Clause
def __init__(self, filename, newfile): """ :key newfile: is the file to be read or is it a new file? """ self.filename = filename if not newfile: self.dom = parse(filename) if self.dom.firstChild.nodeName != 'PyBrain': raise Exception('Not a correct PyBrai...
:key newfile: is the file to be read or is it a new file?
__init__
python
pybrain/pybrain
pybrain/tools/customxml/handling.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/handling.py
BSD-3-Clause
def readAttrDict(self, node, transform = None): """ read a dictionnary of attributes :key transform: optionally function transforming the attribute values on reading """ args = {} for name, val in list(node.attributes.items()): name = str(name) if transform != Non...
read a dictionnary of attributes :key transform: optionally function transforming the attribute values on reading
readAttrDict
python
pybrain/pybrain
pybrain/tools/customxml/handling.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/handling.py
BSD-3-Clause
def writeAttrDict(self, node, adict, transform = None): """ read a dictionnary of attributes :key transform: optionally transform the attribute values on writing """ for name, val in list(adict.items()): if val != None: if transform != None: node....
read a dictionnary of attributes :key transform: optionally transform the attribute values on writing
writeAttrDict
python
pybrain/pybrain
pybrain/tools/customxml/handling.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/handling.py
BSD-3-Clause
def newChild(self, node, name): """ create a new child of node with the provided name. """ elem = self.dom.createElement(name) node.appendChild(elem) return elem
create a new child of node with the provided name.
newChild
python
pybrain/pybrain
pybrain/tools/customxml/handling.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/handling.py
BSD-3-Clause
def getChild(self, node, name): """ get the child with the given name """ for n in node.childNodes: if name and n.nodeName == name: return n
get the child with the given name
getChild
python
pybrain/pybrain
pybrain/tools/customxml/handling.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/handling.py
BSD-3-Clause
def findNode(self, name, index = 0, root = None): """ return the toplevel node with the provided name (if there are more, choose the index corresponding one). """ if root == None: root = self.root for n in root.childNodes: if n.nodeName == name: if...
return the toplevel node with the provided name (if there are more, choose the index corresponding one).
findNode
python
pybrain/pybrain
pybrain/tools/customxml/handling.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/handling.py
BSD-3-Clause
def findNamedNode(self, name, nameattr, root = None): """ return the toplevel node with the provided name, and the fitting 'name' attribute. """ if root == None: root = self.root for n in root.childNodes: if n.nodeName == name: # modif JPQ # if 'name' in n....
return the toplevel node with the provided name, and the fitting 'name' attribute.
findNamedNode
python
pybrain/pybrain
pybrain/tools/customxml/handling.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/handling.py
BSD-3-Clause
def baseTransform(val): """ back-conversion: modules are encoded by their name and classes by the classname """ from pybrain.structure.modules.module import Module from inspect import isclass if isinstance(val, Module): return val.name elif isclass(val): return val.__name__ ...
back-conversion: modules are encoded by their name and classes by the classname
baseTransform
python
pybrain/pybrain
pybrain/tools/customxml/handling.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/handling.py
BSD-3-Clause
def readFrom(filename, name = None, index = 0): """ append the network to an existing xml file :key name: if this parameter is specified, read the network with this name :key index: which network in the file shall be read (if there is more than one) """ r = NetworkReader(filenam...
append the network to an existing xml file :key name: if this parameter is specified, read the network with this name :key index: which network in the file shall be read (if there is more than one)
readFrom
python
pybrain/pybrain
pybrain/tools/customxml/networkreader.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/networkreader.py
BSD-3-Clause
def appendToFile(net, filename): """ append the network to an existing xml file """ w = NetworkWriter(filename, newfile = False) netroot = w.newRootNode('Network') w.writeNetwork(net, netroot) w.save()
append the network to an existing xml file
appendToFile
python
pybrain/pybrain
pybrain/tools/customxml/networkwriter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/networkwriter.py
BSD-3-Clause
def writeToFile(net, filename): """ write the network as a new xml file """ w = NetworkWriter(filename, newfile = True) netroot = w.newRootNode('Network') w.writeNetwork(net, netroot) w.save()
write the network as a new xml file
writeToFile
python
pybrain/pybrain
pybrain/tools/customxml/networkwriter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/networkwriter.py
BSD-3-Clause
def writeNetwork(self, net, netroot): """ write a Network into a new XML node """ netroot.setAttribute('name', net.name) netroot.setAttribute('class', canonicClassString(net)) if net.argdict: self.writeArgs(netroot, net.argdict) # the modules mods = self.newC...
write a Network into a new XML node
writeNetwork
python
pybrain/pybrain
pybrain/tools/customxml/networkwriter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/networkwriter.py
BSD-3-Clause
def writeBuildable(self, rootnode, m): """ store the class (with path) and name in a new child. """ mname = m.__class__.__name__ mnode = self.newChild(rootnode, mname) mnode.setAttribute('name', m.name) mnode.setAttribute('class', canonicClassString(m)) if m.argdict: ...
store the class (with path) and name in a new child.
writeBuildable
python
pybrain/pybrain
pybrain/tools/customxml/networkwriter.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/customxml/networkwriter.py
BSD-3-Clause
def makeMnistDataSets(path): """Return a pair consisting of two datasets, the first being the training and the second being the test dataset.""" test = SupervisedDataSet(28 * 28, 10) test_image_file = os.path.join(path, 't10k-images-idx3-ubyte') test_label_file = os.path.join(path, 't10k-labels-idx1...
Return a pair consisting of two datasets, the first being the training and the second being the test dataset.
makeMnistDataSets
python
pybrain/pybrain
pybrain/tools/datasets/mnist.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/datasets/mnist.py
BSD-3-Clause
def plot_module_classification_sequence_performance(module, dataset, sequence_index, bounds=(0, 1)): """Plot all outputs and fill the value of the output of the correct category. The grapth of a good classifier should be like all white, with all other values very low. A graph with lot of black ...
Plot all outputs and fill the value of the output of the correct category. The grapth of a good classifier should be like all white, with all other values very low. A graph with lot of black is a bad sign. :param module: The module/network to plot. :type module: pybrain.structure.modul...
plot_module_classification_sequence_performance
python
pybrain/pybrain
pybrain/tools/plotting/classification.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/classification.py
BSD-3-Clause
def plot_module_classification_dataset_performance(module, dataset, cols=4, bounds=(0, 1)): """Do a plot_module_classification_sequence_performance() for all sequences in the dataset. :param module: The module/network to plot. :type module: pybrain.structure.modules.module.Module :param ...
Do a plot_module_classification_sequence_performance() for all sequences in the dataset. :param module: The module/network to plot. :type module: pybrain.structure.modules.module.Module :param dataset: Training dataset used as inputs and expected outputs. :type dataset: SequenceClassific...
plot_module_classification_dataset_performance
python
pybrain/pybrain
pybrain/tools/plotting/classification.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/classification.py
BSD-3-Clause
def punchcard_module_classification_performance(module, dataset, s=800): """Punshcard-like clasification performances.__add__( Actual dataset target vs. estimated target by the module. The graph of a good classfier module should a have no red dots visible: - Red Dots: Target (only visib...
Punshcard-like clasification performances.__add__( Actual dataset target vs. estimated target by the module. The graph of a good classfier module should a have no red dots visible: - Red Dots: Target (only visible if the black dot doesn't cover it). - Green Dots: Estimated classes confi...
punchcard_module_classification_performance
python
pybrain/pybrain
pybrain/tools/plotting/classification.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/classification.py
BSD-3-Clause
def calculate_module_output_mean(module, inputs): """Returns the mean of the module's outputs for a given input list.""" outputs = np.zeros(module.outdim) module.reset() for inpt in inputs: outputs += module.activate(inpt) return outputs / len(...
Returns the mean of the module's outputs for a given input list.
calculate_module_output_mean
python
pybrain/pybrain
pybrain/tools/plotting/classification.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/classification.py
BSD-3-Clause
def __init__(self, mat, cmap=None, pixelspervalue=20, minvalue=None, maxvalue=None): """ Make a colormap image of a matrix :key mat: the matrix to be used for the colormap. """ if minvalue == None: minvalue = amin(mat) if maxvalue == None: maxvalue = amax...
Make a colormap image of a matrix :key mat: the matrix to be used for the colormap.
__init__
python
pybrain/pybrain
pybrain/tools/plotting/colormaps.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/colormaps.py
BSD-3-Clause
def __init__(self, f, xmin= -1, xmax=1, ymin= -1, ymax=1, precision=50, newfig=True, colorbar=False, cblabel=None): """ :key precision: how many steps along every dimension """ if isinstance(f, FunctionEnvironment): assert f.xdim == 2 self.f = lambda x, y: f(arra...
:key precision: how many steps along every dimension
__init__
python
pybrain/pybrain
pybrain/tools/plotting/fitnesslandscapes.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/fitnesslandscapes.py
BSD-3-Clause
def _generateValMap(self): """ generate the function fitness values for the current grid of x and y """ vals = zeros((len(self.xs), len(self.ys))) for i, x in enumerate(self.xs): for j, y in enumerate(self.ys): vals[j, i] = self.f(x, y) return vals
generate the function fitness values for the current grid of x and y
_generateValMap
python
pybrain/pybrain
pybrain/tools/plotting/fitnesslandscapes.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/fitnesslandscapes.py
BSD-3-Clause
def plotAll(self, levels=50, popup=True): """ :key levels: how many fitness levels should be drawn.""" tmp = contour(self.xs, self.ys, self.zs, levels) if self.colorbar: cb = colorbar(tmp) if self.cblabel != None: cb.set_label(self.cblabel) if pop...
:key levels: how many fitness levels should be drawn.
plotAll
python
pybrain/pybrain
pybrain/tools/plotting/fitnesslandscapes.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/fitnesslandscapes.py
BSD-3-Clause
def addSamples(self, samples, rescale=True, color=''): """plot some sample points on the fitness landscape. :key rescale: should the plotting ranges be adjusted? """ # split samples into x and y sx = zeros(len(samples)) sy = zeros(len(samples)) for i, s in enumerate(samp...
plot some sample points on the fitness landscape. :key rescale: should the plotting ranges be adjusted?
addSamples
python
pybrain/pybrain
pybrain/tools/plotting/fitnesslandscapes.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/fitnesslandscapes.py
BSD-3-Clause
def plotFitnessProgession(fitdict, batchsize=1, semilog=True, targetcutoff=1e-10, minimize=True, title=None, verbose=True, varyplotsymbols=False, averageOverEvaluations=True, onlysuccessful=...
Plot multiple fitness curves on a single figure, with the following customizations: :arg fitdict: a dictionary mapping a name to a list of fitness-arrays :key batchsize: the number of evaluations between two points in fitness-arrays specific batch sizes can also be given give...
plotFitnessProgession
python
pybrain/pybrain
pybrain/tools/plotting/fitnessprogression.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/fitnessprogression.py
BSD-3-Clause
def relevantPart(l): """ the part of the vector that's above the cutoff. """ if targetcutoff != None: for i, val in enumerate(l): if minimize and val <= targetcutoff: return l[:i + 1] elif not minimize and val >= targetcutoff: ...
the part of the vector that's above the cutoff.
relevantPart
python
pybrain/pybrain
pybrain/tools/plotting/fitnessprogression.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/fitnessprogression.py
BSD-3-Clause
def __init__(self, maxLines=1, autoscale=0.0, **kwargs): """ :key maxLines: Number of Plots to draw and so max ID. :key autoscale: If set to a factor > 1, axes are automatically expanded whenever out-range data points are added :var indexList: The x-component of the data points :var DataList: Th...
:key maxLines: Number of Plots to draw and so max ID. :key autoscale: If set to a factor > 1, axes are automatically expanded whenever out-range data points are added :var indexList: The x-component of the data points :var DataList: The y-component of the data points
__init__
python
pybrain/pybrain
pybrain/tools/plotting/multiline.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/multiline.py
BSD-3-Clause
def _checkMaxId(self, id): """ Appends additional lines as necessary :key id: Lines up to this id are added automatically """ if id >= self.nbLines: for i in range(self.nbLines, id + 1): # create a new line with corresponding x/y data, and attach it to the plot ...
Appends additional lines as necessary :key id: Lines up to this id are added automatically
_checkMaxId
python
pybrain/pybrain
pybrain/tools/plotting/multiline.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/multiline.py
BSD-3-Clause
def addData(self, id0, x, y): """ The given data point or points is appended to the given line. :key id0: The plot ID (counted from 0) the data point(s) belong to. :key x: The x-component of the data point(s) :key y: The y-component of the data point(s)""" id = id0 + self.offset if ...
The given data point or points is appended to the given line. :key id0: The plot ID (counted from 0) the data point(s) belong to. :key x: The x-component of the data point(s) :key y: The y-component of the data point(s)
addData
python
pybrain/pybrain
pybrain/tools/plotting/multiline.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/multiline.py
BSD-3-Clause
def setData(self, id0, x, y): """ Data series id0 is replaced by the given lists :key id0: The plot ID (counted from 0) the data point(s) belong to. :key x: The x-component of the data points :key y: The y-component of the data points""" id = id0 + self.offset self._checkMaxId(id) ...
Data series id0 is replaced by the given lists :key id0: The plot ID (counted from 0) the data point(s) belong to. :key x: The x-component of the data points :key y: The y-component of the data points
setData
python
pybrain/pybrain
pybrain/tools/plotting/multiline.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/multiline.py
BSD-3-Clause
def saveData(self, filename): """ Writes the data series for all points to a file :key filename: The name of the output file """ file = open(filename, "w") for i in range(self.nbLines): datLen = len(self.indexList[i]) for j in range(datLen): file.writ...
Writes the data series for all points to a file :key filename: The name of the output file
saveData
python
pybrain/pybrain
pybrain/tools/plotting/multiline.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/multiline.py
BSD-3-Clause
def setLineStyle(self, id=None, **kwargs): """ hand parameters to the specified line(s), and set them as default for new lines :key id: The line or lines (list!) to be modified - defaults to last one added """ if id is None: id = self.currentID if isinstance(id, list) | isinsta...
hand parameters to the specified line(s), and set them as default for new lines :key id: The line or lines (list!) to be modified - defaults to last one added
setLineStyle
python
pybrain/pybrain
pybrain/tools/plotting/multiline.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/multiline.py
BSD-3-Clause
def update(self): """ Updates the current plot, if necessary """ if not self.replot: return xr = list(self.Axes.get_xlim()) yr = list(self.Axes.get_ylim()) for i in range(self.nbLines): self.Lines[i].set_data(self.indexList[i], self.dataList[i]) ...
Updates the current plot, if necessary
update
python
pybrain/pybrain
pybrain/tools/plotting/multiline.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/multiline.py
BSD-3-Clause
def show(self, xLabel='', yLabel='', Title='', popup=False, imgfile=None): """ Plots the data internally and saves an image of it to the plotting directory. :key title: The title of the plot. :key xLable: The label for the x-axis :key yLable: The label for the y-axis :key popup: also produce a ...
Plots the data internally and saves an image of it to the plotting directory. :key title: The title of the plot. :key xLable: The label for the x-axis :key yLable: The label for the y-axis :key popup: also produce a popup window with the image?
show
python
pybrain/pybrain
pybrain/tools/plotting/multiline.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/multiline.py
BSD-3-Clause
def plotVariations(datalist, titles, genFun, varyperplot=None, prePlotFun=None, postPlotFun=None, _differentiator=0.0, **optionlists): """ A tool for quickly generating a lot of variations of a plot. Generates a number of figures from a list of data (and titles). For each data item it pro...
A tool for quickly generating a lot of variations of a plot. Generates a number of figures from a list of data (and titles). For each data item it produces one or more figures, each with one or more plots, while varying all options in optionlists (trying all combinations). :arg genFun: is the function ...
plotVariations
python
pybrain/pybrain
pybrain/tools/plotting/quickvariations.py
https://github.com/pybrain/pybrain/blob/master/pybrain/tools/plotting/quickvariations.py
BSD-3-Clause
def iterRbms(self): """Yield every two layers as an rbm.""" layers = [i for i in self.net.modulesSorted if isinstance(i, NeuronLayer) and not isinstance(i, BiasUnit)] # There will be a single bias. bias = [i for i in self.net.modulesSorted if isinstance(i, BiasUnit)][0]...
Yield every two layers as an rbm.
iterRbms
python
pybrain/pybrain
pybrain/unsupervised/trainers/deepbelief.py
https://github.com/pybrain/pybrain/blob/master/pybrain/unsupervised/trainers/deepbelief.py
BSD-3-Clause
def trainOnDataset(self, dataset): """This function trains the RBM using the same algorithm and implementation presented in: http://www.cs.toronto.edu/~hinton/MatlabForSciencePaper.html""" cfg = self.cfg for rows in dataset.randomBatches(self.datasetField, cfg.batchSize): ...
This function trains the RBM using the same algorithm and implementation presented in: http://www.cs.toronto.edu/~hinton/MatlabForSciencePaper.html
trainOnDataset
python
pybrain/pybrain
pybrain/unsupervised/trainers/rbm.py
https://github.com/pybrain/pybrain/blob/master/pybrain/unsupervised/trainers/rbm.py
BSD-3-Clause
def calcUpdateByRow(self, row): """This function trains the RBM using only one data row. Return a 3-tuple consiting of updates for (weightmatrix, hidden bias weights, visible bias weights).""" # a) positive phase poshp = self.rbm.activate(row) # compute the posterior probability...
This function trains the RBM using only one data row. Return a 3-tuple consiting of updates for (weightmatrix, hidden bias weights, visible bias weights).
calcUpdateByRow
python
pybrain/pybrain
pybrain/unsupervised/trainers/rbm.py
https://github.com/pybrain/pybrain/blob/master/pybrain/unsupervised/trainers/rbm.py
BSD-3-Clause
def calcUpdateByRows(self, rows): """Return a 3-tuple constisting of update for (weightmatrix, hidden bias weights, visible bias weights).""" delta_w, delta_hb, delta_vb = \ zeros((self.rbm.visibleDim, self.rbm.hiddenDim)), \ zeros(self.rbm.hiddenDim), zeros(self.rbm.vis...
Return a 3-tuple constisting of update for (weightmatrix, hidden bias weights, visible bias weights).
calcUpdateByRows
python
pybrain/pybrain
pybrain/unsupervised/trainers/rbm.py
https://github.com/pybrain/pybrain/blob/master/pybrain/unsupervised/trainers/rbm.py
BSD-3-Clause
def __init__(self, layer, num_layers, encoder_type=None): ''' @param layer: one encoder layer, i.e., self-attention layer @param num_layers: number of self-attention layers @param encoder_type: type differentiation ''' super(Encoder, self).__init__() self.encoder_...
@param layer: one encoder layer, i.e., self-attention layer @param num_layers: number of self-attention layers @param encoder_type: type differentiation
__init__
python
wildltr/ptranking
ptranking/base/list_ranker.py
https://github.com/wildltr/ptranking/blob/master/ptranking/base/list_ranker.py
MIT