Refactored code base for Theano DBN