<s> from __future__ import print_function <EOL> __author__ = '<STR_LIT>' <EOL> from pybrain . structure import FeedForwardNetwork , LinearLayer , SigmoidLayer , FullConnection , RecurrentNetwork <EOL> from pybrain . tools . shortcuts import buildNetwork <EOL> """<STR_LIT>""" <EOL> n = FeedForwardNetwork ( ) <EOL> """<STR_LIT>""" <EOL> inLayer = LinearLayer ( <NUM_LIT:2> ) <EOL> hiddenLayer = SigmoidLayer ( <NUM_LIT:3> ) <EOL> outLayer = LinearLayer ( <NUM_LIT:1> ) <EOL> """<STR_LIT>""" <EOL> n . addInputModule ( inLayer ) <EOL> n . addModule ( hiddenLayer ) <EOL> n . addOutputModule ( outLayer ) <EOL> """<STR_LIT>""" <EOL> in2hidden = FullConnection ( inLayer , hiddenLayer ) <EOL> hidden2out = FullConnection ( hiddenLayer , outLayer ) <EOL> n . addConnection ( in2hidden ) <EOL> n . addConnection ( hidden2out ) <EOL> """<STR_LIT>""" <EOL> n . sortModules ( ) <EOL> """<STR_LIT>""" <EOL> print ( n ) <EOL> """<STR_LIT>""" <EOL> print ( n . activate ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) ) <EOL> """<STR_LIT>""" <EOL> print ( hidden2out . params ) <EOL> print ( n . params ) <EOL> """<STR_LIT>""" <EOL> print ( n . params [ - <NUM_LIT:3> : ] == hidden2out . params ) <EOL> """<STR_LIT>""" <EOL> n2 = RecurrentNetwork ( name = '<STR_LIT>' ) <EOL> n2 . addInputModule ( LinearLayer ( <NUM_LIT:2> , name = '<STR_LIT>' ) ) <EOL> n2 . addModule ( SigmoidLayer ( <NUM_LIT:3> , name = '<STR_LIT:h>' ) ) <EOL> n2 . addOutputModule ( LinearLayer ( <NUM_LIT:1> , name = '<STR_LIT>' ) ) <EOL> n2 . addConnection ( FullConnection ( n2 [ '<STR_LIT>' ] , n2 [ '<STR_LIT:h>' ] , name = '<STR_LIT>' ) ) <EOL> n2 . addConnection ( FullConnection ( n2 [ '<STR_LIT:h>' ] , n2 [ '<STR_LIT>' ] , name = '<STR_LIT>' ) ) <EOL> n2 . sortModules ( ) <EOL> """<STR_LIT>""" <EOL> print ( n2 ) <EOL> """<STR_LIT>""" <EOL> n3 = buildNetwork ( <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:1> , bias = False ) <EOL> """<STR_LIT>""" <EOL> n2 . addRecurrentConnection ( FullConnection ( n2 [ '<STR_LIT:h>' ] , n2 [ '<STR_LIT:h>' ] , name = '<STR_LIT>' ) ) <EOL> """<STR_LIT>""" <EOL> n2 . sortModules ( ) <EOL> print ( n2 ) <EOL> """<STR_LIT>""" <EOL> print ( n2 . activate ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) , end = '<STR_LIT:U+0020>' ) <EOL> print ( n2 . activate ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) , end = '<STR_LIT:U+0020>' ) <EOL> print ( n2 . activate ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) ) <EOL> """<STR_LIT>""" <EOL> n2 . reset ( ) <EOL> print ( n2 . activate ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) , end = '<STR_LIT:U+0020>' ) <EOL> print ( n2 . activate ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) , end = '<STR_LIT:U+0020>' ) <EOL> print ( n2 . activate ( [ <NUM_LIT:1> , <NUM_LIT:2> ] ) ) <EOL> """<STR_LIT>""" </s>
