因为单词" layer"当应用于卷积层时,通常意味着不同的东西(有些通过汇集作为单个层来处理所有事情,其他人将卷积,非线性和汇集视为单独的"层&#34 ;; see fig 9.7)它&#39 ;我不清楚在卷积层应用辍学的地方。
非线性和汇集之间是否会发生辍学?
例如,在TensorFlow中它会是这样的:
kernel_logits = tf.nn.conv2d(input_tensor, ...) + biases
activations = tf.nn.relu(kernel_logits)
kept_activations = tf.nn.dropout(activations, keep_prob)
output = pool_fn(kept_activations, ...)
答案 0 :(得分:2)
您可能会尝试在不同的地方应用辍学,但在防止过度拟合方面,不确定在合并之前您会看到很多问题。我在CNN看到的是tensorflow.nn.dropout
在非线性和汇集后被应用:
# Create a convolution + maxpool layer for each filter size
pooled_outputs = []
for i, filter_size in enumerate(filters):
with tf.name_scope("conv-maxpool-%s" % filter_size):
# Convolution Layer
filter_shape = [filter_size, embedding_size, 1, num_filters]
W = tf.Variable(tf.truncated_normal(filter_shape, stddev=0.1), name="W")
b = tf.Variable(tf.constant(0.1, shape=[num_filters]), name="b")
conv = tf.nn.conv2d(
self.embedded_chars_expanded,
W,
strides=[1, 1, 1, 1],
padding="VALID",
name="conv")
# Apply nonlinearity
h = tf.nn.relu(tf.nn.bias_add(conv, b), name="relu")
# Maxpooling over the outputs
pooled = tf.nn.max_pool(
h,
ksize=[1, sequence_length - filter_size + 1, 1, 1],
strides=[1, 1, 1, 1],
padding='VALID',
name="pool")
pooled_outputs.append(pooled)
# Combine all the pooled features
num_filters_total = num_filters * len(filters)
self.h_pool = tf.concat(3, pooled_outputs)
self.h_pool_flat = tf.reshape(self.h_pool, [-1, num_filters_total])
# Add dropout
with tf.name_scope("dropout"):
self.h_drop = tf.nn.dropout(self.h_pool_flat, self.dropout_keep_prob)