tensorflow / privacy

Library for training machine learning models with privacy for training data
Apache License 2.0
1.95k stars 452 forks source link

ABCMeta object is not subscriptable #595

Open Doris404 opened 3 months ago

Doris404 commented 3 months ago

I am using tensorflow_privacy package for dp training. The error messages are as follows:

Traceback (most recent call last):
  File "src/synthesize.py", line 9, in <module>
    from p3gm import P3GM
  File "/home/ruc/xiaotong/OpenDataGen/log/20240903/P3GM/src/p3gm.py", line 8, in <module>
    from tensorflow_privacy.privacy.analysis.rdp_accountant import compute_rdp, get_privacy_spent
  File "/home/ruc/xiaotong/OpenDataGen/log/20240903/P3GM/src/tensorflow_privacy/__init__.py", line 61, in <module>
    from tensorflow_privacy.privacy.keras_models.dp_keras_model import DPModel
  File "/home/ruc/xiaotong/OpenDataGen/log/20240903/P3GM/src/tensorflow_privacy/privacy/keras_models/dp_keras_model.py", line 20, in <module>
    from tensorflow_privacy.privacy.fast_gradient_clipping import clip_grads
  File "/home/ruc/xiaotong/OpenDataGen/log/20240903/P3GM/src/tensorflow_privacy/privacy/fast_gradient_clipping/clip_grads.py", line 29, in <module>
    from tensorflow_privacy.privacy.fast_gradient_clipping import common_manip_utils
  File "/home/ruc/xiaotong/OpenDataGen/log/20240903/P3GM/src/tensorflow_privacy/privacy/fast_gradient_clipping/common_manip_utils.py", line 19, in <module>
    from tensorflow_privacy.privacy.fast_gradient_clipping import type_aliases
  File "/home/ruc/xiaotong/OpenDataGen/log/20240903/P3GM/src/tensorflow_privacy/privacy/fast_gradient_clipping/type_aliases.py", line 24, in <module>
    PackedTensors = Union[Tensor, Iterable[Tensor], Mapping[str, Tensor]]
TypeError: 'ABCMeta' object is not subscriptable
Doris404 commented 3 months ago

I debug and find that privacy/fast_gradient_clipping/type_aliases.py line 24 trigger the bug. When we try to Iterable[Tensor] and Mapping[str, Tensor], it send error *** TypeError: 'ABCMeta' object is not subscriptable.