class_docstr: Implements DTNN models for regression.
  
  DTNN is based on the many-body Hamiltonian concept, which is a fundamental principle in quantum mechanics.
  DTNN recieves a molecule's distance matrix and membership of its atom from its Coulomb Matrix representation.
  Then, it iteratively refines the representation of each atom by considering its interactions with neighboring atoms.
  Finally, it predicts the energy of the molecule by summing up the energies of the individual atoms.
  
  This class implements the Deep Tensor Neural Network (DTNN) [1]_.
  
  Examples
  --------
  >>> import os
  >>> from deepchem.data import SDFLoader
  >>> from deepchem.feat import CoulombMatrix
  >>> from deepchem.models.torch_models import DTNNModel
  >>> model_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  >>> dataset_file = os.path.join(model_dir, 'tests/assets/qm9_mini.sdf')
  >>> TASKS = ["alpha", "homo"]
  >>> loader = SDFLoader(tasks=TASKS, featurizer=CoulombMatrix(29), sanitize=True)
  >>> data = loader.create_dataset(dataset_file, shard_size=100)
  >>> n_tasks = data.y.shape[1]
  >>> model = DTNNModel(n_tasks,
  ...                   n_embedding=20,
  ...                   n_distance=100,
  ...                   learning_rate=1.0,
  ...                   mode="regression")
  >>> loss = model.fit(data, nb_epoch=250)
  >>> pred = model.predict(data)
  
  References
  ----------
  .. [1] Schütt, Kristof T., et al. "Quantum-chemical insights from deep
      tensor neural networks." Nature communications 8.1 (2017): 1-8.
docstr: Parameters
  ----------
  n_tasks: int
      Number of tasks
  n_embedding: int (default 30)
      Number of features per atom.
  n_hidden: int (default 100)
      Number of features for each molecule after DTNNStep
  n_distance: int (default 100)
      granularity of distance matrix
      step size will be (distance_max-distance_min)/n_distance
  distance_min: float (default -1)
      minimum distance of atom pairs (in Angstrom)
  distance_max: float (default = 18)
      maximum distance of atom pairs (in Angstrom)
  output_activation: bool (default True)
      determines whether an activation function should be apply  to its output.
  mode: str (default "regression")
      Only "regression" is currently supported.
  dropout: float (default 0.0)
      the dropout probablity to use.
  n_steps: int (default 2)
      Number of DTNNStep Layers to use.
docstr_tok: ["Parameters","--","--","--","--","--","n_tasks",":","int","Number","of","tasks","n_embedding",":","int","(","default","30",")","Number","of","features","per","atom",".","n_hidden",":","int","(","default","100",")","Number","of","features","for","each","molecule","after","DTNNStep","n_distance",":","int","(","default","100",")","granularity","of","distance","matrix","step","size","will","be","(","distance_max-distance_min",")","\/n_distance","distance_min",":","float","(","default","-1",")","minimum","distance","of","atom","pairs","(","in","Angstrom",")","distance_max",":","float","(","default","=","18",")","maximum","distance","of","atom","pairs","(","in","Angstrom",")","output_activation",":","bool","(","default","True",")","determines","whether","an","activation","function","should","be","apply","to","its","output",".","mode",":","str","(","default","``","regression","''",")","Only","``","regression","''","is","currently","supported",".","dropout",":","float","(","default","0.0",")","the","dropout","probablity","to","use",".","n_steps",":","int","(","default","2",")","Number","of","DTNNStep","Layers","to","use","."]
code: def __init__(
      self,
      n_tasks: int,
      n_embedding: int = 30,
      n_hidden: int = 100,
      n_distance: int = 100,
      distance_min: float = -1,
      distance_max: float = 18,
      output_activation: bool = True,
      mode: str = "regression",
      dropout: float = 0.0,
      n_steps: int = 2,
      **kwargs,
  ):
      """
      Parameters
      ----------
      n_tasks: int
          Number of tasks
      n_embedding: int (default 30)
          Number of features per atom.
      n_hidden: int (default 100)
          Number of features for each molecule after DTNNStep
      n_distance: int (default 100)
          granularity of distance matrix
          step size will be (distance_max-distance_min)/n_distance
      distance_min: float (default -1)
          minimum distance of atom pairs (in Angstrom)
      distance_max: float (default = 18)
          maximum distance of atom pairs (in Angstrom)
      output_activation: bool (default True)
          determines whether an activation function should be apply  to its output.
      mode: str (default "regression")
          Only "regression" is currently supported.
      dropout: float (default 0.0)
          the dropout probablity to use.
      n_steps: int (default 2)
          Number of DTNNStep Layers to use.
  
      """
      if dropout < 0 or dropout > 1:
          raise ValueError(
              "dropout probability has to be between 0 and 1, "
              "but got {}".format(dropout)
          )
      model = DTNN(
          n_tasks=n_tasks,
          n_embedding=n_embedding,
          n_hidden=n_hidden,
          n_distance=n_distance,
          distance_min=distance_min,
          distance_max=distance_max,
          output_activation=output_activation,
          mode=mode,
          dropout=dropout,
          n_steps=n_steps,
      )
      if mode not in ["regression"]:
          raise ValueError(
              "Only 'regression' mode is currently supported"
          )
      super(DTNNModel, self).__init__(
          model, L2Loss(), ["prediction"], **kwargs
      )
  
file_path: deepchem/deepchem/models/torch_models/dtnn.py
imports: from typing import List
  import torch.nn
  import torch
  from deepchem.models.losses import L2Loss
  from deepchem.models.torch_models import layers
  from deepchem.models.torch_models import TorchModel
  from deepchem.data.datasets import Dataset
  from deepchem.utils import batch_coulomb_matrix_features
label_desc: Use image node_id 1 to create a new DTNNModel object from inherited base classes: TorchModel with example: obj = DTNNModel(n_tasks, n_embedding, n_hidden, n_distance, distance_min, distance_max, output_activation, mode, dropout, n_steps)