Is AtomicConv.forward meant to pass inputs_x to every layer?
❓ Questions & Help
In deepchem/models/torch_models/layers.py, AtomicConv.forward passes inputs_x into every layer of the loop rather than the previous layer's output:
for layer, activation_fn, dropout in zip(self.layers, self.activation_fns, self.dropouts):
x = layer(inputs_x)__init__ builds self.layers as a chained stack, advancing prev_size after each nn.Linear, so with layer_sizes=[32, 32, 16] the layers are Linear(concat_dim, 32), Linear(32, 32), Linear(32, 16). Feeding inputs_x into the second layer gives it concat_dim features where it expects 32.
The class docstring example uses layer_sizes = [32, 32, 16], and the parameter doc says the length of that list determines the number of layers. The default is [100], a single layer, where the loop runs once and the behaviour is the same either way.
test_atomic_convolution_module constructs with [32, 32, 16] but asserts on acm.prev_layer.size() without calling forward. The tests that do call forward use layer_sizes=[10].
Reproducing the construction and the loop in isolation:
built: [(512, 32), (32, 32), (32, 16)]
current loop: RuntimeError: mat1 and mat2 shapes cannot be multiplied (4x512 and 32x32)
chained loop: ok, output (4, 16)Is the single-layer case the intended usage, with multi-layer layer_sizes unsupported, or should this be x = layer(x)? Happy to open a PR with the fix and a forward test covering multi-layer sizes if the second one is right.
Source: deepchem/deepchem