txie-93 / cdvae

An SE(3)-invariant autoencoder for generating the periodic structure of materials [ICLR 2022]
MIT License
230 stars 91 forks source link

Reconstruction evaluation error #30

Closed DeNeutoy closed 2 years ago

DeNeutoy commented 2 years ago

Hello @txie-93!

Thanks for the great code/repo. It is refreshing to have such high quality research code.

I have trained a model with property prediction, but running the evaluation for reconstruction throws this error:

(cdvae) markn@MacBook-Pro cdvae % PYTHONPATH=. python scripts/evaluate.py --model_path /Users/markn/code/cdvae/hydra/singlerun/2022-09-15/mini-property-pred --tasks gen opt recon --batch_size 10 --num_batches_to_samples 2
/Users/markn/anaconda3/envs/cdvae/lib/python3.8/site-packages/hydra/experimental/compose.py:16: UserWarning: hydra.experimental.compose() is no longer experimental. Use hydra.compose()
  warnings.warn(
 72%|██████████████████████████████████████████████████████▋                     | 285/396 [00:17<00:05, 20.42it/s]/Users/markn/anaconda3/envs/cdvae/lib/python3.8/site-packages/pymatgen/io/cif.py:1193: UserWarning: Issues encountered while parsing CIF: Some fractional co-ordinates rounded to ideal values to avoid issues with finite precision.
  warnings.warn(
100%|████████████████████████████████████████████████████████████████████████████| 396/396 [00:24<00:00, 16.12it/s]
/Users/markn/anaconda3/envs/cdvae/lib/python3.8/site-packages/torch_geometric/deprecation.py:13: UserWarning: 'data.DataLoader' is deprecated, use 'loader.DataLoader' instead
  warnings.warn(out)
Evaluate model on the reconstruction task.
batch 0 in 13
/Users/markn/code/cdvae/cdvae/common/data_utils.py:622: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  X = torch.tensor(X, dtype=torch.float)
100%|██████████████████████████████████████████████████████████████████████████████| 50/50 [10:50<00:00, 13.01s/it]
Batch(edge_index=[2, 1114], y=[32, 1], frac_coords=[298, 3], atom_types=[298], lengths=[32, 3], angles=[32, 3], to_jimages=[1114, 3], num_atoms=[32], num_bonds=[32], num_nodes=298, batch=[298], ptr=[33])
Traceback (most recent call last):
  File "scripts/evaluate.py", line 281, in <module>
    main(args)
  File "scripts/evaluate.py", line 195, in main
    all_frac_coords_stack, all_atom_types_stack, input_data_batch) = reconstructon(
  File "scripts/evaluate.py", line 70, in reconstructon
    input_data_list = input_data_list + batch.to_data_list()
  File "/Users/markn/anaconda3/envs/cdvae/lib/python3.8/site-packages/torch_geometric/data/batch.py", line 157, in to_data_list
    return [self.get(i) for i in range(self.num_graphs)]
  File "/Users/markn/anaconda3/envs/cdvae/lib/python3.8/site-packages/torch_geometric/data/batch.py", line 157, in <listcomp>
    return [self.get(i) for i in range(self.num_graphs)]
  File "/Users/markn/anaconda3/envs/cdvae/lib/python3.8/site-packages/torch_geometric/data/batch.py", line 90, in get
    data = separate(
  File "/Users/markn/anaconda3/envs/cdvae/lib/python3.8/site-packages/torch_geometric/data/separate.py", line 40, in separate
    data_store[attr] = _separate(attr, batch_store[attr], idx, slices,
  File "/Users/markn/anaconda3/envs/cdvae/lib/python3.8/site-packages/torch_geometric/data/separate.py", line 87, in _separate
    if decrement and (incs.dim() > 1 or int(incs[idx]) != 0):
AttributeError: 'NoneType' object has no attribute 'dim'

Perhaps this is related to the pytorch geometric version? The version that was installed is torch-geometric==2.0.1

Otherwise, do you have any pointers/suggestions?

thanks,

Mark

DeNeutoy commented 2 years ago

Solved this by upgrading to torch-geometric 2.0.4. Thanks!