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

Class cA

code/cA.py:53–228  ·  view source on GitHub ↗

Contractive Auto-Encoder class (cA) The contractive autoencoder tries to reconstruct the input with an additional constraint on the latent space. With the objective of obtaining a robust representation of the input space, we regularize the L2 norm(Froebenius) of the jacobian of the

Source from the content-addressed store, hash-verified

51
52
53class cA(object):
54 """ Contractive Auto-Encoder class (cA)
55
56 The contractive autoencoder tries to reconstruct the input with an
57 additional constraint on the latent space. With the objective of
58 obtaining a robust representation of the input space, we
59 regularize the L2 norm(Froebenius) of the jacobian of the hidden
60 representation with respect to the input. Please refer to Rifai et
61 al.,2011 for more details.
62
63 If x is the input then equation (1) computes the projection of the
64 input into the latent space h. Equation (2) computes the jacobian
65 of h with respect to x. Equation (3) computes the reconstruction
66 of the input, while equation (4) computes the reconstruction
67 error and the added regularization term from Eq.(2).
68
69 .. math::
70
71 h_i = s(W_i x + b_i) (1)
72
73 J_i = h_i (1 - h_i) * W_i (2)
74
75 x' = s(W' h + b') (3)
76
77 L = -sum_{k=1}^d [x_k \log x'_k + (1-x_k) \log( 1-x'_k)]
78 + lambda * sum_{i=1}^d sum_{j=1}^n J_{ij}^2 (4)
79
80 """
81
82 def __init__(self, numpy_rng, input=None, n_visible=784, n_hidden=100,
83 n_batchsize=1, W=None, bhid=None, bvis=None):
84 """Initialize the cA class by specifying the number of visible units
85 (the dimension d of the input), the number of hidden units (the
86 dimension d' of the latent or hidden space) and the contraction level.
87 The constructor also receives symbolic variables for the input, weights
88 and bias.
89
90 :type numpy_rng: numpy.random.RandomState
91 :param numpy_rng: number random generator used to generate weights
92
93 :type theano_rng: theano.tensor.shared_randomstreams.RandomStreams
94 :param theano_rng: Theano random generator; if None is given
95 one is generated based on a seed drawn from `rng`
96
97 :type input: theano.tensor.TensorType
98 :param input: a symbolic description of the input or None for
99 standalone cA
100
101 :type n_visible: int
102 :param n_visible: number of visible units
103
104 :type n_hidden: int
105 :param n_hidden: number of hidden units
106
107 :type n_batchsize int
108 :param n_batchsize: number of examples per batch
109
110 :type W: theano.tensor.TensorType

Callers 1

test_cAFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_cAFunction · 0.68