old_contents: """
  Script that trains graph-conv models on Tox21 dataset.
  """
  from __future__ import print_function
  from __future__ import division
  from __future__ import unicode_literals
  
  import numpy as np
  np.random.seed(123)
  import tensorflow as tf
  tf.set_random_seed(123)
  import deepchem as dc
  from deepchem.molnet import load_sampl
  
  # Load Tox21 dataset
  SAMPL_tasks, SAMPL_datasets, transformers = load_sampl(featurizer='GraphConv')
  train_dataset, valid_dataset, test_dataset = SAMPL_datasets
  
  # Fit models
  metric = dc.metrics.Metric(dc.metrics.pearson_r2_score, np.mean)
  
  # Do setup required for tf/keras models
  # Number of features on conv-mols
  n_feat = 75
  # Batch size of models
  batch_size = 128
  graph_model = dc.nn.SequentialGraph(n_feat)
  graph_model.add(dc.nn.GraphConv(128, n_feat, activation='relu'))
  graph_model.add(dc.nn.BatchNormalization(epsilon=1e-5, mode=1))
  graph_model.add(dc.nn.GraphPool())
  graph_model.add(dc.nn.GraphConv(128, 128, activation='relu'))
  graph_model.add(dc.nn.BatchNormalization(epsilon=1e-5, mode=1))
  graph_model.add(dc.nn.GraphPool())
  # Gather Projection
  graph_model.add(dc.nn.Dense(256, 128, activation='relu'))
  graph_model.add(dc.nn.BatchNormalization(epsilon=1e-5, mode=1))
  graph_model.add(dc.nn.GraphGather(batch_size, activation="tanh"))
  # Dense post-processing layer
  
  model = dc.models.MultitaskGraphRegressor(
      graph_model,
      len(SAMPL_tasks),
      n_feat,
      batch_size=batch_size,
      learning_rate=1e-3,
      learning_rate_decay_time=1000,
      optimizer_type="adam",
      beta1=.9,
      beta2=.999)
  
  # Fit trained model
  model.fit(train_dataset, nb_epoch=20)
  
  print("Evaluating model")
  train_scores = model.evaluate(train_dataset, [metric], transformers)
  valid_scores = model.evaluate(valid_dataset, [metric], transformers)
  
  print("Train scores")
  print(train_scores)
  
  print("Validation scores")
  print(valid_scores)
  
new_contents: """
  Script that trains graph-conv models on SAMPL(FreeSolv) dataset.
  """
  from __future__ import print_function
  from __future__ import division
  from __future__ import unicode_literals
  
  import numpy as np
  np.random.seed(123)
  import tensorflow as tf
  tf.set_random_seed(123)
  import deepchem as dc
  from deepchem.molnet import load_sampl
  
  # Load SAMPL(FreeSolv) dataset
  SAMPL_tasks, SAMPL_datasets, transformers = load_sampl(featurizer='GraphConv')
  train_dataset, valid_dataset, test_dataset = SAMPL_datasets
  
  # Fit models
  metric = dc.metrics.Metric(dc.metrics.pearson_r2_score, np.mean)
  
  # Do setup required for tf/keras models
  # Number of features on conv-mols
  n_feat = 75
  # Batch size of models
  batch_size = 128
  graph_model = dc.nn.SequentialGraph(n_feat)
  graph_model.add(dc.nn.GraphConv(128, n_feat, activation='relu'))
  graph_model.add(dc.nn.BatchNormalization(epsilon=1e-5, mode=1))
  graph_model.add(dc.nn.GraphPool())
  graph_model.add(dc.nn.GraphConv(128, 128, activation='relu'))
  graph_model.add(dc.nn.BatchNormalization(epsilon=1e-5, mode=1))
  graph_model.add(dc.nn.GraphPool())
  # Gather Projection
  graph_model.add(dc.nn.Dense(256, 128, activation='relu'))
  graph_model.add(dc.nn.BatchNormalization(epsilon=1e-5, mode=1))
  graph_model.add(dc.nn.GraphGather(batch_size, activation="tanh"))
  # Dense post-processing layer
  
  model = dc.models.MultitaskGraphRegressor(
      graph_model,
      len(SAMPL_tasks),
      n_feat,
      batch_size=batch_size,
      learning_rate=1e-3,
      learning_rate_decay_time=1000,
      optimizer_type="adam",
      beta1=.9,
      beta2=.999)
  
  # Fit trained model
  model.fit(train_dataset, nb_epoch=20)
  
  print("Evaluating model")
  train_scores = model.evaluate(train_dataset, [metric], transformers)
  valid_scores = model.evaluate(valid_dataset, [metric], transformers)
  
  print("Train scores")
  print(train_scores)
  
  print("Validation scores")
  print(valid_scores)
  
subject: Update sampl_graph_conv.py