'np.int' should changed to 'np.int16' in cogdl/utils/utils.py
Song-xx opened this issue · comments
🐛 Bug
To Reproduce
Steps to reproduce the behavior:
- install cogdl==0.6.0;
- from cogdl import pipeline and use 'generate-emb’ for pipeline;
- use 'cora' as dataset, and use 'line' or 'netsmf' as model name;
- bug is in the function alias_setup of cogdl/utils/utils.py.
data = build_dataset_from_name("cora").data
edge_index = ......
generator = pipeline("generate-emb", model=model.lower(), return_model=True,
num_features=-1, hidden_size=emb_dim, cpu=True,
cpu_inference=True, no_test=True)
emb = generator(edge_index, data.x.numpy())
Expected behavior
Environment
- CogDL version: 0.6.0
- OS (e.g., Linux): macos m1
- Python version: 3.9
- PyTorch version: 2.0.1
- CUDA/cuDNN version (if applicable): None
- Any other relevant information: numpy==1.23.5
Additional context
Traceback (most recent call last):
......
emb = generator(edge_index, data.x.numpy())
File "/Users/xxx/python3.9/site-packages/cogdl/pipelines.py", line 189, in __call__
embeddings = self.model(data)
File "/Users/xxx/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/Users/xxx/python3.9/site-packages/cogdl/models/emb/line.py", line 75, in forward
self.edges_table, self.edges_prob = alias_setup(self.edges_prob)
File "/Users/xxx/python3.9/site-packages/cogdl/utils/utils.py", line 109, in alias_setup
J = np.zeros(K, dtype=np.int)
File "/Users/xxx/python3.9/site-packages/numpy/__init__.py", line 305, in __getattr__
raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
A similar error occurs in construct_sparse in cogdl/utils/ppr_utils.py, it also has a dtype=np.int.