<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> from pybrain . tests import runModuleTestSuite <EOL> from pybrain . structure . networks import BorderSwipingNetwork <EOL> from pybrain import ModuleMesh , LinearLayer , TanhLayer <EOL> def nearlyEqual ( lst1 , lst2 , tolerance = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> return all ( abs ( i - j ) <= tolerance for i , j in zip ( lst1 , lst2 ) ) <EOL> def buildSimpleBorderSwipingNet ( size = <NUM_LIT:3> , dim = <NUM_LIT:3> , hsize = <NUM_LIT:1> , predefined = { } ) : <EOL> """<STR_LIT>""" <EOL> dims = tuple ( [ size ] * dim ) <EOL> hdims = tuple ( list ( dims ) + [ <NUM_LIT:2> ** dim ] ) <EOL> inmod = LinearLayer ( size ** dim , name = '<STR_LIT:input>' ) <EOL> inmesh = ModuleMesh . viewOnFlatLayer ( inmod , dims , '<STR_LIT>' ) <EOL> outmod = LinearLayer ( size ** dim , name = '<STR_LIT>' ) <EOL> outmesh = ModuleMesh . viewOnFlatLayer ( outmod , dims , '<STR_LIT>' ) <EOL> hiddenmesh = ModuleMesh . constructWithLayers ( TanhLayer , hsize , hdims , '<STR_LIT>' ) <EOL> return BorderSwipingNetwork ( inmesh , hiddenmesh , outmesh , predefined = predefined ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> runModuleTestSuite ( __import__ ( '<STR_LIT:__main__>' ) ) </s>
