Permalink
Browse files

dont do dropout during eval

  • Loading branch information...
1 parent ca2e28a commit 97a9e1ff663ac7238f986d8b8247f4ab81f83432 @ry committed Jan 30, 2016
Showing with 10 additions and 8 deletions.
  1. +1 −1 README.md
  2. +2 −2 caffe_to_tensorflow.py
  3. BIN vgg16-20160121.torrent → vgg16-20160129.tfmodel.torrent
  4. +7 −5 vgg16.py
View
@@ -16,7 +16,7 @@ Run `make` to download the original caffe model and convert it.
file.
If you don't feel like installing caffe, you can download the output here
-https://github.com/ry/tensorflow-vgg16/raw/master/vgg16-20160121.torrent
+https://github.com/ry/tensorflow-vgg16/raw/master/vgg16-20160129.tfmodel.torrent
The input ("images") to the TF model is expected to be [batch, height, width, channel]
where height = width = 224 and channel = 3. Values should be between 0 and 1.
@@ -114,7 +114,7 @@ def show_caffe_net_input():
skimage.io.show()
def same_tensor(a, b):
- return np.linalg.norm(a - b) < 1
+ return np.linalg.norm(a - b) < 0.1
def main():
global tf_activations
@@ -161,7 +161,7 @@ def main():
}
top1 = print_prob(tf_activations['prob'])
- ##assert top1 == "n02123045 tabby, tabby cat"
+ assert top1 == "n02123045 tabby, tabby cat"
# Now we compare tf_activations to net_caffe's if we ran a forward pass
# in both networks.
Binary file not shown.
View
@@ -46,7 +46,7 @@ def _fc_layer(self, bottom, name):
# Input should be an rgb image [batch, height, width, 3]
# values scaled [0, 1]
- def build(self, rgb):
+ def build(self, rgb, train=False):
rgb_scaled = rgb * 255.0
# Convert RGB to BGR
@@ -88,12 +88,14 @@ def build(self, rgb):
assert self.fc6.get_shape().as_list()[1:] == [4096]
self.relu6 = tf.nn.relu(self.fc6)
- self.drop6 = tf.nn.dropout(self.relu6, 0.5)
+ if train:
+ self.relu6 = tf.nn.dropout(self.relu6, 0.5)
- self.fc7 = self._fc_layer(self.drop6, "fc7")
+ self.fc7 = self._fc_layer(self.relu6, "fc7")
self.relu7 = tf.nn.relu(self.fc7)
- self.drop7 = tf.nn.dropout(self.relu7, 0.5)
+ if train:
+ self.relu7 = tf.nn.dropout(self.relu7, 0.5)
- self.fc8 = self._fc_layer(self.drop7, "fc8")
+ self.fc8 = self._fc_layer(self.relu7, "fc8")
self.prob = tf.nn.softmax(self.fc8, name="prob")

0 comments on commit 97a9e1f

Please sign in to comment.