Vanishing and exploding gradients