class_docstr: This class defines a simple deconvolution with an optional bias term.
  Please consider ``DeconvolutionalLayer`` if batch_norm and activation
  are also used.
class_docstr_tok: ["This","class","defines","a","simple","deconvolution","with","an","optional","bias","term",".","Please","consider","``","DeconvolutionalLayer","``","if","batch_norm","and","activation","are","also","used","."]
code: def layer_op(self, input_tensor):
      input_shape = input_tensor.shape.as_list()
      n_input_chns = input_shape[-1]
      spatial_rank = layer_util.infer_spatial_rank(input_tensor)
  
      # initialize conv kernels/strides and then apply
      kernel_size_all_dim = layer_util.expand_spatial_params(
          self.kernel_size, spatial_rank
      )
      w_full_size = kernel_size_all_dim + (
          self.n_output_chns,
          n_input_chns,
      )
      stride_all_dim = layer_util.expand_spatial_params(
          self.stride, spatial_rank
      )
      full_stride = (1,) + stride_all_dim + (1,)
  
      deconv_kernel = tf.get_variable(
          "w",
          shape=w_full_size,
          initializer=self.initializers["w"],
          regularizer=self.regularizers["w"],
      )
      if spatial_rank == 2:
          op_ = SUPPORTED_OP["2D"]
      elif spatial_rank == 3:
          op_ = SUPPORTED_OP["3D"]
      else:
          raise ValueError(
              "Only 2D and 3D spatial deconvolutions are supported"
          )
  
      spatial_shape = []
      for i, dim in enumerate(input_shape[:-1]):
          if i == 0:
              continue
          if dim is None:
              spatial_shape.append(tf.shape(input_tensor)[i])
          else:
              spatial_shape.append(dim)
      output_dims = infer_output_dims(
          spatial_shape,
          stride_all_dim,
          kernel_size_all_dim,
          self.padding,
      )
      if input_tensor.shape.is_fully_defined():
          full_output_size = (
              [input_shape[0]] + output_dims + [self.n_output_chns]
          )
      else:
          batch_size = tf.shape(input_tensor)[0]
          full_output_size = tf.stack(
              [batch_size] + output_dims + [self.n_output_chns]
          )
      output_tensor = op_(
          value=input_tensor,
          filter=deconv_kernel,
          output_shape=full_output_size,
          strides=full_stride,
          padding=self.padding,
          name="deconv",
      )
      if not self.with_bias:
          return output_tensor
  
      # adding the bias term
      bias_full_size = (self.n_output_chns,)
      bias_term = tf.get_variable(
          "b",
          shape=bias_full_size,
          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/deconvolution.py
imports: from __future__ import absolute_import, print_function
  import numpy
  import tensorflow
  from niftynet.layer import layer_util
  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
  from niftynet.utilities.util_common import look_up_operations
label_desc: Use image node_id 2 for calling the DeconvLayer obj's underlying member method code with example usage: obj.layer_op(input_tensor) and returns: output_tensor, output_tensor