class_docstr: Initialisation from the paper `All you need is a good init <https://arxiv.org/abs/1511.06422>`__. Call
  LSUV.init_model(...) on a torch model to perform the initialisation. Implementation based off of the PyTorch
  implementation `here <https://github.com/ducha-aiki/LSUV-pytorch>`__.
  
  Example: ::
  
      >>> import torch.nn
      >>> from torchbearer.callbacks import LSUV
  
      # Example of initialising a torch model with LSUV
      >>> model = torch.nn.Linear(1,1)
      >>> data = torch.rand(100, 1)
      >>> lsuv = LSUV(model, data)
      >>> model = lsuv.init_model(model, data)
class_docstr_tok: ["Initialisation","from","the","paper","`","All","you","need","is","a","good","init","<","https",":","\/\/arxiv.org\/abs\/1511.06422",">","`","__",".","Call","LSUV.init_model","(","...",")","on","a","torch","model","to","perform","the","initialisation",".","Implementation","based","off","of","the","PyTorch","implementation","`","here","<","https",":","\/\/github.com\/ducha-aiki\/LSUV-pytorch",">","`","__",".","Example",":",":",":",">",">",">","import","torch.nn",">",">",">","from","torchbearer.callbacks","import","LSUV","#","Example","of","initialising","a","torch","model","with","LSUV",">",">",">","model","=","torch.nn.Linear","(","1,1",")",">",">",">","data","=","torch.rand","(","100",",","1",")",">",">",">","lsuv","=","LSUV","(","model",",","data",")",">",">",">","model","=","lsuv.init_model","(","model",",","data",")"]
code: def init_model(
      self,
      model,
      data,
      weight_lambda=None,
      needed_std=1.0,
      std_tol=0.1,
      max_attempts=10,
      do_orthonorm=True,
  ):
      self.gg = self.reset_parameters()
      train = True if model.training else False
      self.gg["weight_lambda"] = (
          self.gg["weight_lambda"]
          if weight_lambda is None
          else weight_lambda
      )
  
      model.eval()
      model.apply(self.count_conv_fc_layers)
      if do_orthonorm:
          model.apply(self.orthogonal_weights_init)
      for layer_idx in range(self.gg["total_fc_conv_layers"]):
          model.apply(self.add_current_hook)
          _ = model(data)
          current_std = self.gg["act_dict"].std()
          attempts = 0
          while torch.abs(current_std - needed_std).item() > std_tol:
              self.gg["current_coef"] = needed_std / (
                  current_std + 1e-8
              )
              self.gg["correction_needed"] = True
              model.apply(self.apply_weights_correction)
              _ = model(data)
              current_std = self.gg["act_dict"].std()
              attempts += 1
              if attempts > max_attempts:
                  break
          if self.gg["hook"] is not None:
              self.gg["hook"].remove()
          self.gg["done_counter"] += 1
          self.gg["counter_to_apply_correction"] = 0
          self.gg["hook_position"] = 0
          self.gg["hook"] = None
  
      if train:
          model.train()
      return model
  
file_path: torchbearer/torchbearer/callbacks/lsuv.py
imports: import numpy
  import torch
  import torch.nn.init
  import torch.nn
label_desc: Use image node_id 8 for calling the LSUV obj's underlying member method code with example usage: obj.init_model(model, data, weight_lambda, needed_std, std_tol, max_attempts, do_orthonorm) and returns: model