Factored train() out of deep_belief_network.py