docs: def saveWeights(self, filename, mode='pickle', counter=None):
          """
          Saves weights to file in pickle, plain, or tlearn mode.
          """
          # modes: pickle/conx, plain, tlearn
          if "?" in filename: # replace ? pattern in filename with epoch number
              import re
              char = "?"
              match = re.search(re.escape(char) + "+", filename)
              if match:
                  num = self.epoch
                  if counter != None:
                      num = counter
                  elif self.totalEpoch != 0: # use a total epoch, if one:
                      num = self.totalEpoch
                  fstring = "%%0%dd" % len(match.group())
                  filename = filename[:match.start()] + \
                             fstring % self.epoch + \
                             filename[match.end():]
                  self.lastAutoSaveWeightsFilename = filename
          if mode == 'pickle':
              mylist = self.arrayify()
              import pickle
              fp = open(filename, "w")
              pickle.dump(mylist, fp)
              fp.close()
          elif mode in ['plain', 'conx']:
              fp = open(filename, "w")
              fp.write("# Biases\n")
              for layer in self.layers:
                  if layer.type != 'Input':
                      fp.write("# Layer: " + layer.name + "\n")
                      for i in range(layer.size):
                          fp.write("%f " % layer.weight[i] )
                      fp.write("\n")
              fp.write("# Weights\n")
              for connection in self.connections:
                  fp.write("# from " + connection.fromLayer.name + " to " +
                           connection.toLayer.name + "\n")
                  for i in range(connection.fromLayer.size):
                      for j in range(connection.toLayer.size):
                          fp.write("%f " % connection.weight[i][j] )
                      fp.write("\n")
              fp.close()
          elif mode == 'tlearn':
              fp = open(filename, "w")
              fp.write("NETWORK CONFIGURED BY TLEARN\n")
              fp.write("# weights after %d sweeps\n" % self.epoch)
              fp.write("# WEIGHTS\n")
              cnt = 1
              for lto in self.layers:
                  if lto.type != 'Input':
                      for j in range(lto.size):
                          fp.write("# TO NODE %d\n" % cnt)
                          fp.write("%f\n" % lto.weight[j] )
                          for lfrom in self.layers:
                              try:
                                  connection = self.getConnection(lfrom.name,lto.name)
                                  for i in range(connection.fromLayer.size):
                                      fp.write("%f\n" % connection.weight[i][j])
                              except NetworkError: # should return an exception here
                                  for i in range(lfrom.size):
                                      fp.write("%f\n" % 0.0)
                          cnt += 1
              fp.close()            
          else:
              raise ValueError('Unknown mode in saveWeights().', mode)