<s> from __future__ import print_function <EOL> __author__ = '<STR_LIT>' <EOL> from pylab import plot , show , ion , cla , subplot , title , figlegend , draw <EOL> import numpy <EOL> from pybrain . structure . modules . evolinonetwork import EvolinoNetwork <EOL> from pybrain . supervised . trainers . evolino import EvolinoTrainer <EOL> from lib . data_generator import generateSuperimposedSineData <EOL> print ( ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( ) <EOL> sinefreqs = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> metascale = <NUM_LIT> <EOL> scale = <NUM_LIT:0.5> * metascale <EOL> stepsize = <NUM_LIT:0.1> * metascale <EOL> print ( "<STR_LIT>" ) <EOL> trnInputSpace = numpy . arange ( <NUM_LIT:0> * scale , <NUM_LIT> * scale , stepsize ) <EOL> trnData = generateSuperimposedSineData ( sinefreqs , trnInputSpace ) <EOL> print ( "<STR_LIT>" ) <EOL> tstInputSpace = numpy . arange ( <NUM_LIT> * scale , <NUM_LIT> * scale , stepsize ) <EOL> tstData = generateSuperimposedSineData ( sinefreqs , tstInputSpace ) <EOL> print ( "<STR_LIT>" ) <EOL> net = EvolinoNetwork ( trnData . outdim , <NUM_LIT> ) <EOL> wtRatio = <NUM_LIT:1.> / <NUM_LIT> <EOL> print ( "<STR_LIT>" ) <EOL> trainer = EvolinoTrainer ( <EOL> net , <EOL> dataset = trnData , <EOL> subPopulationSize = <NUM_LIT:20> , <EOL> nParents = <NUM_LIT:8> , <EOL> nCombinations = <NUM_LIT:1> , <EOL> initialWeightRange = ( - <NUM_LIT> , <NUM_LIT> ) , <EOL> backprojectionFactor = <NUM_LIT> , <EOL> mutationAlpha = <NUM_LIT> , <EOL> nBurstMutationEpochs = numpy . Infinity , <EOL> wtRatio = wtRatio , <EOL> verbosity = <NUM_LIT:2> ) <EOL> trnSequence = trnData . getField ( '<STR_LIT:target>' ) <EOL> separatorIdx = int ( len ( trnSequence ) * wtRatio ) <EOL> trnSequenceWashout = trnSequence [ <NUM_LIT:0> : separatorIdx ] <EOL> trnSequenceTarget = trnSequence [ separatorIdx : ] <EOL> tstSequence = tstData . getField ( '<STR_LIT:target>' ) <EOL> separatorIdx = int ( len ( tstSequence ) * wtRatio ) <EOL> tstSequenceWashout = tstSequence [ <NUM_LIT:0> : separatorIdx ] <EOL> tstSequenceTarget = tstSequence [ separatorIdx : ] <EOL> ion ( ) <EOL> for i in range ( <NUM_LIT> ) : <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> trainer . trainEpochs ( <NUM_LIT:1> ) <EOL> print ( "<STR_LIT>" ) <EOL> trnSequenceOutput = net . extrapolate ( trnSequenceWashout , len ( trnSequenceTarget ) ) <EOL> tstSequenceOutput = net . extrapolate ( tstSequenceWashout , len ( tstSequenceTarget ) ) <EOL> sp = subplot ( <NUM_LIT> ) <EOL> cla ( ) <EOL> title ( "<STR_LIT>" ) <EOL> sp . set_autoscale_on ( True ) <EOL> targetline = plot ( trnSequenceTarget , "<STR_LIT>" ) <EOL> sp . set_autoscale_on ( False ) <EOL> outputline = plot ( trnSequenceOutput , "<STR_LIT>" ) <EOL> sp = subplot ( <NUM_LIT> ) <EOL> cla ( ) <EOL> title ( "<STR_LIT>" ) <EOL> sp . set_autoscale_on ( True ) <EOL> plot ( tstSequenceTarget , "<STR_LIT>" ) <EOL> sp . set_autoscale_on ( False ) <EOL> plot ( tstSequenceOutput , "<STR_LIT>" ) <EOL> figlegend ( ( targetline , outputline ) , ( '<STR_LIT:target>' , '<STR_LIT>' ) , ( '<STR_LIT>' ) ) <EOL> draw ( ) <EOL> show ( ) </s>
