Skip to content

Commit

Permalink
He initialization of dense layer, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
auduno committed Dec 31, 2015
1 parent 5b3bac4 commit 3a168ac
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions papers/Deep_Residual_Learning_CIFAR-10.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""
Lasagne implementation of CIFAR-10 examples from "Deep Residual Learning for Image Recognition" (http://arxiv.org/abs/1512.03385)
With n=5, i.e. 32-layer network from the paper, this achieves a validation error of 6.88% (vs 7.51% in the paper).
With n=5, i.e. 32-layer network from the paper, this achieves a validation error of approximately 7.5% (same as in the paper).
With a single run of n=9 (56-layer network), we achieved a validation error of 7.2% (i.e. close to papers error of 6.97%).
The accuracy has not yet been tested for the other values of n.
"""

Expand All @@ -21,6 +22,9 @@
import theano.tensor as T
import lasagne

# for the larger networks (n>=9), we need to adjust pythons recursion limit
sys.setrecursionlimit(10000)

# ##################### Load data from CIFAR-10 dataset #######################
# this code assumes the cifar dataset from 'https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz'
# has been extracted in current working directory
Expand Down Expand Up @@ -85,8 +89,6 @@ def load_data():
from lasagne.layers import Pool2DLayer
from lasagne.layers import NonlinearityLayer
from lasagne.nonlinearities import softmax, rectify

# NB! from pull request #461 : https://github.com/f0k/Lasagne/blob/98b5581fa830cda3d3f838506ef14e5811a35ef7/lasagne/layers/normalization.py
from lasagne.layers import batch_norm

def build_cnn(input_var=None, n=5):
Expand Down Expand Up @@ -147,6 +149,7 @@ def residual_block(l, increase_dim=False, projection=False):
# fully connected layer
network = DenseLayer(
l, num_units=10,
W=lasagne.init.HeNormal(),
nonlinearity=softmax)

return network
Expand Down

0 comments on commit 3a168ac

Please sign in to comment.