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

Method get_cost_updates

code/dA.py:233–260  ·  view source on GitHub ↗

This function computes the cost and the updates for one trainng step of the dA

(self, corruption_level, learning_rate)

Source from the content-addressed store, hash-verified

231 return T.nnet.sigmoid(T.dot(hidden, self.W_prime) + self.b_prime)
232
233 def get_cost_updates(self, corruption_level, learning_rate):
234 """ This function computes the cost and the updates for one trainng
235 step of the dA """
236
237 tilde_x = self.get_corrupted_input(self.x, corruption_level)
238 y = self.get_hidden_values(tilde_x)
239 z = self.get_reconstructed_input(y)
240 # note : we sum over the size of a datapoint; if we are using
241 # minibatches, L will be a vector, with one entry per
242 # example in minibatch
243 L = - T.sum(self.x * T.log(z) + (1 - self.x) * T.log(1 - z), axis=1)
244 # note : L is now a vector, where each element is the
245 # cross-entropy cost of the reconstruction of the
246 # corresponding example of the minibatch. We need to
247 # compute the average of all these to get the cost of
248 # the minibatch
249 cost = T.mean(L)
250
251 # compute the gradients of the cost of the `dA` with respect
252 # to its parameters
253 gparams = T.grad(cost, self.params)
254 # generate the list of updates
255 updates = [
256 (param, param - learning_rate * gparam)
257 for param, gparam in zip(self.params, gparams)
258 ]
259
260 return (cost, updates)
261
262
263def test_dA(learning_rate=0.1, training_epochs=15,

Callers 3

test_dAFunction · 0.45
pretraining_functionsMethod · 0.45
pretraining_functionsMethod · 0.45

Calls 3

get_corrupted_inputMethod · 0.95
get_hidden_valuesMethod · 0.95

Tested by 1

test_dAFunction · 0.36