<commit_before>""" A neural network trainer with various options: rmsprop, nerterov, momentum etc.
This trainer is used for multiple types of neural nets: dbns and cnns and it is designed
to be adaptable to other types of networks as well.
"""

__author__ = "<NAME>"
__contact__ = "<EMAIL>"

import numpy as np
import theano
from theano import tensor as T

import debug

DEBUG = False

class BatchTrainer(object):

  def makeTrainFunction(self, x, y, data, labels, trainingOptions):
    error = T.sum(self.cost(y))

    miniBatchIndex = T.lscalar()
    momentum = T.fscalar()

    if DEBUG:
      mode = theano.compile.MonitorMode(post_func=debug.detect_nan).excluding(
                                        'local_elemwise_fusion', 'inplace')
    else:
      mode = None
<commit_msg>Clarifying comment in batch trainer<commit_after>""" A neural network trainer with various options: rmsprop, nerterov, momentum etc.
This trainer is used for multiple types of neural nets: dbns and cnns and it is designed
to be adaptable to other types of networks as well.
"""

__author__ = "<NAME>"
__contact__ = "<EMAIL>"

import numpy as np
import theano
from theano import tensor as T

import debug

DEBUG = False

class BatchTrainer(object):
  """
    Abstract class used to define updates on the parameters of neural networks
    during training.
    Subclasses must have the params field set before using functionality provided
    by this class. Due to momentum, the oldUpdates fields also has to be initialized
    before using this class. In case rmsprop is used, the oldMeanSquares field
    has to be initialized in the subclass before using inherited methods from this class.

    This class supports momentum updates and nesterov updates, both with rmsprop
    or without (see the TrainingOptions class for more details in the available
    training options.
  """

  def makeTrainFunction(self, x, y, data, labels, trainingOptions):
    error = T.sum(self.cost(y))

    miniBatchIndex = T.lscalar()
    momentum = T.fscalar()

    if DEBUG:
      mode = theano.compile.MonitorMode(post_func=debug.detect_nan).excluding(
                                        'local_elemwise_fusion', 'inplace')
    else:
      mode = None

{'fraction_non_alphanumeric': 0.06963162623539983, 'fraction_numerical': 0.0, 'mean_word_length': 3.3581213307240705, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2192665', 'n_tokens_mistral': 615, 'n_tokens_neox': 596, 'n_words': 260}