Skip to content

Commit

Permalink
Intermediate Push.
Browse files Browse the repository at this point in the history
Fine tuning setup still has some problems. Will fix it next.
  • Loading branch information
Ragav Venkatesan committed Nov 13, 2016
1 parent c4e155b commit 7463edb
Show file tree
Hide file tree
Showing 10 changed files with 161 additions and 139 deletions.
4 changes: 3 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ of `theano`_. To setup the toolbox refer the :ref:`setup` guide. Once setup you
.. warning ::
Yann is currently under its early phases and is presently undergoing massive development.
Expect a lot of changes.
Expect a lot of changes. Testing going on at the moment with the ``cook`` function and
therefore some loss functions might not work temporarily.
.. warning ::
Expand Down Expand Up @@ -207,6 +208,7 @@ Hope you liked this quick start guide to the Yann toolbox and have fun!
yann/index
trailer
license
genindex


Indices of functions and modules
Expand Down
33 changes: 12 additions & 21 deletions pantry/examples/lenet.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/python
import sys, os
sys.path.insert(0, os.getcwd())
from yann.network import network
Expand All @@ -10,21 +9,21 @@ def lenet5 ( dataset= None, verbose = 1 ):
"""
optimizer_params = {
"momentum_type" : 'polyak',
"momentum_type" : 'false',
# false, polyak, nesterov
"momentum_params" : (0.5, 0.95, 30),
# (mom_start, momentum_end, momentum_end_epoch)
"regularization" : (0.0001, 0.0001),
"regularization" : (0.00, 0.00),
# l1_coeff, l2_coeff, decisiveness (optional)
"optimizer_type" : 'rmsprop',
"optimizer_type" : 'sgd',
# sgd, adagrad, rmsprop, adam
"id" : "main"
}


dataset_params = {
"dataset" : dataset,
"svm" : False,
"dataset" : dataset,
"svm" : False,
"n_classes" : 10,
"id" : 'mnist'
}
Expand All @@ -49,17 +48,15 @@ def lenet5 ( dataset= None, verbose = 1 ):
verbose = verbose,
datastream_origin = 'mnist', # if you didnt add a dataset module, now is
# the time.
mean_subtract = True )
mean_subtract = False )

# add first convolutional layer

net.add_layer ( type = "conv_pool",
origin = "input",
id = "conv_pool_1",
num_neurons = 20,
filter_size = (5,5),
pool_size = (2,2),
batch_norm = True,
activation = 'relu',
verbose = verbose
)
Expand All @@ -70,18 +67,14 @@ def lenet5 ( dataset= None, verbose = 1 ):
num_neurons = 50,
filter_size = (3,3),
pool_size = (2,2),
batch_norm = True,
dropout_rate = 0.5,
activation = 'relu',
verbose = verbose
)

net.add_layer ( type = "dot_product",
origin = "conv_pool_2",
id = "dot_product_1",
num_neurons = 800,
batch_norm = True,
dropout_rate = 0.5,
activation = 'relu',
verbose = verbose
)
Expand All @@ -90,8 +83,6 @@ def lenet5 ( dataset= None, verbose = 1 ):
origin = "dot_product_1",
id = "dot_product_2",
num_neurons = 800,
batch_norm = True,
dropout_rate = 0.5,
activation = 'relu',
verbose = verbose
)
Expand All @@ -107,7 +98,8 @@ def lenet5 ( dataset= None, verbose = 1 ):
net.add_layer ( type = "objective",
id = "obj",
origin = "softmax",
objective = "cce",
objective = "nll",
datastream_origin = 'mnist',
verbose = verbose
)

Expand All @@ -118,8 +110,7 @@ def lenet5 ( dataset= None, verbose = 1 ):
# hinge-hinge loss
learning_rates = (0.01, 0.05, 0.001)
# (initial_learning_rate, annealing, ft_learnint_rate)

net.pretty_print() # this will print out the network.
# net.pretty_print() # this will print out the network.
net.cook( optimizer = 'main',
objective_layer = 'obj',
datastream = 'mnist',
Expand All @@ -128,11 +119,11 @@ def lenet5 ( dataset= None, verbose = 1 ):
verbose = verbose
)

net.train( epochs = (200, 200),
net.train( epochs = (20, 20),
ft_learning_rate = 0.001,
validate_after_epochs = 1,
training_accuracy = True,
show_progress = False,
show_progress = True,
early_terminate = True,
verbose = verbose)

Expand Down
10 changes: 5 additions & 5 deletions pantry/examples/log_reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def log_reg ( dataset, verbose ):
"""
optimizer_params = {
"momentum_type" : 'polyak',
"momentum_type" : 'false',
# false, polyak, nesterov
"momentum_params" : (0.9, 0.95, 30),
"momentum_params" : (0.5, 0.95, 30),
# (mom_start, momentum_end, momentum_end_epoch)
"regularization" : (0.0001, 0.0001),
"regularization" : (0.000, 0.000),
# l1_coeff, l2_coeff, decisiveness (optional)
"optimizer_type" : 'rmsprop',
"optimizer_type" : 'sgd',
# sgd, adagrad, rmsprop, adam
"id" : "main"
}
Expand Down Expand Up @@ -62,7 +62,7 @@ def log_reg ( dataset, verbose ):
net.add_layer ( type = "objective",
id = "nll",
origin = "softmax",
objective = 'cce',
objective = 'nll',
verbose = verbose
)

