Package pyrobot :: Package brain :: Module conx :: Class SRN
[frames | no frames]

Class SRN

Network --+
          |
         SRN

Known Subclasses:
GovernorSRN

A subclass of Network. SRN allows for simple recursive networks by
copying hidden activations back to a context layer. This subclass
adds support for sequencing, prediction, and context layers.

Method Summary
  __init__(self, name, verbosity)
Constructor for SRN sub-class.
  addContext(self, layer, hiddenLayerName, verbosity)
Adds a context layer.
  addContextLayer(self, name, size, hiddenLayerName, verbosity)
  addSRNLayers(self, inc, hidc, outc)
Wraps SRN.addThreeLayers() for compatibility.
  addThreeLayers(self, inc, hidc, outc)
Creates a three level network with a context layer.
  backprop(self)
Extends backprop() from Network to automatically deal with context layers.
  copyHiddenToContext(self)
Uses key to identify the hidden layer associated with each layer in the self.contextLayers dictionary.
  networkStep(self, **args)
This exists so that other extensions can interface at the point where the call is made to Network.step().
  predict(self, inName, outName)
Sets prediction between an input and output layer.
  propagate(self, **args)
SRN.propagate: Sets error flags and propagates.
  setContext(self, value)
Clears the context layer by setting context layer to (default) value 0.5.
  setInitContext(self, value)
Clear context layer between sequences.
  setLearnDuringSequence(self, value)
Set self.learnDuringSequence.
  setSequenceType(self, value)
You must set this! Set it to "epoch" or "pattern".
  step(self, **args)
SRN.step() Extends network step method by automatically copying hidden layer activations to the context layer.
  sweepCrossValidation(self)
sweepCrossValidation() will go through each of the crossvalidation input/targets.
    Inherited from Network
  __getitem__(self, name)
Returns the layer specified by name.
  __len__(self)
Returns the number of layers in the network.
  __str__(self)
Returns string representation of network.
  activationFunction(self, x)
Determine the activation of a node based on that nodes net input.
  ACTPRIME(self, act)
Used in compute_error.
  add(self, layer, verbosity)
Adds a layer.
  addLayer(self, name, size, verbosity)
  addPattern(self, word, vector)
Adds a pattern with key word.
  arrayify(self)
Returns an array of node bias values and connection weights for use in a GA.
  associate(self, inName, outName)
inName layer and outName layer will be auto-associating.
  ce_init(self)
Initializes error computation.
  change_weights(self)
Changes the weights according to the error values calculated during backprop().
  changeLayerSize(self, layername, newsize)
Changes layer size.
  closeLog(self, layerName)
Close the layerName's log file.
  compare(self, v1, v2)
Compares two values.
  compute_error(self)
Computes error for all non-output layers backwards through all projections.
  compute_wed(self)
Computes weight error derivative for all connections in self.connections starting with the last connection.
  connect(self, fromName, toName)
Connects two layers by instantiating an instance of Connection class.
  copyActivations(self, layer, vec, start)
Copies activations in vec to the specified layer, replacing patterns if necessary.
  copyTargets(self, layer, vec, start)
Copies targets in vec to specified layer, replacing patterns if necessary.
  copyVector(self, vector1, vec2, start)
Copies vec2 into vector1 being sure to replace patterns if necessary.
  cycle(self)
Alternate to sweep().
  delPattern(self, word)
Delete a pattern with key word.
  diff(self, value)
Returns value to within 0.001.
  display(self)
Displays the network to the screen.
  getActivationsDict(self, nameList)
Returns a dictionary of layer names that map to a list of activations.
  getActive(self, layerName)
Returns the value of the active flag for the layer specified by layerName.
  getConnection(self, lfrom, lto)
Returns the connection instance connecting the specified (string) layer names.
  getCorrect(self, layerName)
Returns the number of correct activation within tolerance of a layer.
  getData(self, pos)
Returns dictionary with input and target given pos.
  getDataCrossValidation(self, pos)
  getEpsilon(self)
Returns the epsilon for the Network instance.
  getError(self, *layerNames)
  getLayer(self, name)
Returns the layer with the argument (string) name.
  getLayerIndex(self, layer)
