docs: def verifyArchitecture(self):
          """
          Check for orphaned layers or connections. Assure that network
          architecture is feed-forward (no-cycles). Check connectivity. Check naming.
          """
          if len(self.cacheLayers) != 0 or len(self.cacheConnections) != 0: return
          # flags for layer type tests
          hiddenInput = 1
          hiddenOutput = 1       
          outputLayerFlag = 1  
          inputLayerFlag = 1
          # must have layers and connections
          if len(self.layers) == 0:
              raise NetworkError('No network layers.', \
                                   self.layers)
          if len(self.connections) == 0:
              raise NetworkError('No network connections.', \
                                   self.connections)
          # layers should not have the same name
          for x, y in [(x, y) for x in range(len(self.layers)) for y in range(len(self.layers))]:
              if x == y:
                  pass # same layer so same name
              else:
                  # different layers same name
                  if self.layers[x].name == self.layers[y].name:
                      raise NetworkError('Two layers have the same name.', (x,y))
          # no multiple connections between layers
          for x, y in [(x,y) for x in range(len(self.connections)) for y in range(len(self.connections))]:
              if x == y:
                  pass # same connection
              else:
                  # multiple connections between fromLayer and toLayer
                  if self.connections[x].fromLayer.name == self.connections[y].fromLayer.name and \
                     self.connections[x].toLayer.name == self.connections[y].toLayer.name:
                      raise NetworkError('Multiple connections between two layers.', \
                                           (self.connections[x].fromLayer.name, \
                                            self.connections[x].toLayer.name))
          # layer type tests
          for layer in self.layers:
              # no undefined layers
              if layer.type == 'Undefined':
                  raise NetworkError('There is an unconnected layer.', layer.name)
              elif layer.type == 'Input':
                  for connection in self.connections:
                      # input layers must have outgoing connections 
                      if connection.fromLayer.name == layer.name:
                          inputLayerFlag = 0
                      # input layers must have no incoming connections
                      if connection.toLayer.name == layer.name:
                          raise NetworkError('Layer has type \'Input\' and an incoming connection.', layer.name)
                  if inputLayerFlag:
                      raise NetworkError('Layer has type \'Input\' but no outgoing connections', layer.name)
              elif layer.type == 'Output':
                  for connection in self.connections:
                      # output layers must have no outgoing connections`
                      if connection.fromLayer.name == layer.name:
                          raise NetworkError('Layer has type \'Output\' and an outgoing connections.',layer.name)
                      # output layers must have an incoming connection
                      if connection.toLayer.name == layer.name:
                          outputLayerFlag = 0
                  if outputLayerFlag:
                      raise NetworkError('Layer has type \'Output\' and no incoming connections.', layer.name)           
              elif layer.type == 'Hidden':
                  for connection in self.connections:
                      # hidden layers must have incoming and outgoing connections.
                      if connection.toLayer.name == layer.name:
                          hiddenInput = 0
                      if connection.fromLayer.name == layer.name:
                          hiddenOutput = 0
                  if hiddenInput or hiddenOutput:
                      raise NetworkError('Layer has type \'Hidden\' but does not have both input and output connections.',\
                             layer.name)
              else:
                  raise LayerError('Unknown layer encountered in verifyArchitecture().', layer.name)
          # network should not have unconnected sub networks
          # every input layer should have a path to every output layer
          for inLayer in self.layers:
              if inLayer.type == 'Input':
                  for outLayer in self.layers:
                      if outLayer.type == 'Output':
                          if not self.path(inLayer, outLayer):
                              raise NetworkError('Network contains disconnected sub networks.', \
                                                   (inLayer.name, outLayer.name))
          # network should not have directed cycles
          for layer in self.layers:
              if self.path(layer, layer):
                  raise NetworkError('Network contains a cycle.', layer.name)