modified tanh layer, maked code cleaner. corrected the mistake for cpu code.