(x, b, axis, act, alpha, gain)
return x
Slow reference implementation of `fused_bias_act()` using standard TensorFlow ops.
Slow reference implementation of `fused_bias_act()` using standard TensorFlow ops.
Slow reference implementation of fused_bias_act () using standard TensorFlow ops .
def _fused_bias_act_ref(x, b, axis, act, alpha, gain):
    """Slow reference implementation of `fused_bias_act()` using standard TensorFlow ops."""

    # Validate arguments.
    x = tf.convert_to_tensor(x)
    b = tf.convert_to_tensor(b) if b is not None else tf.constant([], dtype=x.dtype)
    act_spec = activation_funcs[act]
    assert b.shape.rank == 1 and (b.shape[0] == 0 or b.shape[0] == x.shape[axis])
    assert b.shape[0] == 0 or 0 <= axis < x.shape.rank
    if alpha is None:
        alpha = act_spec.def_alpha
    if gain is None:
        gain = act_spec.def_gain

    # Add bias.
    if b.shape[0] != 0:
        x += tf.reshape(b, [-1 if i == axis else 1 for i in range(x.shape.rank)])

    # Evaluate activation function.
    x = act_spec.func(x, alpha=alpha)

    # Scale by gain.
    if gain != 1:
        x *= gain
    return x
def _fused_bias_act_ref ( x , b , axis , act , alpha , gain ) : # Validate arguments. x = tf . convert_to_tensor ( x ) b = tf . convert_to_tensor ( b ) if b is not None else tf . constant ( [ ] , dtype = x . dtype ) act_spec = activation_funcs [ act ] assert b . shape . rank == 1 and ( b . shape [ 0 ] == 0 or b . shape [ 0 ] == x . shape [ axis ] ) assert b . shape [ 0 ] == 0 or 0 <= axis < x . shape . rank if alpha is None : alpha = act_spec . def_alpha if gain is None : gain = act_spec . def_gain # Add bias. if b . shape [ 0 ] != 0 : x += tf . reshape ( b , [ - 1 if i == axis else 1 for i in range ( x . shape . rank ) ] ) # Evaluate activation function. x = act_spec . func ( x , alpha = alpha ) # Scale by gain. if gain != 1 : x *= gain return x