Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'numpy.int64' object has no attribute 'unsqueeze' #78

Open
jonathan-booth opened this issue Mar 4, 2024 · 2 comments
Open

Comments

@jonathan-booth
Copy link

I'm trying to run a toy example of training using a toy dataset just to make sure I can get ase datasets working. I get this error when I try and run Nequip:
AttributeError: 'numpy.int64' object has no attribute 'unsqueeze'

The dataset I'm using is this (taken from the discussion #74):

3
Lattice="1.0 0.0 0.0 0.0 2.0 0.0 0.0 0.0 3.0" Properties=species:S:1:pos:R:3:forces:R:3 energy=-100 stress="0.0002 0.003 -0.004 0.003 -0.004 -0.005 -0.004 -0.005 -0.006" free_energy=-100 pbc="T T T"
H      14.80702000       9.47114000      14.83362000       0.05630700       0.18844700       0.12262800
C      14.40303000       9.58896000       4.81541000       0.28543000      -0.56192100       0.59003500
Al       0.15995000       9.61979000       9.87331000      -0.15746000       0.51516600       0.14365000
2
Lattice="1.0 0.0 0.0 0.0 2.0 0.0 0.0 0.0 3.0" Properties=species:S:1:pos:R:3:forces:R:3 energy=-100 stress="0.0002 0.003 -0.004 0.003 -0.004 -0.005 -0.004 -0.005 -0.006" free_energy=-100 pbc="T T T"
H      14.80702000       9.47114000      14.83362000       0.05630700       0.18844700       0.12262800
C      14.40303000       9.58896000       4.81541000       0.28543000      -0.56192100       0.59003500

Here is the data section of my .yaml:

dataset: ase
dataset_file_name: training.extxyz
ase_args:   
 format: extxyz

chemical_symbols:
  - H
  - C
  - Al

Here is the full error output:

