class_docstr: "
  This class implement the second order optimizer - KFAC, which uses Kronecker factor products of inputs and the gradients to
  get the approximate inverse fisher matrix, which is used to update the model parameters. Presently this optimizer works only
  on liner and 2D convolution layers. If you want to know more details about KFAC, please check the paper [1]_ and [2]_.
  
  References:
  -----------
  [1] Martens, James, and Roger Grosse. Optimizing Neural Networks with Kronecker-Factored Approximate Curvature.
  arXiv:1503.05671, arXiv, 7 June 2020. arXiv.org, http://arxiv.org/abs/1503.05671.
  [2] Grosse, Roger, and James Martens. A Kronecker-Factored Approximate Fisher Matrix for Convolution Layers.
  arXiv:1602.01407, arXiv, 23 May 2016. arXiv.org, http://arxiv.org/abs/1602.01407.
class_docstr_tok: ["``","This","class","implement","the","second","order","optimizer","-","KFAC",",","which","uses","Kronecker","factor","products","of","inputs","and","the","gradients","to","get","the","approximate","inverse","fisher","matrix",",","which","is","used","to","update","the","model","parameters",".","Presently","this","optimizer","works","only","on","liner","and","2D","convolution","layers",".","If","you","want","to","know","more","details","about","KFAC",",","please","check","the","paper","[","1","]","_","and","[","2","]","_.","References",":","--","--","--","--","--","-","[","1","]","Martens",",","James",",","and","Roger","Grosse",".","Optimizing","Neural","Networks","with","Kronecker-Factored","Approximate","Curvature",".","arXiv:1503.05671",",","arXiv",",","7","June","2020.","arXiv.org",",","http",":","\/\/arxiv.org\/abs\/1503.05671",".","[","2","]","Grosse",",","Roger",",","and","James","Martens",".","A","Kronecker-Factored","Approximate","Fisher","Matrix","for","Convolution","Layers",".","arXiv:1602.01407",",","arXiv",",","23","May","2016.","arXiv.org",",","http",":","\/\/arxiv.org\/abs\/1602.01407","."]
docstr: Does eigen decomposition of the input(A) and gradient(G) matrix for computing inverse of the ~ fisher.
  
  Parameter:
  ----------
  m: torch.nn.Module
      This is the layer for which the eigen decomposition should be done on.
docstr_tok: ["Does","eigen","decomposition","of","the","input","(","A",")","and","gradient","(","G",")","matrix","for","computing","inverse","of","the","~","fisher",".","Parameter",":","--","--","--","--","--","m",":","torch.nn.Module","This","is","the","layer","for","which","the","eigen","decomposition","should","be","done","on","."]
code: def _update_inv(self, m: torch.nn.Module):
      """
      Does eigen decomposition of the input(A) and gradient(G) matrix for computing inverse of the ~ fisher.
  
      Parameter:
      ----------
      m: torch.nn.Module
          This is the layer for which the eigen decomposition should be done on.
      """
      eps = 1e-10  # for numerical stability
  
      if self.mean:
          self.d_a[m], self.Q_a[m] = torch.symeig(
              self.m_aa[m] - torch.mean(self.m_aa[m]), eigenvectors=True
          )
          self.d_g[m], self.Q_g[m] = torch.symeig(
              self.m_gg[m] - torch.mean(self.m_gg[m]), eigenvectors=True
          )
      else:
          self.d_a[m], self.Q_a[m] = torch.symeig(
              self.m_aa[m], eigenvectors=True
          )
          self.d_g[m], self.Q_g[m] = torch.symeig(
              self.m_gg[m], eigenvectors=True
          )
  
      self.d_a[m].mul_((self.d_a[m] > eps).float())
      self.d_g[m].mul_((self.d_g[m] > eps).float())
  
file_path: deepchem/deepchem/models/torch_models/kfac_optimizer.py
imports: import math
  from typing import Optional, Callable, Dict, Tuple, List, Union
label_desc: Use image node_id 9 for calling the KFACOptimizer obj's underlying member method code with example usage: obj._update_inv(m) without return types