本を読んでTensorFlowの勉強をしています。
その中で、プーリング層と畳み込み層の間に
局所応答正規化の層を追加して精度を上げる、という話が出てきました。
しかし、TensorFlowには元々正規化のメソッドがある(softmax関数とか)ので、それが局所応答正規化のメソッド(nn.lrn関数)とどのように機能的に違うのかがわかりませんでした。
局所応答正規化と正規化のメソッドの違いはどのようなものなのでしょうか?
ちなみに、局所応答正規化の話が出てきた時のコード全体は以下の通りです。
# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf NUM_CLASSES = 10 def _get_weights(shape,stddev=1.0): var = tf.get_variable( 'weights', shape, initializer=tf.truncated_normal_initializer(stddev=stddev) ) return var def _get_biases(shape,value=0.0): var = tf.get_variable( 'biases', shape, initializer=tf.constant_initializer(value) ) return var def inference(image_node): # conv1 with tf.variable_scope('conv1') as scope: weights = _get_weights(shape=[5,5,3,64],stddev=1e-4) conv = tf.nn.conv2d(image_node,weights,[1,1,1,1],padding='SAME') biases = _get_biases([64],value=0.1) bias = tf.nn.bias_add(conv,biases) conv1 = tf.nn.relu(bias,name=scope.name) # pool pool1 = tf.nn.max_pool(conv1,ksize=[1,3,3,1],strides=[1,2,2,1],padding='SAME',name='pool1') #norm1 norm1 = tf.nn.lrn(pool1,4,bias=1.0,alpha=0.001/9.0,beta=0.75,name='norml') # conv2 with tf.variable_scope('conv2') as scope: weights = _get_weights(shape=[5,5,64,64],stddev=1e-4) conv = tf.nn.conv2d(norm1,weights,[1,1,1,1],padding='SAME') biases = _get_biases([64],value=0.1) bias = tf.nn.bias_add(conv,biases) conv2 = tf.nn.relu(bias,name=scope.name) #norm2 norm2 = tf.nn.lrn(conv2,4,bias=1.0,alpha=0.001/9.0,beta=0.75,name='norm2') # pool2 pool2 = tf.nn.max_pool(norm2,ksize=[1,3,3,1],strides=[1,2,2,1],padding='SAME',name='pool2') reshape = tf.reshape(pool2,[1,-1]) dim = reshape.get_shape()[1].value # fc3 with tf.variable_scope('fc3') as scope: weights = _get_weights(shape=[dim,384],stddev=0.04) biases = _get_biases([384],value=0.1) fc3 = tf.nn.relu( tf.matmul(reshape,weights) + biases, name=scope.name ) # fc4 with tf.variable_scope('fc4') as scope: weights = _get_weights(shape=[384,192],stddev=0.04) biases = _get_biases([192],value=0.1) fc4 = tf.nn.relu(tf.matmul(fc3,weights) + biases,name=scope.name) # output with tf.variable_scope('output') as scope: weights = _get_weights(shape=[192,NUM_CLASSES],stddev=1/192.0) biases = _get_biases([NUM_CLASSES],value=0.0) logits = tf.add(tf.matmul(fc4,weights),biases,name='logits') return logits
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。