'Fit the model to the data.
Parameters
train_X : array_like, shape (n_samples, n_features)
Training data.
train_Y : array_like, shape (n_samples, n_features)
Training reference data.
val_X : array_like, shape (N, n_features) optional, (default = None).
Validation data.
val_Y : array_like, shape (N, n_features) optional, (default = None).
Validation reference data.
graph : tf.Graph, optional (default = None)
Tensorflow Graph object.
Returns'

def fit(self, train_X, train_Y=None, val_X=None, val_Y=None, graph=None):

    g = (graph if (graph is not None) else self.tf_graph)
    with g.as_default():
        self.build_model(train_X.shape[1])
        with tf.Session() as self.tf_session:
            summary_objs = tf_utils.init_tf_ops(self.tf_session)
            self.tf_merged_summaries = summary_objs[0]
            self.tf_summary_writer = summary_objs[1]
            self.tf_saver = summary_objs[2]
            self._train_model(train_X, train_Y, val_X, val_Y)
            self.tf_saver.save(self.tf_session, self.model_path)