Given a reference to a layer, returns the index of that layer in self.layers.
  getPattern(self, word)
Returns the pattern with key word.
  getWeights(self, fromName, toName)
Gets the weights of the connection between two layers (argument strings).
  getWord(self, pattern)
Returns the word associated with pattern.
  initialize(self)
Initializes network by calling Connection.initialize() and Layer.initialize().
  loadCrossValidation(self, filename)
  loadDataFromFile(self, filename, ocnt)
Loads data (targets/inputs) from file.
  loadInputPatternsFromFile(self, filename, cols, everyNrows, delim, checkEven)
Loads inputs as patterns from file.
  loadInputsFromFile(self, filename, cols, everyNrows, delim, checkEven)
Loads inputs from file.
  loadTargetPatternssFromFile(self, filename, cols, everyNrows, delim, checkEven)
Loads targets as patterns from file.
  loadTargetsFromFile(self, filename, cols, everyNrows, delim, checkEven)
Loads targets from file.
  loadVectorsFromFile(self, filename, cols, everyNrows, delim, checkEven, patterned)
Load a set of vectors from a file.
  loadWeightsFromFile(self, filename, mode)
Loads weights from a file in pickle, plain, or tlearn mode.
  logLayer(self, layerName, fileName)
Sets the layerName's log feature.
  logMsg(self, layerName, message)
Logs a message with layerName log.
  mapInput(self, layerName, offset)
Adds layerName and offset to inputMap.
  mapInputs(self, nameOffsetPairs)
  mapTarget(self, layerName, offset)
Adds layerName and offset to targetMap.
  mapTargets(self, nameOffsetPairs)
  path(self, startLayer, endLayer)
Used in error checking with verifyArchitecture() and in prop_from().
  patternVector(self, vector)
Replaces vector with patterns.
  postStep(self)
  postSweep(self)
  preStep(self)
  preSweep(self)
  Print(self, msg)
  prompt(self)
  prop_from(self, startLayers)
Start propagation from the layers in the list startLayers.
  propagateFrom(self, startLayer, **args)
Propagates activation through the network.
  putActivations(self, dict)
Puts a dict of name: activations into their respective layers.
  randomizeOrder(self)
Randomizes self.loadOrder, the order in which inputs set with self.setInputs() are presented.
  replacePatterns(self, vector)
Replaces patterned inputs or targets with activation vectors.
  reportEpoch(self, epoch, tssErr, totalCorrect, totalCount, rmsErr)
  reportFinal(self, epoch, tssErr, totalCorrect, totalCount, rmsErr)
  reportPattern(self)
  reportStart(self)
  reset(self)
Resets seed values.
  resetFlags(self)
Resets layer flags for activation and target.
  RMSError(self)
Returns Root Mean Squared Error for all output layers in this network.
  saveDataToFile(self, filename)
Saves data (targets/inputs) to file.
  saveInputsToFile(self, filename)
Saves inputs to file.
  saveNetworkForCrossValidation(self, filename, mode)
  saveNetworkToFile(self, filename, makeWrapper)
Saves network to file using pickle.
  saveTargetsToFile(self, filename)
Saves targets to file.
  saveWeightsToFile(self, filename, mode)
Saves weights to file in pickle, plain, or tlearn mode.
  setActive(self, layerName, value)
Sets a layer to active.
  setAutoCrossValidation(self, value)
  setAutoSaveWeightsFile(self, filename)
  setBatch(self, value)
Sets self.batch to value.
  setEpsilon(self, value)
Sets epsilon value for the network.
  setInputs(self, inputs)
Sets self.input to inputs.
  setInputsAndTargets(self, data1, data2)
Network.setInputsAndTargets() Sets the corpus of data for training.
  setInteractive(self, value)
Sets interactive to value.
  setLayerVerification(self, value)
  setLearning(self, value)
Sets learning to value.
  setMaxRandom(self, value)
Sets the maxRandom Layer attribute for each layer to value.Specifies the global range for randomly initialized values, [-max, max].
  setMomentum(self, value)
Sets self.momentum to value.
  setOrderedInputs(self, value)
Sets self.orderedInputs to value.
  setOutputs(self, outputs)
For compatiblity.
  setPattern(self, word, vector)