Expand Down
9 changes: 2 additions & 7 deletions pantry/examples/mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ def mlp ( dataset, verbose = 1 ):
dataset: an already created dataset.
"""
optimizer_params = {
"momentum_type" : 'polyak',
"momentum_type" : 'false',
# false, polyak, nesterov
"momentum_params" : (0.9, 0.95, 30),
# (mom_start, momentum_end, momentum_end_epoch)
"regularization" : (0.0001, 0.0001),
# l1_coeff, l2_coeff, decisiveness (optional)
"optimizer_type" : 'rmsprop',
"optimizer_type" : 'sgd',
# sgd, adagrad, rmsprop, adam
"id" : "main"
}
Expand Down Expand Up @@ -51,16 +51,13 @@ def mlp ( dataset, verbose = 1 ):
verbose = verbose,
datastream_origin = 'mnist', # if you didnt add a dataset module, now is
# the time.
dropout_rate = 0,
mean_subtract = True )

# add first convolutional laye
net.add_layer ( type = "dot_product",
origin = "input",
id = "dot_product_1",
num_neurons = 800,
batch_norm = True,
dropout_rate = 0.5,
activation = 'relu',
verbose = verbose
)
Expand All @@ -69,8 +66,6 @@ def mlp ( dataset, verbose = 1 ):
origin = "dot_product_1",
id = "dot_product_2",
num_neurons = 800,
batch_norm = True,
dropout_rate = 0.5,
activation = 'relu',
verbose = verbose
)
Expand Down
5 changes: 3 additions & 2 deletions yann/core/conv.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
``yann.core.conv.py`` is one file that contains all the convolution operators.
It contains two functions for performing either 2d convolution (``conv2d``) or 3d convolution (``conv3d``).
It contains two functions for performing either 2d convolution (``conv2d``) or 3d convolution
(``conv3d``).
These functions shall be called by every convolution layer from ``yann.layers.py``
Expand Down Expand Up @@ -105,7 +106,7 @@ def __init__ ( self,

from theano.sandbox import cuda
if not cuda.dnn.dnn_available():
raise Exception ("cuDNN is needed for this operation.")
raise Exception ("cuDNN is needed for this type of convolution.")

else:
if subsample[0] == 1 and subsample[1] == 1:
Expand Down
5 changes: 2 additions & 3 deletions yann/core/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ def __init__ ( self,
ds,
img_shp,
mode = 'max',
ignore_border = False,
ignore_border = True,
verbose = 1

):

if verbose >=3:
Expand Down Expand Up @@ -102,7 +101,7 @@ def __init__ ( self,
ignore_border = ignore_border,
mode = 'average_exc_pad'
)

# ignore_border has some issue. False seems to pull things off GPU.
self.out_shp = (img_shp[0], img_shp[1], _out_height, _out_width)

if __name__ == '__main__':
Expand Down

0 comments on commit 7463edb

Please sign in to comment.