如何在张量流中使用maxout激活函数?

1 tensorflow

我想在tensorflow中使用maxout激活函数,但我不知道应该使用哪个函数.

gkc*_*kcn 5

我发送了maxout的pull请求,这里是链接:

https://github.com/tensorflow/tensorflow/pull/5528

代码如下:

def maxout(inputs, num_units, axis=None):
    shape = inputs.get_shape().as_list()
    if axis is None:
        # Assume that channel is the last dimension
        axis = -1
    num_channels = shape[axis]
    if num_channels % num_units:
        raise ValueError('number of features({}) is not a multiple of num_units({})'
             .format(num_channels, num_units))
    shape[axis] = -1
    shape += [num_channels // num_units]
    outputs = tf.reduce_max(tf.reshape(inputs, shape), -1, keep_dims=False)
    return outputs
Run Code Online (Sandbox Code Playgroud)

下面是它的工作原理:

github截图