torsional-diffusion icon indicating copy to clipboard operation
torsional-diffusion copied to clipboard

Cannot use batch normalization for layers without any scalar irrep (0e)

Open CaptainCuong opened this issue 3 years ago • 3 comments

https://github.com/gcorso/torsional-diffusion/blob/fcad6fb70da275ea7131be2aa5a3941e2c1129de/diffusion/score_model.py#L118

The variable new_means is an empty list e3nn code which leads to this error because it is necessary to have at least a scalar irrep for calculating new_means in the BatchNorm layer.

CaptainCuong avatar Sep 25 '22 03:09 CaptainCuong

Sorry, could you specify a bit more about the error and the environment you are running it with (e.g. e3nn version)?

gcorso avatar Sep 30 '22 18:09 gcorso

My environment: python = 3.10.1 torch_geometric = 2.1.0 e3nn = 0.5.0

I met this problem when reproduce the code with your default arguments. I just modified the path, change from DRUGS to QM9 dataset and the number of node features, from 74 to 44.

Traceback (most recent call last):
  File "C:\Users\ADMIN\Documents\GitHub\torsional-diffusion\train.py", line 115, in <module>
    train(args, model, optimizer, scheduler, train_loader, val_loader)
  File "C:\Users\ADMIN\Documents\GitHub\torsional-diffusion\train.py", line 27, in train
    train_loss, base_train_loss = train_epoch(model, train_loader, optimizer, device)
  File "C:\Users\ADMIN\Documents\GitHub\torsional-diffusion\utils\training.py", line 64, in train_epoch
    data = model(data)
  File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\ADMIN\Documents\GitHub\torsional-diffusion\diffusion\score_model.py", line 337, in forward
    out = self.bond_conv(node_attr, edge_index, edge_attr, edge_sh, out_nodes=data.edge_mask.sum(), reduce='mean')
  File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\ADMIN\Documents\GitHub\torsional-diffusion\diffusion\score_model.py", line 230, in forward
    out = self.batch_norm(out)
  File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python310\lib\site-packages\e3nn\nn\_batchnorm.py", line 178, in forward
    torch.cat(new_means, out=self.running_mean)
RuntimeError: torch.cat(): expected a non-empty list of Tensors

CaptainCuong avatar Oct 01 '22 15:10 CaptainCuong

Hi @CaptainCuong, sorry for the delay we did not manage to replicate the issue. Could you try to see if this fix solves the problem? https://github.com/gcorso/DiffDock/issues/14

gcorso avatar Oct 17 '22 21:10 gcorso

Closing for inactivity, feel free to reopen if the issue arises again

gcorso avatar Nov 16 '22 19:11 gcorso