class_docstr: Parent class for deepchem Tensorflow models.
  
  Classifier:
    n_classes
  
  Has the following attributes:
  
    placeholder_root: String placeholder prefix, used to create
      placeholder_scope.
  
  Generic base class for defining, training, and evaluating TensorflowGraphs.
  
  Subclasses must implement the following methods:
    build
    add_output_ops
    add_training_cost 
  
  Args:
    train: If True, model is in training mode.
    logdir: Directory for output files.
class_docstr_tok: ["Parent","class","for","deepchem","Tensorflow","models",".","Classifier",":","n_classes","Has","the","following","attributes",":","placeholder_root",":","String","placeholder","prefix",",","used","to","create","placeholder_scope",".","Generic","base","class","for","defining",",","training",",","and","evaluating","TensorflowGraphs",".","Subclasses","must","implement","the","following","methods",":","build","add_output_ops","add_training_cost","Args",":","train",":","If","True",",","model","is","in","training","mode",".","logdir",":","Directory","for","output","files","."]
docstr: Fit the model.
  
  Parameters
  ---------- 
  dataset: dc.data.Dataset
    Dataset object holding training data 
  nb_epoch: 10
    Number of training epochs.
  max_checkpoints_to_keep: int
    Maximum number of checkpoints to keep; older checkpoints will be deleted.
  log_every_N_batches: int
    Report every N batches. Useful for training on very large datasets,
    where epochs can take long time to finish.
  
  Raises
  ------
  AssertionError
    If model is not in training mode.
docstr_tok: ["Fit","the","model",".","Parameters","--","--","--","--","--","dataset",":","dc.data.Dataset","Dataset","object","holding","training","data","nb_epoch",":","10","Number","of","training","epochs",".","max_checkpoints_to_keep",":","int","Maximum","number","of","checkpoints","to","keep",";","older","checkpoints","will","be","deleted",".","log_every_N_batches",":","int","Report","every","N","batches",".","Useful","for","training","on","very","large","datasets",",","where","epochs","can","take","long","time","to","finish",".","Raises","--","--","--","AssertionError","If","model","is","not","in","training","mode","."]
code: def fit(
      self,
      dataset,
      nb_epoch=10,
      max_checkpoints_to_keep=5,
      log_every_N_batches=50,
      **kwargs,
  ):
      """Fit the model.
  
      Parameters
      ----------
      dataset: dc.data.Dataset
        Dataset object holding training data
      nb_epoch: 10
        Number of training epochs.
      max_checkpoints_to_keep: int
        Maximum number of checkpoints to keep; older checkpoints will be deleted.
      log_every_N_batches: int
        Report every N batches. Useful for training on very large datasets,
        where epochs can take long time to finish.
  
      Raises
      ------
      AssertionError
        If model is not in training mode.
      """
      ############################################################## TIMING
      time1 = time.time()
      ############################################################## TIMING
      log("Training for %d epochs" % nb_epoch, self.verbose)
      with self.train_graph.graph.as_default():
          train_op = self.get_training_op(
              self.train_graph.graph, self.train_graph.loss
          )
          with self._get_shared_session(train=True) as sess:
              sess.run(tf.global_variables_initializer())
              saver = tf.train.Saver(
                  max_to_keep=max_checkpoints_to_keep
              )
              # Save an initial checkpoint.
              saver.save(sess, self._save_path, global_step=0)
              for epoch in range(nb_epoch):
                  avg_loss, n_batches = 0.0, 0
                  for ind, (X_b, y_b, w_b, ids_b) in enumerate(
                      # Turns out there are valid cases where we don't want pad-batches
                      # on by default.
                      # dataset.iterbatches(batch_size, pad_batches=True)):
                      dataset.iterbatches(
                          self.batch_size, pad_batches=self.pad_batches
                      )
                  ):
                      if ind % log_every_N_batches == 0:
                          log("On batch %d" % ind, self.verbose)
                      # Run training op.
                      feed_dict = self.construct_feed_dict(
                          X_b, y_b, w_b, ids_b
                      )
                      fetches = self.train_graph.output + [
                          train_op,
                          self.train_graph.loss,
                      ]
                      fetched_values = sess.run(
                          fetches, feed_dict=feed_dict
                      )
                      output = fetched_values[
                          : len(self.train_graph.output)
                      ]
                      loss = fetched_values[-1]
                      avg_loss += loss
                      y_pred = np.squeeze(np.array(output))
                      y_b = y_b.flatten()
                      n_batches += 1
                  saver.save(sess, self._save_path, global_step=epoch)
                  avg_loss = float(avg_loss) / n_batches
                  log(
                      "Ending epoch %d: Average loss %g"
                      % (epoch, avg_loss),
                      self.verbose,
                  )
              # Always save a final checkpoint when complete.
              saver.save(sess, self._save_path, global_step=epoch + 1)
      ############################################################## TIMING
      time2 = time.time()
      print(
          "TIMING: model fitting took %0.3f s" % (time2 - time1),
          self.verbose,
      )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import unicode_literals
  import collections
  import pickle
  import os
  import time
  import warnings
  import numpy
  import pandas
  import tensorflow
  import tempfile
  from deepchem.models import Model
  from deepchem.metrics import from_one_hot
  from deepchem.nn import model_ops
  from deepchem.models.tensorflow_models import utils
  from deepchem.trans import undo_transforms
  from deepchem.utils.save import log
  from deepchem.utils.evaluate import Evaluator
  from deepchem.data import pad_features
  from tensorflow.contrib.layers.python.layers import batch_norm
label_desc: Use image node_id 7 for calling the TensorflowGraphModel obj's underlying member method code with example usage: obj.fit(dataset, nb_epoch, max_checkpoints_to_keep, log_every_N_batches) without return types