def two_step_backprop(mlp):
 X = T.matrix()
 y = T.vector()
 (H, y_hat) = mlp.fprop(X)
 l = loss(y_hat, y)
 (g_w, g_H) = T.grad(l, [mlp.w_out, H])
 f1 = function([X, y], [g_w, g_H])
 known_grads = OrderedDict()
 known_grads[H] = g_H
 g_W = T.grad(None, mlp.W_hid, known_grads=known_grads)
 f2 = function([X, g_H], g_W)
 return (f1, f2)

def two_step_backprop ( mlp ) : X = T . matrix ( ) y = T . vector ( ) ( H , y_hat ) = mlp . fprop ( X ) l = loss ( y_hat , y ) ( g_w , g_H ) = T . grad ( l , [ mlp . w_out , H ] ) f1 = function ( [ X , y ] , [ g_w , g_H ] ) known_grads = OrderedDict ( ) known_grads [ H ] = g_H g_W = T . grad ( None , mlp . W_hid , known_grads = known_grads ) f2 = function ( [ X , g_H ] , g_W ) return ( f1 , f2 )
mlp: a simplemlp instance returns: f1: a theano function takes two arguments: a minibatch of examples and a minibatch of targets .