class_docstr: Neural Network. Deep Learning base model.
  
  Parameters:
  -----------
  optimizer: class
      The weight optimizer that will be used to tune the weights in order of minimizing
      the loss.
  loss: class
      Loss function used to measure the model's performance. SquareLoss or CrossEntropy.
  validation: tuple
      A tuple containing validation data and labels (X, y)
class_docstr_tok: ["Neural","Network",".","Deep","Learning","base","model",".","Parameters",":","--","--","--","--","--","-","optimizer",":","class","The","weight","optimizer","that","will","be","used","to","tune","the","weights","in","order","of","minimizing","the","loss",".","loss",":","class","Loss","function","used","to","measure","the","model","'s","performance",".","SquareLoss","or","CrossEntropy",".","validation",":","tuple","A","tuple","containing","validation","data","and","labels","(","X",",","y",")"]
docstr: Trains the model for a fixed number of epochs 
docstr_tok: ["Trains","the","model","for","a","fixed","number","of","epochs"]
code: def fit(self, X, y, n_epochs, batch_size):
      """Trains the model for a fixed number of epochs"""
      for _ in self.progressbar(range(n_epochs)):
          batch_error = []
          for X_batch, y_batch in batch_iterator(
              X, y, batch_size=batch_size
          ):
              loss, _ = self.train_on_batch(X_batch, y_batch)
              batch_error.append(loss)
  
          self.errors["training"].append(np.mean(batch_error))
  
          if self.val_set is not None:
              val_loss, _ = self.test_on_batch(
                  self.val_set["X"], self.val_set["y"]
              )
              self.errors["validation"].append(val_loss)
  
      return self.errors["training"], self.errors["validation"]
  
file_path: ML-From-Scratch/mlfromscratch/deep_learning/neural_network.py
imports: from __future__ import print_function, division
  from terminaltables import AsciiTable
  import numpy
  import progressbar
  from mlfromscratch.utils import batch_iterator
  from mlfromscratch.utils.misc import bar_widgets
label_desc: Use image node_id 6 for calling the NeuralNetwork obj's underlying member method code with example usage: obj.fit(X, y, n_epochs, batch_size) and returns: self,  self