class_docstr: The :class:`TernaryDense` class is a ternary fully connected layer, which weights are either -1 or 1 or 0 while inference.
  
  Note that, the bias vector would not be tenaried.
  
  Parameters
  ----------
  n_units : int
      The number of units of this layer.
  act : activation function
      The activation function of this layer, usually set to ``tf.act.sign`` or apply :class:`SignLayer` after :class:`BatchNormLayer`.
  use_gemm : boolean
      If True, use gemm instead of ``tf.matmul`` for inference. (TODO).
  W_init : initializer
      The initializer for the weight matrix.
  b_init : initializer or None
      The initializer for the bias vector. If None, skip biases.
  in_channels: int
      The number of channels of the previous layer.
      If None, it will be automatically detected when the layer is forwarded for the first time.
  name : None or str
      A unique layer name.
code: def build(self, inputs_shape):
      if len(inputs_shape) != 2:
          raise Exception(
              "The input dimension must be rank 2, please reshape or flatten it"
          )
  
      if self.in_channels is None:
          self.in_channels = inputs_shape[1]
  
      if self.use_gemm:
          raise Exception(
              "TODO. The current version use tf.matmul for inferencing."
          )
  
      n_in = inputs_shape[-1]
  
      self.W = self._get_weights(
          var_name="weights",
          shape=(n_in, self.n_units),
          init=self.W_init,
      )
      if self.b_init is not None:
          self.b = self._get_weights(
              var_name="biases", shape=(self.n_units), init=self.b_init
          )
  
file_path: TensorLayer/tensorlayer/layers/dense/ternary_dense.py
imports: import tensorflow
  import tensorlayer
  from tensorlayer import logging
  from tensorlayer.decorators import deprecated_alias
  from tensorlayer.layers.core import Layer
  from tensorlayer.layers.utils import compute_alpha, ternary_operation
label_desc: Use image node_id 3 for calling the TernaryDense obj's underlying member method code with example usage: obj.build(inputs_shape) without return types