Skip to content

not working predictions with v2 #206

Description

@marian-code

Summary

predict method is not working with v2 version. I get error concernig cell array reshape

I am running version 0.2.1 installed with pip on linux

Steps to Reproduce

from dpdata import LabeledSystem
s = LabeledSystem(".", fmt="deepmd/raw")
s.predict()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-9f4569986ead> in <module>
----> 1 s.predict("../../../../../selective_train3/gen5/train5_5/ge_all_s5_5.pb")

~/Raid/conda_envs/dpmd_gpu_v2.0/lib/python3.9/site-packages/dpdata/system.py in predict(self, dp)
    986             else:
    987                 cell = None
--> 988             e, f, v = dp.eval(coord, cell, atype)
    989             data = ss.data
    990             data['energies'] = e.reshape((1, 1))

~/Raid/conda_envs/dpmd_gpu_v2.0/lib/python3.9/site-packages/deepmd/infer/deep_pot.py in eval(self, coords, cells, atom_types, atomic, fparam, aparam, efield)
    244         else :
    245             if self.auto_batch_size is not None:
--> 246                 e, f, v = self.auto_batch_size.execute_all(self._eval_inner, numb_test, natoms,
    247                               coords, cells, atom_types, fparam = fparam, aparam = aparam, atomic = atomic, efield = efield)
    248             else:

~/Raid/conda_envs/dpmd_gpu_v2.0/lib/python3.9/site-packages/deepmd/utils/batch_size.py in execute_all(self, callable, total_size, natoms, *args, **kwargs)
    114         results = []
    115         while index < total_size:
--> 116             n_batch, result = self.execute(execute_with_batch_size, index, natoms)
    117             if not isinstance(result, tuple):
    118                 result = (result,)

~/Raid/conda_envs/dpmd_gpu_v2.0/lib/python3.9/site-packages/deepmd/utils/batch_size.py in execute(self, callable, start_index, natoms)
     64         """
     65         try:
---> 66             n_batch, result = callable(max(self.current_batch_size // natoms, 1), start_index)
     67         except OutOfMemoryError as e:
     68             # TODO: it's very slow to catch OOM error; I don't know what TF is doing here

~/Raid/conda_envs/dpmd_gpu_v2.0/lib/python3.9/site-packages/deepmd/utils/batch_size.py in execute_with_batch_size(batch_size, start_index)
    106             end_index = start_index + batch_size
    107             end_index = min(end_index, total_size)
--> 108             return (end_index - start_index), callable(
    109                 *[(vv[start_index:end_index] if isinstance(vv, np.ndarray) and vv.ndim > 1 else vv) for vv in args],
    110                 **{kk: (vv[start_index:end_index] if isinstance(vv, np.ndarray) and vv.ndim > 1 else vv) for kk, vv in kwargs.items()},

~/Raid/conda_envs/dpmd_gpu_v2.0/lib/python3.9/site-packages/deepmd/infer/deep_pot.py in _eval_inner(self, coords, cells, atom_types, fparam, aparam, atomic, efield)
    276         else:
    277             pbc = True
--> 278             cells = np.array(cells).reshape([nframes, 9])
    279 
    280         if self.has_fparam :

ValueError: cannot reshape array of size 1 into shape (1,9)

The problem is here I think:

cell = ss['cells'].reshape((-1,1))

The v2 version seems to require cell vector transposed. If I swap the dimension everything works fine:

cell = ss['cells'].reshape((1,-1))

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions