probs_y2 = probs[:, (T.arange(targets.shape[1])[(np.newaxis), :]), (targets)]
print(probs_y2.eval())
print((probs_y2.dimshuffle(0, 2, 1) - probs_y).eval())
Theano advanced indexing for tensor, shared index