class_docstr: Implementation of paper "Born Again Neural Networks"
  https://arxiv.org/abs/1805.04770
  
  :param student_model (torch.nn.Module): Student model
  :param train_loader (torch.utils.data.DataLoader): Dataloader for training
  :param val_loader (torch.utils.data.DataLoader): Dataloader for validation
  :param optimizer (torch.optim.*): Optimizer for training
  :param num_gen (int): Number of generations to train.
  :param loss_fn (torch.nn.Module): Loss Function used for first model in gen.
                                    later, KLDivLoss is used.
  :param temp (float): Temperature parameter for distillation
  :param distil_weight (float): Weight paramter for distillation loss
  :param device (str): Device for training; 'cpu' for cpu and 'cuda' for gpu
  :param log (bool): True if logging required
  :param logdir (str): Directory for storing logs
class_docstr_tok: ["Implementation","of","paper","``","Born","Again","Neural","Networks","''","https",":","\/\/arxiv.org\/abs\/1805.04770",":","param","student_model","(","torch.nn.Module",")",":","Student","model",":","param","train_loader","(","torch.utils.data.DataLoader",")",":","Dataloader","for","training",":","param","val_loader","(","torch.utils.data.DataLoader",")",":","Dataloader","for","validation",":","param","optimizer","(","torch.optim",".","*",")",":","Optimizer","for","training",":","param","num_gen","(","int",")",":","Number","of","generations","to","train",".",":","param","loss_fn","(","torch.nn.Module",")",":","Loss","Function","used","for","first","model","in","gen.","later",",","KLDivLoss","is","used",".",":","param","temp","(","float",")",":","Temperature","parameter","for","distillation",":","param","distil_weight","(","float",")",":","Weight","paramter","for","distillation","loss",":","param","device","(","str",")",":","Device","for","training",";","'cpu","'","for","cpu","and","'cuda","'","for","gpu",":","param","log","(","bool",")",":","True","if","logging","required",":","param","logdir","(","str",")",":","Directory","for","storing","logs"]
docstr: Evaluate method for printing accuracies of the trained network
  
  :param models_dir (str): Location of stored models. (default: ./models)
docstr_tok: ["Evaluate","method","for","printing","accuracies","of","the","trained","network",":","param","models_dir","(","str",")",":","Location","of","stored","models",".","(","default",":",".\/models",")"]
code: def evaluate(self, models_dir="./models"):
      """
      Evaluate method for printing accuracies of the trained network
  
      :param models_dir (str): Location of stored models. (default: ./models)
      """
      print("Evaluating Model Ensemble")
      models_dir = glob.glob(os.path.join(models_dir, "*.pth"))
      len_models = len(models_dir)
      outputs = []
      model = self.student_model
      for model_weight in models_dir:
          model.load_state_dict(torch.load(model_weight))
          output, _ = self._evaluate_model(model, verbose=False)
          outputs.append(output)
      print("Total Models: ", len(outputs))
      total = len(self.val_loader)
      print("Total Samples: ", total)
      correct = 0
      for idx, (data, target) in enumerate(self.val_loader):
          target = target.to(self.device)
          output = outputs[0][idx] / len_models
          for k in range(1, len_models):
              output += outputs[k][idx] / len_models
  
          pred = output.argmax(dim=1, keepdim=True)
          correct += pred.eq(target.view_as(pred)).sum().item()
  
      accuracy = {correct / total}
      print("-" * 80)
      print(f"Accuracy: {accuracy}")
  
      return accuracy
  
file_path: KD_Lib/KD_Lib/KD/vision/BANN/BANN.py
imports: import glob
  import os
  from copy import deepcopy
  import torch
  import torch.nn
  import torch.nn.functional
  from KD_Lib.KD.common import BaseClass
label_desc: Use image node_id 3 for calling the BANN obj's underlying member method code with example usage: obj.evaluate(models_dir) and returns: accuracy