class_docstr: Off-diagonal orthogonal regularizer.
  
  The implementation is based on https://arxiv.org/abs/1809.11096.
  Given a rank N >= 2 tensor, the regularizer computes
  the sum of off-diagonal entries of (W^T W)^2 where
  
  * W is the input tensor reshaped to a matrix by collapsing the
    leading N - 1 axes into the first one;
  * ^2 is the element-wise square.
  
  NB: that is equivalent to computing the off-diagonal sum of (W^T W - I)^2,
  as off-diagonal entries of I are 0.
  
  For example,
  
      >>> t = tf.reshape(tf.range(8, dtype=tf.float32), [2, 2, 2])
      >>> reg = snt.regularizers.OffDiagonalOrthogonal(0.01)
      >>> reg([t])
      <tf.Tensor: ...>
  
  corresponds to copmuting
  
      >>> w = tf.reshape(t, [-1, 2])
      >>> w_gram_sq = tf.square(tf.matmul(tf.transpose(w), w))
      >>> 0.01 * (tf.reduce_sum(w_gram_sq) - tf.linalg.trace(w_gram_sq))
      <tf.Tensor: ...>
docstr: Create an off-diagonal orthogonal regularizer.
  
  Args:
    scale: A non-negative regularization factor.
  
  Raises:
    ValueError: if scale is <0.
docstr_tok: ["Create","an","off-diagonal","orthogonal","regularizer",".","Args",":","scale",":","A","non-negative","regularization","factor",".","Raises",":","ValueError",":","if","scale","is","<","0","."]
code: def __init__(self, scale: types.FloatLike):
      """Create an off-diagonal orthogonal regularizer.
  
      Args:
        scale: A non-negative regularization factor.
  
      Raises:
        ValueError: if scale is <0.
      """
      self.scale = _check_scale(scale)
  
imports: import abc
  from typing import Sequence
  from sonnet.src import types
  import tensorflow
label_desc: Use image node_id 1 to create a new OffDiagonalOrthogonal object from inherited base classes: Regularizer with example: obj = OffDiagonalOrthogonal(scale)