wengong-jin / hgraph2graph

Hierarchical Generation of Molecular Graphs using Structural Motifs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Size of tensors do not match

MehdiABM opened this issue · comments

Hello Wengong !

Thanks for the great work !
I am currently trying to train the VAE on ChemBL, however, after about 300 gradient descent steps, I encounter the following error :

Traceback (most recent call last):
  File "vae_train.py", line 108, in <module>
    loss, kl_div, wacc, iacc, tacc, sacc = model(*batch, beta=beta)
  File "/opt/conda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home//PycharmProjects/hgraph2graph/generation/poly_hgraph/hgnn.py", line 79, in forward
    loss, wacc, iacc, tacc, sacc = self.decoder((root_vecs, root_vecs, root_vecs), graphs, tensors, orders)
  File "/opt/conda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/home//PycharmProjects/hgraph2graph/generation/poly_hgraph/decoder.py", line 251, in forward
    cand_vecs = self.enum_attach(hgraph, cands, icls, nth_child)
  File "/home//PycharmProjects/hgraph2graph/generation/poly_hgraph/decoder.py", line 293, in enum_attach
    cand_vecs = torch.cat([cand_vecs, icls_vecs, order_vecs], dim=-1)
RuntimeError: Sizes of tensors must match except in dimension 0. Got 146 and 292

Would you have any pointers to a possible source ?
The error is not easy to reproduce as it seems to occur at random stages of the training.

Thanks !

Hi,

Sorry for my late reply. It's hard for me to identify the source of problem given limited information. One solution is to add a try/except wrapper in vae_train.py (say line 78-84) and skip those errors (if they happen only occasionally).

Wengong