class_docstr: Directed Acyclic Graph models for molecular property prediction.
  
  This model is based on the following paper:
  
  Lusci, Alessandro, Gianluca Pollastri, and Pierre Baldi. "Deep architectures and deep learning in chemoinformatics: the prediction of aqueous solubility for drug-like molecules." Journal of chemical information and modeling 53.7 (2013): 1563-1575.
  
  The basic idea for this paper is that a molecule is usually
  viewed as an undirected graph. However, you can convert it to
  a series of directed graphs. The idea is that for each atom,
  you make a DAG using that atom as the vertex of the DAG and
  edges pointing "inwards" to it. This transformation is
  implemented in
  `dc.trans.transformers.DAGTransformer.UG_to_DAG`.
  
  This model accepts ConvMols as input, just as GraphConvModel
  does, but these ConvMol objects must be transformed by
  dc.trans.DAGTransformer.
  
  As a note, performance of this model can be a little
  sensitive to initialization. It might be worth training a few
  different instantiations to get a stable set of parameters.
class_docstr_tok: ["Directed","Acyclic","Graph","models","for","molecular","property","prediction",".","This","model","is","based","on","the","following","paper",":","Lusci",",","Alessandro",",","Gianluca","Pollastri",",","and","Pierre","Baldi",".","``","Deep","architectures","and","deep","learning","in","chemoinformatics",":","the","prediction","of","aqueous","solubility","for","drug-like","molecules",".","''","Journal","of","chemical","information","and","modeling","53.7","(","2013",")",":","1563-1575",".","The","basic","idea","for","this","paper","is","that","a","molecule","is","usually","viewed","as","an","undirected","graph",".","However",",","you","can","convert","it","to","a","series","of","directed","graphs",".","The","idea","is","that","for","each","atom",",","you","make","a","DAG","using","that","atom","as","the","vertex","of","the","DAG","and","edges","pointing","``","inwards","''","to","it",".","This","transformation","is","implemented","in","`","dc.trans.transformers.DAGTransformer.UG_to_DAG","`",".","This","model","accepts","ConvMols","as","input",",","just","as","GraphConvModel","does",",","but","these","ConvMol","objects","must","be","transformed","by","dc.trans.DAGTransformer",".","As","a","note",",","performance","of","this","model","can","be","a","little","sensitive","to","initialization",".","It","might","be","worth","training","a","few","different","instantiations","to","get","a","stable","set","of","parameters","."]
docstr: Convert a dataset into the tensors needed for learning
docstr_tok: ["Convert","a","dataset","into","the","tensors","needed","for","learning"]
code: def default_generator(
      self,
      dataset,
      epochs=1,
      mode="fit",
      deterministic=True,
      pad_batches=True,
  ):
      """Convert a dataset into the tensors needed for learning"""
      for epoch in range(epochs):
          for X_b, y_b, w_b, ids_b in dataset.iterbatches(
              batch_size=self.batch_size,
              deterministic=deterministic,
              pad_batches=pad_batches,
          ):
              if y_b is not None and self.mode == "classification":
                  y_b = to_one_hot(
                      y_b.flatten(), self.n_classes
                  ).reshape(-1, self.n_tasks, self.n_classes)
  
              atoms_per_mol = [mol.get_num_atoms() for mol in X_b]
              n_atoms = sum(atoms_per_mol)
              start_index = [0] + list(np.cumsum(atoms_per_mol)[:-1])
  
              atoms_all = []
              # calculation orders for a batch of molecules
              parents_all = []
              calculation_orders = []
              calculation_masks = []
              membership = []
              for idm, mol in enumerate(X_b):
                  # padding atom features vector of each molecule with 0
                  atoms_all.append(mol.get_atom_features())
                  parents = mol.parents
                  parents_all.extend(parents)
                  calculation_index = np.array(parents)[:, :, 0]
                  mask = np.array(
                      calculation_index - self.max_atoms, dtype=bool
                  )
                  calculation_orders.append(
                      calculation_index + start_index[idm]
                  )
                  calculation_masks.append(mask)
                  membership.extend([idm] * atoms_per_mol[idm])
              if mode == "predict":
                  dropout = np.array(0.0)
              else:
                  dropout = np.array(1.0)
  
              yield (
                  [
                      np.concatenate(atoms_all, axis=0),
                      np.stack(parents_all, axis=0),
                      np.concatenate(calculation_orders, axis=0),
                      np.concatenate(calculation_masks, axis=0),
                      np.array(membership),
                      np.array(n_atoms),
                      dropout,
                  ],
                  [y_b],
                  [w_b],
              )
  
imports: from collections.abc import Sequence
  import deepchem
  import numpy
  import tensorflow
  from typing import List, Union, Tuple, Iterable, Dict, Optional
  from deepchem.utils.typing import OneOrMany, LossFn, ActivationFn
  from deepchem.data import Dataset, pad_features
  from deepchem.feat.mol_graphs import ConvMol
  from deepchem.metrics import to_one_hot
  from deepchem.models import KerasModel, layers
  from deepchem.models.losses import L2Loss, SoftmaxCrossEntropy, Loss
  from tensorflow.keras.layers import Input, Dense, Reshape, Softmax, Dropout, Activation, BatchNormalization
  import warnings
label_desc: Use image node_id 2 for calling the DAGModel obj's underlying member method code with example usage: obj.default_generator(dataset, epochs, mode, deterministic, pad_batches) without return types