google-deepmind / jax_privacy

Algorithms for Privacy-Preserving Machine Learning in JAX
Apache License 2.0
87 stars 11 forks source link

TypeError: 'type' object is not subscriptable #14

Closed Ryan0v0 closed 9 months ago

Ryan0v0 commented 1 year ago

Hi there! I am trying to run the Image Classification Experiments but got the following errors:

$ python run_experiment.py --config=configs/imagenet_nf_resnet_50_eps8.py --jaxline_mode=train_eval_multithreaded
Traceback (most recent call last):
  File "run_experiment.py", line 26, in <module>
    from jax_privacy.src.training.image_classification import experiment
  File "/nfs-share/wz341/jax_privacy/jax_privacy/__init__.py", line 18, in <module>
    from jax_privacy.src import accounting
  File "/nfs-share/wz341/jax_privacy/jax_privacy/src/accounting/__init__.py", line 18, in <module>
    from jax_privacy.src.accounting import accountant
  File "/nfs-share/wz341/jax_privacy/jax_privacy/src/accounting/accountant.py", line 20, in <module>
    from jax_privacy.src.accounting import calibrate
  File "/nfs-share/wz341/jax_privacy/jax_privacy/src/accounting/calibrate.py", line 26, in <module>
    from dp_accounting import dp_event
  File "/home/wz341/.local/lib/python3.8/site-packages/dp_accounting/__init__.py", line 17, in <module>
    from dp_accounting import pld
  File "/home/wz341/.local/lib/python3.8/site-packages/dp_accounting/pld/__init__.py", line 17, in <module>
    from dp_accounting.pld.pld_privacy_accountant import PLDAccountant
  File "/home/wz341/.local/lib/python3.8/site-packages/dp_accounting/pld/pld_privacy_accountant.py", line 19, in <module>
    from dp_accounting import dp_event
  File "/home/wz341/.local/lib/python3.8/site-packages/dp_accounting/dp_event.py", line 71, in <module>
    class DpEventNamedTuple(Protocol):
  File "/home/wz341/.local/lib/python3.8/site-packages/dp_accounting/dp_event.py", line 72, in DpEventNamedTuple
    _fields: tuple[str, ...]
TypeError: 'type' object is not subscriptable

I am unsure what is causing this issue and would appreciate any assistance in resolving it. Can you please advise on what steps I can take to fix this error and successfully run the experiments?

Thank you for your help!

lberrada commented 1 year ago

Hi, based on these logs, it seems that the error is raised within the dp_accounting library, when tuple is used as a type annotation, because this syntax is not supported on python 3.8. Using a newer version of python (>=3.9) should make the error disappear.