def backpropagate(self, sample):
"""
Compute the derivate at each level of the sample and return the sum
of it (stored in a gradient object)
"""
# Notations:
# a: Output at root node (after activation)
# z: Output before softmax (z=Ws*a + bs)
# y: Output after softmax, final prediction (y=softmax(z))
# E: Cost of the current prediction (E = cost(softmax(Ws*a + bs)) = cost(y))
# t: Gound truth prediction
# We then have:
# x -> a -> x -> a -> ... x -> a(last layer) -> z (projection on dim 5) -> y (softmax prediction) -> E (cost)
return self._backpropagate(sample.root, None) # No incoming error for the root node (except the one coming from softmax)
评论列表
文章目录