class_docstr: Molecular Attention Transformer.
  
  This class implements the Molecular Attention Transformer [1]_.
  The MATFeaturizer (deepchem.feat.MATFeaturizer) is intended to work with this class.
  The model takes a batch of MATEncodings (from MATFeaturizer) as input, and returns an array of size Nx1, where N is the number of molecules in the batch.
  Each molecule is broken down into its Node Features matrix, adjacency matrix and distance matrix.
  A mask tensor is calculated for the batch. All of this goes as input to the MATEmbedding, MATEncoder and MATGenerator layers, which are defined in deepchem.models.torch_models.layers.py
  
  Currently, MATModel is intended to be a regression model for the freesolv dataset.
  
  References
  ----------
  .. [1] Lukasz Maziarka et al. "Molecule Attention Transformer" Graph Representation Learning workshop and Machine Learning and the Physical Sciences workshop at NeurIPS 2019. 2020. https://arxiv.org/abs/2002.08264
  
  Examples
  --------
  >>> import deepchem as dc
  >>> import pandas as pd
  >>> smiles = ['CC', 'CCC',  'CCCC', 'CCCCC', 'CCCCCCC']
  >>> vals = [1.35, 6.72, 5.67, 1.23, 1.76]
  >>> df = pd.DataFrame(list(zip(smiles, vals)), columns = ['smiles', 'y'])
  >>> loader = dc.data.CSVLoader(tasks=['y'], feature_field='smiles', featurizer=dc.feat.MATFeaturizer())
  >>> df.to_csv('test.csv')
  >>> dataset = loader.create_dataset('test.csv')
  >>> model = dc.models.torch_models.MATModel(batch_size = 2)
  >>> out = model.fit(dataset, nb_epoch = 1)
class_docstr_tok: ["Molecular","Attention","Transformer",".","This","class","implements","the","Molecular","Attention","Transformer","[","1","]","_",".","The","MATFeaturizer","(","deepchem.feat.MATFeaturizer",")","is","intended","to","work","with","this","class",".","The","model","takes","a","batch","of","MATEncodings","(","from","MATFeaturizer",")","as","input",",","and","returns","an","array","of","size","Nx1",",","where","N","is","the","number","of","molecules","in","the","batch",".","Each","molecule","is","broken","down","into","its","Node","Features","matrix",",","adjacency","matrix","and","distance","matrix",".","A","mask","tensor","is","calculated","for","the","batch",".","All","of","this","goes","as","input","to","the","MATEmbedding",",","MATEncoder","and","MATGenerator","layers",",","which","are","defined","in","deepchem.models.torch_models.layers.py","Currently",",","MATModel","is","intended","to","be","a","regression","model","for","the","freesolv","dataset",".","References","--","--","--","--","--","..","[","1","]","Lukasz","Maziarka","et","al",".","``","Molecule","Attention","Transformer","''","Graph","Representation","Learning","workshop","and","Machine","Learning","and","the","Physical","Sciences","workshop","at","NeurIPS","2019",".","2020.","https",":","\/\/arxiv.org\/abs\/2002.08264","Examples","--","--","--","--",">",">",">","import","deepchem","as","dc",">",">",">","import","pandas","as","pd",">",">",">","smiles","=","[","'CC","'",",","'CCC","'",",","'CCCC","'",",","'CCCCC","'",",","'CCCCCCC","'","]",">",">",">","vals","=","[","1.35",",","6.72",",","5.67",",","1.23",",","1.76","]",">",">",">","df","=","pd.DataFrame","(","list","(","zip","(","smiles",",","vals",")",")",",","columns","=","[","'smiles","'",",","'","y","'","]",")",">",">",">","loader","=","dc.data.CSVLoader","(","tasks=","[","'","y","'","]",",","feature_field='smiles","'",",","featurizer=dc.feat.MATFeaturizer","(",")",")",">",">",">","df.to_csv","(","'test.csv","'",")",">",">",">","dataset","=","loader.create_dataset","(","'test.csv","'",")",">",">",">","model","=","dc.models.torch_models.MATModel","(","batch_size","=","2",")",">",">",">","out","=","model.fit","(","dataset",",","nb_epoch","=","1",")"]
code: def default_generator(
      self,
      dataset,
      epochs=1,
      mode="fit",
      deterministic=True,
      pad_batches=True,
      **kwargs,
  ):
      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,
          ):
              node_features = self.pad_sequence(
                  [
                      torch.tensor(data.node_features).float()
                      for data in X_b
                  ]
              )
              adjacency_matrix = self.pad_sequence(
                  [
                      torch.tensor(data.adjacency_matrix).float()
                      for data in X_b
                  ]
              )
              distance_matrix = self.pad_sequence(
                  [
                      torch.tensor(data.distance_matrix).float()
                      for data in X_b
                  ]
              )
  
              inputs = [
                  node_features,
                  adjacency_matrix,
                  distance_matrix,
              ]
              yield (inputs, [y_b], [w_b])
  
file_path: deepchem/deepchem/models/torch_models/mat.py
imports: import torch
  import torch.nn
  import numpy
  from deepchem.models.torch_models import layers
  from deepchem.models.torch_models.torch_model import TorchModel
  from deepchem.models.losses import L2Loss
  from typing import Any
label_desc: Use image node_id 4 for calling the MATModel obj's underlying member method code with example usage: obj.default_generator(dataset, epochs, mode, deterministic, pad_batches) without return types