Processing dataset...
Traceback (most recent call last):
  File "nequip/utils/auto_init.py", line 232, in instantiate
    instance = builder(**positional_args, **final_optional_args)
  File "nequip/data/dataset.py", line 880, in __init__
    super().__init__(
  File "nequip/data/dataset.py", line 166, in __init__
    super().__init__(root=root, type_mapper=type_mapper)
  File "nequip/data/dataset.py", line 50, in __init__
    super().__init__(root=root, transform=type_mapper)
  File "nequip/utils/torch_geometric/dataset.py", line 91, in __init__
    self._process()
  File "nequip/utils/torch_geometric/dataset.py", line 176, in _process
    self.process()
  File "nequip/data/dataset.py", line 218, in process
    data = self.get_data()
  File "nequip/data/dataset.py", line 971, in get_data
    datas = reader(rank=0)
  File "nequip/data/dataset.py", line 789, in _ase_dataset_reader
    AtomicData.from_ase(atoms=atoms, **atomicdata_kwargs)
  File "nequip/data/AtomicData.py", line 443, in from_ase
    return cls.from_points(
  File "nequip/data/AtomicData.py", line 330, in from_points
    return cls(edge_index=edge_index, pos=torch.as_tensor(pos), **kwargs)
  File "nequip/data/AtomicData.py", line 225, in __init__
    _process_dict(kwargs)
  File "nequip/data/AtomicData.py", line 155, in _process_dict
    kwargs[k] = v.unsqueeze(-1)
AttributeError: 'numpy.int64' object has no attribute 'unsqueeze'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "nequip-train", line 8, in <module>
    sys.exit(main())
  File "nequip/scripts/train.py", line 72, in main
    trainer = fresh_start(config)
  File "nequip/scripts/train.py", line 148, in fresh_start
    dataset = dataset_from_config(config, prefix="dataset")
  File "nequip/data/_build.py", line 78, in dataset_from_config
    instance, _ = instantiate(
  File "nequip/utils/auto_init.py", line 234, in instantiate
    raise RuntimeError(
RuntimeError: Failed to build object with prefix `dataset` using builder `ASEDataset`

I'm running it on a mac. Here are details of the environment:

# Name                    Version                   Build  Channel
appdirs                   1.4.4                    pypi_0    pypi
ase                       3.22.1                   pypi_0    pypi
ca-certificates           2023.12.12           hca03da5_0  
certifi                   2024.2.2                 pypi_0    pypi
cffi                      1.16.0           py39h80987f9_0  
charset-normalizer        3.3.2                    pypi_0    pypi
click                     8.1.7                    pypi_0    pypi
contourpy                 1.2.0                    pypi_0    pypi
cycler                    0.12.1                   pypi_0    pypi
docker-pycreds            0.4.0                    pypi_0    pypi
e3nn                      0.5.1                    pypi_0    pypi
fonttools                 4.49.0                   pypi_0    pypi
future                    0.18.3           py39hca03da5_0  
gitdb                     4.0.11                   pypi_0    pypi
gitpython                 3.1.42                   pypi_0    pypi
idna                      3.6                      pypi_0    pypi
importlib-resources       6.1.2                    pypi_0    pypi
kiwisolver                1.4.5                    pypi_0    pypi
libblas                   3.9.0           16_osxarm64_openblas    conda-forge
libcblas                  3.9.0           16_osxarm64_openblas    conda-forge
libcxx                    14.0.6               h848a8c0_0  
libffi                    3.4.4                hca03da5_0  
libgfortran               5.0.0           11_3_0_hca03da5_28  
libgfortran5              11.3.0              h009349e_28  
liblapack                 3.9.0           16_osxarm64_openblas    conda-forge
libopenblas               0.3.21               h269037a_0  
llvm-openmp               14.0.6               hc6e5704_0  
matplotlib                3.8.3                    pypi_0    pypi
mir-allegro               0.2.0                    pypi_0    pypi
mpmath                    1.3.0                    pypi_0    pypi
ncurses                   6.4                  h313beb8_0  
nequip                    0.5.6                    pypi_0    pypi
ninja                     1.10.2               hca03da5_5  
ninja-base                1.10.2               h525c30c_5  
npzviewer                 0.2.0                    pypi_0    pypi
numpy                     1.26.4                   pypi_0    pypi
openssl                   3.0.13               h1a28f6b_0  
opt-einsum                3.3.0                    pypi_0    pypi
opt-einsum-fx             0.1.4                    pypi_0    pypi
packaging                 23.2                     pypi_0    pypi
pillow                    10.2.0                   pypi_0    pypi
pip                       23.3.1           py39hca03da5_0  
protobuf                  4.25.3                   pypi_0    pypi
psutil                    5.9.8                    pypi_0    pypi
pycparser                 2.21               pyhd3eb1b0_0  
pyparsing                 3.1.1                    pypi_0    pypi
pyqt5                     5.15.10                  pypi_0    pypi
pyqt5-qt5                 5.15.12                  pypi_0    pypi
pyqt5-sip                 12.13.0                  pypi_0    pypi
python                    3.9.18               hb885b13_0  
python-dateutil           2.8.2                    pypi_0    pypi
pytorch                   1.10.2          cpu_py39h23cb94c_0  
pyyaml                    6.0.1                    pypi_0    pypi
readline                  8.2                  h1a28f6b_0  
requests                  2.31.0                   pypi_0    pypi
scipy                     1.12.0                   pypi_0    pypi
sentry-sdk                1.40.6                   pypi_0    pypi
setproctitle              1.3.3                    pypi_0    pypi
setuptools                68.2.2           py39hca03da5_0  
six                       1.16.0                   pypi_0    pypi
smmap                     5.0.1                    pypi_0    pypi
sqlite                    3.41.2               h80987f9_0  
sympy                     1.12                     pypi_0    pypi
tk                        8.6.12               hb8d0fd4_0  
torch-ema                 0.3                      pypi_0    pypi
torch-runstats            0.2.0                    pypi_0    pypi
tqdm                      4.66.2                   pypi_0    pypi
typing-extensions         4.9.0            py39hca03da5_1  
typing_extensions         4.9.0            py39hca03da5_1  
tzdata                    2024a                h04d1e81_0  
urllib3                   2.2.1                    pypi_0    pypi
wandb                     0.16.3                   pypi_0    pypi
wheel                     0.41.2           py39hca03da5_0  
xz                        5.4.5                h80987f9_0  
zipp                      3.17.0                   pypi_0    pypi
zlib                      1.2.13               h5a0b063_0  

Thanks

@DavidW99
Copy link

DavidW99 commented Mar 4, 2024

Hi Jonathan,

The example is only for showing the format. The values are not physical as you can see the position coordinate is larger than the lattice vectors. Please use your own xyz file.

@jonathan-booth
Copy link
Author

My mistake sorry; I wrongly assumed the error wasn't because of that, I thought I had the wrong version of some library or other. It works now thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants