Skip to content

Commit

Permalink
first yadll commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pchavanne committed Jun 21, 2016
1 parent d0ad20b commit f1634bf
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ Different networks tested on mnist:
* Stacked Denoising Autoencoder
* Restricted Boltzmann Machine
* Deep Belief Network
* RNN
* LSTM
* Recurent Neural Networks
* Long Short-Term Memory

get the list of available networks:

Expand Down
47 changes: 44 additions & 3 deletions docs/modules/init.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@
.. _init:
:mod:`yadll.init`

Init
----
.. automodule:: yadll.init

Initializers
------------

.. autosummary::

constant
uniform
normal
glorot_uniform
glorot_normal
he_uniform
he_normal
orthogonal


Detailed description
--------------------

.. autoclass:: initializer
:members:

.. autoclass:: constant
:members:

.. autoclass:: uniform
:members:

.. autoclass:: normal
:members:

.. autoclass:: glorot_uniform
:members:

.. autoclass:: glorot_normal
:members:

.. autoclass:: he_uniform
:members:

.. autoclass:: he_normal
:members:
37 changes: 37 additions & 0 deletions yadll/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,55 @@


def initializer(init_obj, shape, name, fan=None):
"""
Call an Initializer from an init_obj
Parameters
----------
init_obj : `init_obj`
an init_obj is an initializer function or the tuple of (initializer function, dict of args)
example : init_obj = glorot_uniform or init_obj = (glorot_uniform, {'gain':tanh, 'borrow':False})
shape : `tuple` or int
shape of the return shared variables
Returns
-------
Initialized shared variables
"""
if not isinstance(init_obj, tuple):
return init_obj(shape, name=name, fan=fan)
else:
return init_obj[0](shape, name=name, fan=fan, **init_obj[1])


def constant(shape, value=0.0, name=None, borrow=True, **kwargs):
"""
Initialize all the weights to a constant value
Parameters
----------
shape
scale
"""
return shared_variable(np.ones(shape=shape) * value,
name=name, borrow=borrow)


def uniform(shape, scale=0.5, name=None, borrow=True, **kwargs):
"""
Initialize all the weights from the uniform distribution
Parameters
----------
shape
scale
name
borrow
kwargs
Returns
-------
"""
if not isinstance(scale, tuple):
scale = (-scale, scale) # (low, high)
return shared_variable(np_rng.uniform(low=scale[0], high=scale[1], size=shape),
Expand Down

0 comments on commit f1634bf

Please sign in to comment.