2016-10-10 1 views

Antwort

1

Ich glaube nicht, dass es eine maximale Aktivierung gibt, aber es gibt nichts, das dich davon abhält, es selbst zu machen. Sie könnten etwas wie das Folgende tun.

with tf.variable_scope('maxout'): 
    layer_input = ... 
    layer_output = None 
    for i in range(n_maxouts): 
    W = tf.get_variable('W_%d' % d, (n_input, n_output)) 
    b = tf.get_variable('b_%d' % i, (n_output,)) 
    y = tf.matmul(layer_input, W) + b 
    if layer_output is None: 
     layer_output = y 
    else: 
     layer_output = tf.maximum(layer_output, y) 

Beachten Sie, dass dieser Code ich in meinem Browser gerade geschrieben haben, so gibt es Syntaxfehler sein können, aber Sie sollten die allgemeine Idee. Sie führen einfach eine Anzahl linearer Transformationen durch und nehmen das Maximum über alle Transformationen hinweg.

4

ich eine Pull-Anforderung für MaxOut, ist der Link hier gesendet:

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

-Code wird wie folgt: Hier

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 

ist, wie es funktioniert:

github screenshot

0

Wie wäre es mit diesem Code? Das scheint in meinem Test zu funktionieren.

def max_out(input_tensor,output_size): 
shape = input_tensor.get_shape().as_list() 
if shape[1] % output_size == 0: 
    return tf.transpose(tf.reduce_max(tf.split(input_tensor,output_size,1),axis=2)) 
else: 
    raise ValueError("Output size or input tensor size is not fine. Please check it. Reminder need be zero.") 

verweise ich das Diagramm in the following page.

Verwandte Themen