Unverified Commit aecd17c9 authored by Daiki Nishikawa's avatar Daiki Nishikawa Committed by GitHub
Browse files

Merge pull request #2123 from nd-02110114/cgcnn-add-mode-option

Add mode args for CGCNNModel
parents e176504a 8323b6dd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -32,18 +32,18 @@ install:
  - conda update -q conda
  - bash scripts/install_deepchem_conda.sh cpu
  - conda activate deepchem
  - python setup.py install
  - pip install -e .
script:
  - bash devtools/run_yapf.sh
  - bash devtools/run_flake8.sh
  - mypy -p deepchem
  - pytest -m "not slow" --cov=deepchem deepchem
  - pytest -v -m "not slow" --cov=deepchem deepchem
  - if [ $TRAVIS_PYTHON_VERSION == '3.7' ]; then
      cd docs && pip install -r requirements.txt;
      make clean html && cd ..;
    fi
  - if [ $TRAVIS_PYTHON_VERSION == '3.7' ]; then
      find ./deepchem -name "*.py" ! -name '*load_dataset_template.py' | xargs python -m doctest -v;
      pytest -v --ignore-glob='deepchem/**/test*.py' --doctest-modules deepchem;
    fi
after_success:
  - echo $TRAVIS_SECURE_ENV_VARS
+1 −6
Original line number Diff line number Diff line
"""
Callback functions that can be invoked while fitting a KerasModel.
"""

import tensorflow as tf
import sys

from deepchem.models.keras_model import is_wandb_available
if is_wandb_available():
  import wandb


class ValidationCallback(object):
  """Performs validation while training a KerasModel.
@@ -86,6 +80,7 @@ class ValidationCallback(object):
      for key in scores:
        model._log_value_to_tensorboard(tag=key, simple_value=scores[key])
    if model.wandb:
      import wandb
      wandb.log(scores, step=step)
    if self.save_dir is not None:
      score = scores[self.metrics[self.save_metric].name]
+9 −13
Original line number Diff line number Diff line
@@ -8,8 +8,6 @@ try:
except:
  from collections import Sequence as SequenceCollection

logger = logging.getLogger(__name__)

from deepchem.data import Dataset, NumpyDataset
from deepchem.metrics import Metric
from deepchem.models.losses import Loss
@@ -34,9 +32,7 @@ try:
except (ImportError, AttributeError):
  _has_wandb = False


def is_wandb_available():
  return _has_wandb
logger = logging.getLogger(__name__)


class KerasModel(Model):
@@ -188,12 +184,12 @@ class KerasModel(Model):
    self.tensorboard = tensorboard

    # W&B logging
    if wandb and not is_wandb_available():
    if wandb and not _has_wandb:
      logger.warning(
          "You set wandb to True but W&B is not installed. To use wandb logging, "
          "run `pip install wandb; wandb login` see https://docs.wandb.com/huggingface."
      )
    self.wandb = wandb and is_wandb_available()
    self.wandb = wandb and _has_wandb

    # Backwards compatibility
    if "tensorboard_log_frequency" in kwargs:
@@ -381,7 +377,6 @@ class KerasModel(Model):
    avg_loss = 0.0
    last_avg_loss = 0.0
    averaged_batches = 0
    train_op = None
    if loss is None:
      loss = self._loss_fn
    var_key = None
@@ -574,12 +569,12 @@ class KerasModel(Model):
    variances: Optional[List[np.ndarray]] = None
    if (outputs is not None) and (other_output_types is not None):
      raise ValueError(
          'This model cannot compute outputs and other output_types simultaneously. Please invoke one at a time.'
      )
          'This model cannot compute outputs and other output_types simultaneously.'
          'Please invoke one at a time.')
    if uncertainty and (other_output_types is not None):
      raise ValueError(
          'This model cannot compute uncertainties and other output types simultaneously. Please invoke one at a time.'
      )
          'This model cannot compute uncertainties and other output types simultaneously.'
          'Please invoke one at a time.')
    if uncertainty:
      assert outputs is None
      if self._variance_outputs is None or len(self._variance_outputs) == 0:
@@ -596,7 +591,8 @@ class KerasModel(Model):
    if (outputs is not None and self.model.inputs is not None and
        len(self.model.inputs) == 0):
      raise ValueError(
          "Cannot use 'outputs' argument with a model that does not specify its inputs. Note models defined in imperative subclassing style cannot specify outputs"
          "Cannot use 'outputs' argument with a model that does not specify its inputs."
          "Note models defined in imperative subclassing style cannot specify outputs"
      )
    if isinstance(outputs, tf.Tensor):
      outputs = [outputs]
+9.19 KiB

File added.

No diff preview for this file type.

−12.1 KiB (4.38 KiB)

File changed.

No diff preview for this file type.

Loading