code: def train(self, params):
      
      if params['reset_every_training']:
        n = params['encoding_num']
        self.net = buildNetwork(n, params['num_cells'], n,
                                 hiddenclass=LSTMLayer,
                                 bias=True,
                                 outputbias=params['output_bias'],
                                 recurrent=True)
        self.net.reset()
  
      # prepare training dataset
      ds = SequentialDataSet(params['encoding_num'], params['encoding_num'])
      history = self.window(self.history, params)
      resets = self.window(self.resets, params)
  
      for i in xrange(1, len(history)):
        if not resets[i - 1]:
          ds.addSample(self.encoder.encode(history[i - 1]),
                       self.encoder.encode(history[i]))
        if resets[i]:
          ds.newSequence()
  
      print "Train LSTM network on buffered dataset of length ", len(history)
      if params['num_epochs'] > 1:
        trainer = RPropMinusTrainer(self.net,
                                    dataset=ds,
                                    verbose=params['verbosity'] > 0)
  
        if len(history) > 1:
          trainer.trainEpochs(params['num_epochs'])
  
        # run network on buffered dataset after training to get the state right
        self.net.reset()
        for i in xrange(len(history) - 1):
          symbol = history[i]
          output = self.net.activate(self.encoder.encode(symbol))
          self.encoder.classify(output, num=params['num_predictions'])
  
          if resets[i]:
            self.net.reset()
      else:
        self.trainer.setData(ds)
        self.trainer.train()
  
        # run network on buffered dataset after training to get the state right
        self.net.reset()
        for i in xrange(len(history) - 1):
          symbol = history[i]
          output = self.net.activate(self.encoder.encode(symbol))
          self.encoder.classify(output, num=params['num_predictions'])
  
          if resets[i]:
            self.net.reset()
docs: Train LSTM network on buffered dataset history
      After training, run LSTM on history[:-1] to get the state correct
      :param params:
      :return: