#5127·deepchem

DAGLayer and DAGGather reject glorot_normal/xavier_normal init

Author: sumitjhadevCreated Sep 8, 2026Updated Sep 8, 2026

Bug

DAGLayer and DAGGather both document init="glorot_normal" and init="xavier_normal" as supported options, but passing either raises ValueError instead of constructing the layer.

To Reproduce

Steps to reproduce the behavior:

  1. from deepchem.models.torch_models.layers import DAGLayer
  2. DAGLayer(init="glorot_normal")
  3. Raises ValueError: Unsupported init: glorot_normal

Same happens with DAGGather(init="glorot_normal"), and with init="xavier_normal" on both classes.

Expected behavior

Layer should construct normally, using nn.init.xavier_normal_ for the weights, same as it already does for glorot_uniform/xavier_uniform.

Environment

  • OS: Linux
  • Python version: 3.12
  • DeepChem version: 2.8.1.dev (current master)
  • RDKit version (optional): N/A, not needed to reproduce
  • TensorFlow version (optional): N/A, not needed to reproduce
  • PyTorch version (optional): 2.x
  • Any other relevant information: bug is in _initialize_weights for both classes in deepchem/models/torch_models/layers.py

Additional context

Looks like a comparison bug — self.init (a str) is compared with == against a list instead of checking membership with in, so that branch can never match. Happy to submit a fix if useful.