parameters: (inputs,
               activation_fn=None,
               initializer=init_ops.zeros_initializer(),
               regularizer=None,
               reuse=None,
               variables_collections=None,
               outputs_collections=None,
               trainable=True,
               data_format=DATA_FORMAT_NHWC,
               scope=None)
docstring: Adds a bias to the inputs.
  
    Can be used as a normalizer function for conv2d and fully_connected.
  
    Args:
      inputs: A tensor of with at least rank 2 and value for the last dimension,
        e.g. `[batch_size, depth]`, `[None, None, None, depth]`.
      activation_fn: Activation function, default set to None to skip it and
        maintain a linear activation.
      initializer: An initializer for the bias, defaults to 0.
      regularizer: A regularizer like the result of
        `l1_regularizer` or `l2_regularizer`.
      reuse: Whether or not the layer and its variables should be reused. To be
        able to reuse the layer scope must be given.
      variables_collections: Optional collections for the variables.
      outputs_collections: Collections to add the outputs.
      trainable: If `True` also add variables to the graph collection
        `GraphKeys.TRAINABLE_VARIABLES` (see tf.Variable).
      data_format: A string. 'NHWC' and 'NCHW' are supported.
      scope: Optional scope for variable_scope.
  
    Returns:
      A tensor representing the result of adding biases to the inputs.
  
    Raises:
      ValueError: If `data_format` is neither `NHWC` nor `NCHW`.
      ValueError: If `data_format` is `NCHW` and rank of `inputs` is not 4.
      ValueError: If the rank of `inputs` is undefined.
      ValueError: If rank or `C` dimension of `inputs` is undefined.
docstring_summary: Adds a bias to the inputs.
docstring_tokens: Adds a bias to the inputs .
function: def bias_add(inputs,
               activation_fn=None,
               initializer=init_ops.zeros_initializer(),
               regularizer=None,
               reuse=None,
               variables_collections=None,
               outputs_collections=None,
               trainable=True,
               data_format=DATA_FORMAT_NHWC,
               scope=None):
    """Adds a bias to the inputs.
  
    Can be used as a normalizer function for conv2d and fully_connected.
  
    Args:
      inputs: A tensor of with at least rank 2 and value for the last dimension,
        e.g. `[batch_size, depth]`, `[None, None, None, depth]`.
      activation_fn: Activation function, default set to None to skip it and
        maintain a linear activation.
      initializer: An initializer for the bias, defaults to 0.
      regularizer: A regularizer like the result of
        `l1_regularizer` or `l2_regularizer`.
      reuse: Whether or not the layer and its variables should be reused. To be
        able to reuse the layer scope must be given.
      variables_collections: Optional collections for the variables.
      outputs_collections: Collections to add the outputs.
      trainable: If `True` also add variables to the graph collection
        `GraphKeys.TRAINABLE_VARIABLES` (see tf.Variable).
      data_format: A string. 'NHWC' and 'NCHW' are supported.
      scope: Optional scope for variable_scope.
  
    Returns:
      A tensor representing the result of adding biases to the inputs.
  
    Raises:
      ValueError: If `data_format` is neither `NHWC` nor `NCHW`.
      ValueError: If `data_format` is `NCHW` and rank of `inputs` is not 4.
      ValueError: If the rank of `inputs` is undefined.
      ValueError: If rank or `C` dimension of `inputs` is undefined.
    """
    if data_format not in (DATA_FORMAT_NCHW, DATA_FORMAT_NHWC):
      raise ValueError('data_format has to be either NCHW or NHWC.')
    with variable_scope.variable_scope(scope, 'BiasAdd', [inputs],
                                       reuse=reuse) as sc:
      inputs = ops.convert_to_tensor(inputs)
      dtype = inputs.dtype.base_dtype
      inputs_shape = inputs.get_shape()
      inputs_rank = inputs_shape.ndims
      if inputs_rank is None:
        raise ValueError('Dims of shape must be known but is None')
      elif inputs_rank != 4 and data_format == DATA_FORMAT_NCHW:
        raise ValueError('Data format NCHW only supports 4D Tensor')
      axis = 1 if data_format == DATA_FORMAT_NCHW else -1
      num_features = inputs_shape[axis].value
      if num_features is None:
        raise ValueError('`C` dimension must be known but is None')
      biases_collections = utils.get_variable_collections(variables_collections,
                                                          'biases')
      biases = variables.model_variable('biases',
                                        shape=[num_features,],
                                        dtype=dtype,
                                        initializer=initializer,
                                        regularizer=regularizer,
                                        collections=biases_collections,
                                        trainable=trainable)
      outputs = nn.bias_add(inputs, biases, data_format=data_format)
      if activation_fn is not None:
        outputs = activation_fn(outputs)
      return utils.collect_named_outputs(outputs_collections, sc.name, outputs)
function_tokens: def bias_add ( inputs , activation_fn = None , initializer = init_ops . zeros_initializer ( ) , regularizer = None , reuse = None , variables_collections = None , outputs_collections = None , trainable = True , data_format = DATA_FORMAT_NHWC , scope = None ) : if data_format not in ( DATA_FORMAT_NCHW , DATA_FORMAT_NHWC ) : raise ValueError ( 'data_format has to be either NCHW or NHWC.' ) with variable_scope . variable_scope ( scope , 'BiasAdd' , [ inputs ] , reuse = reuse ) as sc : inputs = ops . convert_to_tensor ( inputs ) dtype = inputs . dtype . base_dtype inputs_shape = inputs . get_shape ( ) inputs_rank = inputs_shape . ndims if inputs_rank is None : raise ValueError ( 'Dims of shape must be known but is None' ) elif inputs_rank != 4 and data_format == DATA_FORMAT_NCHW : raise ValueError ( 'Data format NCHW only supports 4D Tensor' ) axis = 1 if data_format == DATA_FORMAT_NCHW else - 1 num_features = inputs_shape [ axis ] . value if num_features is None : raise ValueError ( '`C` dimension must be known but is None' ) biases_collections = utils . get_variable_collections ( variables_collections , 'biases' ) biases = variables . model_variable ( 'biases' , shape = [ num_features , ] , dtype = dtype , initializer = initializer , regularizer = regularizer , collections = biases_collections , trainable = trainable ) outputs = nn . bias_add ( inputs , biases , data_format = data_format ) if activation_fn is not None : outputs = activation_fn ( outputs ) return utils . collect_named_outputs ( outputs_collections , sc . name , outputs )