class_docstr: Glorot weight initialization.
  
  This is also known as Xavier initialization [1]_.
  
  Parameters
  ----------
  initializer : lasagne.init.Initializer
      Initializer used to sample the weights, must accept `std` in its
      constructor to sample from a distribution with a given standard
      deviation.
  gain : float or 'relu'
      Scaling factor for the weights. Set this to ``1.0`` for linear and
      sigmoid units, to 'relu' or ``sqrt(2)`` for rectified linear units, and
      to ``sqrt(2/(1+alpha**2))`` for leaky rectified linear units with
      leakiness ``alpha``. Other transfer functions may need different
      factors.
  c01b : bool
      For a :class:`lasagne.layers.cuda_convnet.Conv2DCCLayer` constructed
      with ``dimshuffle=False``, `c01b` must be set to ``True`` to compute
      the correct fan-in and fan-out.
  
  References
  ----------
  .. [1] Xavier Glorot and Yoshua Bengio (2010):
         Understanding the difficulty of training deep feedforward neural
         networks. International conference on artificial intelligence and
         statistics.
  
  Notes
  -----
  For a :class:`DenseLayer <lasagne.layers.DenseLayer>`, if ``gain='relu'``
  and ``initializer=Uniform``, the weights are initialized as
  
  .. math::
     a &= \sqrt{\frac{12}{fan_{in}+fan_{out}}}\\
     W &\sim U[-a, a]
  
  If ``gain=1`` and ``initializer=Normal``, the weights are initialized as
  
  .. math::
     \sigma &= \sqrt{\frac{2}{fan_{in}+fan_{out}}}\\
     W &\sim N(0, \sigma)
  
  See Also
  --------
  GlorotNormal  : Shortcut with Gaussian initializer.
  GlorotUniform : Shortcut with uniform initializer.
class_docstr_tok: ["Glorot","weight","initialization",".","This","is","also","known","as","Xavier","initialization","[","1","]","_.","Parameters","--","--","--","--","--","initializer",":","lasagne.init.Initializer","Initializer","used","to","sample","the","weights",",","must","accept","`","std","`","in","its","constructor","to","sample","from","a","distribution","with","a","given","standard","deviation",".","gain",":","float","or","'relu'","Scaling","factor","for","the","weights",".","Set","this","to","``","1.0","``","for","linear","and","sigmoid","units",",","to","'relu","'","or","``","sqrt","(","2",")","``","for","rectified","linear","units",",","and","to","``","sqrt","(","2\/","(","1+alpha","*","*","2",")",")","``","for","leaky","rectified","linear","units","with","leakiness","``","alpha","``",".","Other","transfer","functions","may","need","different","factors",".","c01b",":","bool","For","a",":","class",":","`","lasagne.layers.cuda_convnet.Conv2DCCLayer","`","constructed","with","``","dimshuffle=False","``",",","`","c01b","`","must","be","set","to","``","True","``","to","compute","the","correct","fan-in","and","fan-out",".","References","--","--","--","--","--","..","[","1","]","Xavier","Glorot","and","Yoshua","Bengio","(","2010",")",":","Understanding","the","difficulty","of","training","deep","feedforward","neural","networks",".","International","conference","on","artificial","intelligence","and","statistics",".","Notes","--","--","-","For","a",":","class",":","`","DenseLayer","<","lasagne.layers.DenseLayer",">","`",",","if","``","gain='relu","'","``","and","``","initializer=Uniform","``",",","the","weights","are","initialized","as","..","math",":",":","a","&","=","\\sqrt","{","\\frac","{","12","}","{","fan_","{","in","}","+fan_","{","out","}","}","}","\\\\","W","&","\\sim","U","[","-a",",","a","]","If","``","gain=1","``","and","``","initializer=Normal","``",",","the","weights","are","initialized","as","..","math",":",":","\\sigma","&","=","\\sqrt","{","\\frac","{","2","}","{","fan_","{","in","}","+fan_","{","out","}","}","}","\\\\","W","&","\\sim","N","(","0",",","\\sigma",")","See","Also","--","--","--","--","GlorotNormal",":","Shortcut","with","Gaussian","initializer",".","GlorotUniform",":","Shortcut","with","uniform","initializer","."]
code: def sample(self, shape):
      if self.c01b:
          if len(shape) != 4:
              raise RuntimeError(
                  "If c01b is True, only shapes of length 4 are accepted"
              )
  
          n1, n2 = shape[0], shape[3]
          receptive_field_size = shape[1] * shape[2]
      else:
          if len(shape) < 2:
              raise RuntimeError(
                  "This initializer only works with shapes of length >= 2"
              )
  
          n1, n2 = shape[:2]
          receptive_field_size = np.prod(shape[2:])
  
      std = self.gain * np.sqrt(
          2.0 / ((n1 + n2) * receptive_field_size)
      )
      return self.initializer(std=std).sample(shape)
  
imports: import numpy
  from .utils import floatX
  from .random import get_rng
label_desc: Use image node_id 2 for calling the Glorot obj's underlying member method code with example usage: obj.sample(shape) and returns: self