def _buildNetwork(*layers, **options):
 bias = (options['bias'] if ('bias' in options) else False)
 net = FeedForwardNetwork()
 layerParts = iter(layers)
 firstPart = iter(next(layerParts))
 firstLayer = next(firstPart)
 net.addInputModule(firstLayer)
 prevLayer = firstLayer
 for part in chain(firstPart, layerParts):
  new_part = True
  for layer in part:
   net.addModule(layer)
   if new_part:
    ConnectionClass = FullConnection
    if bias:
     biasUnit = BiasUnit(('BiasUnit for %s' % layer.name))
     net.addModule(biasUnit)
     net.addConnection(FullConnection(biasUnit, layer))
   else:
    ConnectionClass = IdentityConnection
   new_part = False
   conn = ConnectionClass(prevLayer, layer)
   net.addConnection(conn)
   prevLayer = layer
 net.addOutputModule(layer)
 net.sortModules()
 return net

def _buildNetwork ( * layers , ** options ) : bias = ( options [ 'bias' ] if ( 'bias' in options ) else False ) net = FeedForwardNetwork ( ) layerParts = iter ( layers ) firstPart = iter ( next ( layerParts ) ) firstLayer = next ( firstPart ) net . addInputModule ( firstLayer ) prevLayer = firstLayer for part in chain ( firstPart , layerParts ) : new_part = True for layer in part : net . addModule ( layer ) if new_part : ConnectionClass = FullConnection if bias : biasUnit = BiasUnit ( ( 'BiasUnit for %s' % layer . name ) ) net . addModule ( biasUnit ) net . addConnection ( FullConnection ( biasUnit , layer ) ) else : ConnectionClass = IdentityConnection new_part = False conn = ConnectionClass ( prevLayer , layer ) net . addConnection ( conn ) prevLayer = layer net . addOutputModule ( layer ) net . sortModules ( ) return net
this is a helper function to create different kinds of networks .