Sets a pattern with key word.
  setPatterned(self, value)
Sets the network to use patterns for inputs and targets.
  setPatterns(self, patterns)
Sets patterns to the dictionary argument.
  setReportRate(self, value)
Sets self.reportRate to value.
  setResetEpoch(self, value)
Sets self.resetEpoch to value.
  setResetLimit(self, value)
Sets self.resetLimit to value.
  setSeed(self, value)
Sets the seed to value.
  setSigmoid_prime_offset(self, value)
Sets self.sigmoid_prime_offset to value.
  setStopPercent(self, value)
Sets self.stopPercent to value.
  setSweepReportRate(self, value)
Sets self.sweepReportRate to value.
  setTargets(self, targets)
Sets the targets.
  setTolerance(self, value)
Sets tolerance to value.
  setup(self)
  setUseCrossValidationToStop(self, value)
Sets flag so that self.stopPercent is compared to cross validation percent rather than the regular training data percentage correct.
  setVerbosity(self, value)
Sets self.verbosity and each layer verbosity to value.
  setWeight(self, fromName, fromPos, toName, toPos, value)
Sets the weight of the connection between two layers (argument strings).
  shareWeights(self, network, listOfLayerNamePairs)
Share weights with another network.
  sweep(self)
Runs through entire dataset.
  toString(self)
Returns the network layers as a string.
  train(self, cont)
Trains the network on the dataset till a stopping condition is met.
  TSSError(self, layerName)
Returns Total Sum Squared error for the specified layer's pattern.
  unArrayify(self, gene)
Copies gene bias values and weights to network bias values and weights.
  verifyArchitecture(self)
Check for orphaned layers or connections.
  verifyArguments(self, arg)
Verifies that arguments to setInputs and setTargets are appropriately formatted.
  verifyInputs(self)
Used in propagate() to verify that the network input activations have been set.
  verifyTargets(self)
Used in backprop() to verify that the network targets have been set.

Method Details

__init__(self, name='Simple Recurrent Network', verbosity=0)
(Constructor)

Constructor for SRN sub-class. Support for sequences and prediction added.
Overrides:
pyrobot.brain.conx.Network.__init__

addContext(self, layer, hiddenLayerName='hidden', verbosity=0)

Adds a context layer. Necessary to keep self.contextLayers dictionary up to date.

addSRNLayers(self, inc, hidc, outc)

Wraps SRN.addThreeLayers() for compatibility.

addThreeLayers(self, inc, hidc, outc)

Creates a three level network with a context layer.
Overrides:
pyrobot.brain.conx.Network.addThreeLayers

backprop(self)

Extends backprop() from Network to automatically deal with context
layers. Copies the contexts, if contextCopying is true.
Overrides:
pyrobot.brain.conx.Network.backprop

copyHiddenToContext(self)

Uses key to identify the hidden layer associated with each
layer in the self.contextLayers dictionary.

networkStep(self, **args)

This exists so that other extensions can interface at the point
where the call is made to Network.step(). See governor.py for
an example.

predict(self, inName, outName)

Sets prediction between an input and output layer.

propagate(self, **args)

SRN.propagate: Sets error flags and propagates.
Overrides:
pyrobot.brain.conx.Network.propagate

setContext(self, value=0.5)

Clears the context layer by setting context layer to (default) value 0.5.

setInitContext(self, value)

Clear context layer between sequences.

setLearnDuringSequence(self, value)

Set self.learnDuringSequence.

setSequenceType(self, value)

You must set this! Set it to "epoch" or "pattern".

step(self, **args)

SRN.step()
Extends network step method by automatically copying hidden
layer activations to the context layer.
Overrides:
pyrobot.brain.conx.Network.step

sweepCrossValidation(self)

sweepCrossValidation() will go through each of the crossvalidation input/targets.
The crossValidationCorpus is a list of dictionaries of input/targets
referenced by layername.
Example: ({"input": [0.0, 0.1], "output": [1.0]}, {"input": [0.5, 0.9], "output": [0.0]})
Overrides:
pyrobot.brain.conx.Network.sweepCrossValidation (inherited documentation)

Generated by Epydoc 2.1 on Mon Jul 25 01:39:27 2005 http://epydoc.sf.net