class_docstr: This class defines a simple fully connected layer with
  an optional bias term.
  Please consider ``FullyConnectedLayer`` if batch_norm and activation
  are also used.
class_docstr_tok: ["This","class","defines","a","simple","fully","connected","layer","with","an","optional","bias","term",".","Please","consider","``","FullyConnectedLayer","``","if","batch_norm","and","activation","are","also","used","."]
code: def layer_op(self, input_tensor):
      input_shape = input_tensor.shape.as_list()
      if len(input_shape) > 2:
          batch_size = input_shape[0]
          input_tensor = tf.reshape(input_tensor, [batch_size, -1])
          input_shape = input_tensor.shape.as_list()
      n_input_chns = input_shape[-1]
  
      # initialize weight matrix and then apply
      weight_matrix = tf.get_variable(
          "w",
          shape=[n_input_chns, self.n_output_chns],
          initializer=self.initializers["w"],
          regularizer=self.regularizers["w"],
      )
      output_tensor = tf.matmul(input_tensor, weight_matrix, name="fc")
      if not self.with_bias:
          return output_tensor
  
      # adding the bias term
      bias_term = tf.get_variable(
          "b",
          shape=self.n_output_chns,
          initializer=self.initializers["b"],
          regularizer=self.regularizers["b"],
      )
      output_tensor = tf.nn.bias_add(
          output_tensor, bias_term, name="add_bias"
      )
      return output_tensor
  
file_path: NiftyNet/niftynet/layer/fully_connected.py
imports: from __future__ import absolute_import, print_function
  import numpy
  import tensorflow
  from niftynet.layer.activation import ActiLayer
  from niftynet.layer.base_layer import TrainableLayer
  from niftynet.layer.bn import BNLayer, InstanceNormLayer
  from niftynet.layer.gn import GNLayer
label_desc: Use image node_id 2 for calling the FCLayer obj's underlying member method code with example usage: obj.layer_op(input_tensor) and returns: output_tensor, output_tensor