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 20, 2016
1 parent 3a742e1 commit e94f244
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions yadll/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@


class Network(object):
"""
The :class:`Network` class is the container of all the layers of the network.
Parameters
----------
name : `string`
The name of the network
layers : list of :class: `Layer`, optional
create a network from another network.layers
Attributes
----------
layers : list of :class: `Layer`
the list of layers in the network
params : list of `theano shared variables`
the list of all the parameters of the network
"""
def __init__(self, name=None, layers=None):
self.layers = []
self.params = []
Expand All @@ -14,17 +31,52 @@ def __init__(self, name=None, layers=None):
self.add(layer)

def add(self, layer):
"""
add a layer to the Network
Parameters
----------
layer: :class: `Layer`
"""
self.layers.append(layer)
self.params.extend(layer.params)
self.reguls += layer.reguls
if isinstance(layer, UnsupervisedLayer):
self.has_unsupervised_layer = True

def params(self):
"""
Returns the list of parameters of the network
Returns
-------
params:
list of parameters of the network
"""
return self.params

def reguls(self):
"""
Returns the regularization cost for the network
Returns
-------
reguls: symbolic expresssion
regularization cost for the network
"""
return self.reguls

def get_output(self, **kwargs):
"""
Returns the output of the network
Returns
-------
symbolic expresssion
output of the network
"""
return self.layers[-1].get_output(**kwargs)

0 comments on commit e94f244

Please sign in to comment.