neural_tangents/stax.py
def _layer(layer):
  """A convenience decorator to be added to all public layers like `Relu` etc.

  Makes the `kernel_fn` of the layer work with both input `np.ndarray`s (when
    the layer is the first one applied to inputs), and with `Kernel` for
    intermediary layers. Also adds optional arguments to make the `kernel_fn`
    call the empirical Monte Carlo kernel estimation instead of computing it
    analytically (by default), as well as specifying the batching strategy.

  Args:
    layer: A layer function returning a triple `(init_fn, apply_fn, kernel_fn)`.

  Returns:
    A function with the same signature as `layer` with `kernel_fn` now
    accepting `np.ndarray`s as inputs if needed, and optional `n_samples=0`,
    `key=None`, `compute_ntk=True` arguments to let the user indicate that
    they want the kernel to be computed by Monte Carlo sampling.
  """
  @wraps(layer)
  def layer_fn(*args, **kwargs):
    init_fn, apply_fn, kernel_fn = layer(*args, **kwargs)
    kernel_fn = _preprocess_kernel_fn(init_fn, kernel_fn)
    kernel_fn.__name__ = layer.__name__
    return init_fn, apply_fn, kernel_fn
  return layer_fn
A convenience decorator to be added to all public layers like `Relu` etc.

  Makes the `kernel_fn` of the layer work with both input `np.ndarray`s (when
    the layer is the first one applied to inputs), and with `Kernel` for
    intermediary layers. Also adds optional arguments to make the `kernel_fn`
    call the empirical Monte Carlo kernel estimation instead of computing it
    analytically (by default), as well as specifying the batching strategy.

  Args:
    layer: A layer function returning a triple `(init_fn, apply_fn, kernel_fn)`.

  Returns:
    A function with the same signature as `layer` with `kernel_fn` now
    accepting `np.ndarray`s as inputs if needed, and optional `n_samples=0`,
    `key=None`, `compute_ntk=True` arguments to let the user indicate that
    they want the kernel to be computed by Monte Carlo sampling.
  
A convenience decorator to be added to all public layers like `Relu` etc.
A convenience decorator to be added to all public layers like ` Relu ` etc .
def _layer(layer):
  @wraps(layer)
  def layer_fn(*args, **kwargs):
    init_fn, apply_fn, kernel_fn = layer(*args, **kwargs)
    kernel_fn = _preprocess_kernel_fn(init_fn, kernel_fn)
    kernel_fn.__name__ = layer.__name__
    return init_fn, apply_fn, kernel_fn
  return layer_fn
def _layer ( layer ) : @ wraps ( layer ) def layer_fn ( * args , ** kwargs ) : init_fn , apply_fn , kernel_fn = layer ( * args , ** kwargs ) kernel_fn = _preprocess_kernel_fn ( init_fn , kernel_fn ) kernel_fn . __name__ = layer . __name__ return init_fn , apply_fn , kernel_fn return layer_fn
A convenience decorator to be added to all public layers like `Relu` etc.
A convenience decorator to be added to all public layers like ` Relu ` etc .
"""A convenience decorator to be added to all public layers like `Relu` etc.

  Makes the `kernel_fn` of the layer work with both input `np.ndarray`s (when
    the layer is the first one applied to inputs), and with `Kernel` for
    intermediary layers. Also adds optional arguments to make the `kernel_fn`
    call the empirical Monte Carlo kernel estimation instead of computing it
    analytically (by default), as well as specifying the batching strategy.

  Args:
    layer: A layer function returning a triple `(init_fn, apply_fn, kernel_fn)`.

  Returns:
    A function with the same signature as `layer` with `kernel_fn` now
    accepting `np.ndarray`s as inputs if needed, and optional `n_samples=0`,
    `key=None`, `compute_ntk=True` arguments to let the user indicate that
    they want the kernel to be computed by Monte Carlo sampling.
  """
A function with the same signature as `layer` with `kernel_fn` now
accepting `np.ndarray`s as inputs if needed, and optional `n_samples=0`,
`key=None`, `compute_ntk=True` arguments to let the user indicate that
they want the kernel to be computed by Monte Carlo sampling.
A function with the same signature as ` layer ` with ` kernel_fn ` now accepting ` np . ndarray ` s as inputs if needed and optional ` n_samples = 0 ` ` key = None ` ` compute_ntk = True ` arguments to let the user indicate that they want the kernel to be computed by Monte Carlo sampling .
layer
A layer function returning a triple `(init_fn, apply_fn, kernel_fn)`.
A layer function returning a triple ` ( init_fn apply_fn kernel_fn ) ` .