MCPcopy Index your code
hub / github.com/lisa-lab/DeepLearningTutorials / __init__

Method __init__

code/SdA.py:62–181  ·  view source on GitHub ↗

This class is made to support a variable number of layers. :type numpy_rng: numpy.random.RandomState :param numpy_rng: numpy random number generator used to draw initial weights :type theano_rng: theano.tensor.shared_randomstreams.RandomStreams

(
        self,
        numpy_rng,
        theano_rng=None,
        n_ins=784,
        hidden_layers_sizes=[500, 500],
        n_outs=10,
        corruption_levels=[0.1, 0.1]
    )

Source from the content-addressed store, hash-verified

60 """
61
62 def __init__(
63 self,
64 numpy_rng,
65 theano_rng=None,
66 n_ins=784,
67 hidden_layers_sizes=[500, 500],
68 n_outs=10,
69 corruption_levels=[0.1, 0.1]
70 ):
71 """ This class is made to support a variable number of layers.
72
73 :type numpy_rng: numpy.random.RandomState
74 :param numpy_rng: numpy random number generator used to draw initial
75 weights
76
77 :type theano_rng: theano.tensor.shared_randomstreams.RandomStreams
78 :param theano_rng: Theano random generator; if None is given one is
79 generated based on a seed drawn from `rng`
80
81 :type n_ins: int
82 :param n_ins: dimension of the input to the sdA
83
84 :type hidden_layers_sizes: list of ints
85 :param hidden_layers_sizes: intermediate layers size, must contain
86 at least one value
87
88 :type n_outs: int
89 :param n_outs: dimension of the output of the network
90
91 :type corruption_levels: list of float
92 :param corruption_levels: amount of corruption to use for each
93 layer
94 """
95
96 self.sigmoid_layers = []
97 self.dA_layers = []
98 self.params = []
99 self.n_layers = len(hidden_layers_sizes)
100
101 assert self.n_layers > 0
102
103 if not theano_rng:
104 theano_rng = RandomStreams(numpy_rng.randint(2 ** 30))
105 # allocate symbolic variables for the data
106 self.x = T.matrix('x') # the data is presented as rasterized images
107 self.y = T.ivector('y') # the labels are presented as 1D vector of
108 # [int] labels
109 # end-snippet-1
110
111 # The SdA is an MLP, for which all weights of intermediate layers
112 # are shared with a different denoising autoencoders
113 # We will first construct the SdA as a deep multilayer perceptron,
114 # and when constructing each sigmoidal layer we also construct a
115 # denoising autoencoder that shares weights with that layer
116 # During pretraining we will train these autoencoders (which will
117 # lead to chainging the weights of the MLP as well)
118 # During finetunining we will finish training the SdA by doing
119 # stochastich gradient descent on the MLP

Callers

nothing calls this directly

Calls 5

HiddenLayerClass · 0.90
dAClass · 0.90
LogisticRegressionClass · 0.90
errorsMethod · 0.45

Tested by

no test coverage detected