question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ModuleNotFoundError: No module named 'tensorflow_privacy.privacy.membership_inference_attack'

See original GitHub issue

Following the README on the membership inference page yields an error.

I am running TensorFlow Privacy in a Google Colab notebook.

After adding the module with pip through !pip install tensorflow-privacy, I try running the lines specified in the README:

from tensorflow_privacy.privacy.membership_inference_attack import membership_inference_attack as mia

This yields the following error message:

---------------------------------------------------------------------------

ModuleNotFoundError                       Traceback (most recent call last)

<ipython-input-10-43809957f96c> in <module>()
      1 # tensorflow privacy mia imports
----> 2 from tensorflow_privacy.privacy.membership_inference_attack import membership_inference_attack as mia
      3 from tensorflow_privacy.privacy.membership_inference_attack.data_structures import AttackInputData
      4 from tensorflow_privacy.privacy.membership_inference_attack.data_structures import SlicingSpec
      5 from tensorflow_privacy.privacy.membership_inference_attack.data_structures import AttackType

ModuleNotFoundError: No module named 'tensorflow_privacy.privacy.membership_inference_attack'


---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------

TensorFlow Privacy seems to be successfully installed before:

Requirement already satisfied: tensorflow-privacy in /usr/local/lib/python3.6/dist-packages (0.2.2)

I would be happy to know how I can keep on using the module. Thank you in advance.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
fraboenicommented, Jan 17, 2021

Thank you very much, it works indeed.

1reaction
Mamunahmed33commented, Jul 7, 2021

Unfortunately it didn’t work for me

`#@test {“skip”: true} !pip install --quiet --upgrade tensorflow-federated-nightly !pip install --quiet --upgrade nest-asyncio

import nest_asyncio nest_asyncio.apply()`

ERROR: tensorflow-privacy 0.6.1 has requirement attrs>=21.2.0, but you’ll have attrs 19.3.0 which is incompatible. ERROR: datascience 0.10.6 has requirement folium==0.2.1, but you’ll have folium 0.8.3 which is incompatible.

!pip install tensorflow-privacy

Requirement already satisfied: tensorflow-privacy in /usr/local/lib/python3.7/dist-packages (0.6.1) Collecting attrs>=21.2.0 Using cached https://files.pythonhosted.org/packages/20/a9/ba6f1cd1a1517ff022b35acd6a7e4246371dfab08b8e42b829b6d07913cc/attrs-21.2.0-py2.py3-none-any.whl Requirement already satisfied: scipy>=0.17 in /usr/local/lib/python3.7/dist-packages (from tensorflow-privacy) (1.4.1) Requirement already satisfied: dm-tree~=0.1.1 in /usr/local/lib/python3.7/dist-packages (from tensorflow-privacy) (0.1.6) Requirement already satisfied: mpmath in /usr/local/lib/python3.7/dist-packages (from tensorflow-privacy) (1.2.1) Requirement already satisfied: tensorflow-estimator>=2.3.0 in /usr/local/lib/python3.7/dist-packages (from tensorflow-privacy) (2.5.0) Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.7/dist-packages (from scipy>=0.17->tensorflow-privacy) (1.19.5) Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.7/dist-packages (from dm-tree~=0.1.1->tensorflow-privacy) (1.15.0) ERROR: tensorflow-federated-nightly 0.19.0.dev20210703 has requirement attrs~=19.3.0, but you’ll have attrs 21.2.0 which is incompatible. ERROR: datascience 0.10.6 has requirement folium==0.2.1, but you’ll have folium 0.8.3 which is incompatible. Installing collected packages: attrs Found existing installation: attrs 19.3.0 Uninstalling attrs-19.3.0: Successfully uninstalled attrs-19.3.0 Successfully installed attrs-21.2.0 WARNING: The following packages were previously imported in this runtime: [attr] You must restart the runtime in order to use newly installed versions.

`import collections import attr import functools import numpy as np import tensorflow as tf import tensorflow_federated as tff

np.random.seed(0)`

__AttributeError Traceback (most recent call last) <ipython-input-7-a9c29c8e8c5e> in <module>() 4 import numpy as np 5 import tensorflow as tf ----> 6 import tensorflow_federated as tff 7 8 np.random.seed(0)

7 frames /usr/local/lib/python3.7/dist-packages/tensorflow_federated/python/aggregators/differential_privacy.py in DifferentiallyPrivateFactory() 203 query: tfp.DPQuery, 204 record_aggregation_factory: Optional[ –> 205 factory.UnweightedAggregationFactory] = None): 206 “”"Initializes DifferentiallyPrivateFactory. 207

AttributeError: module ‘tensorflow_privacy’ has no attribute ‘DPQuery’__

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing a New Privacy Testing Library in TensorFlow
Today, we're excited to announce a new experimental module in TensorFlow Privacy (GitHub) that allows developers to assess the privacy ...
Read more >
Membership Inference Attacks with TensorFlow Privacy
The aim of a membership inference attack is quite straight forward: Given a trained ML model and some data point, decide whether this...
Read more >
Google releases TensorFlow privacy testing module
Applying a test called 'membership inference attack,' TensorFlow Privacy can establish a score revealing how vulnerable a model is to leaked ...
Read more >
Membership Inference Attack against Differentially Private ...
While these models are considered to be immune to privacy attacks, with the advent of recent and sophis- ticated attack models, it is...
Read more >
Differential Privacy Protection Against Membership Inference ...
Studies have shown that not only the raw data but also the trained model can potentially infringe genome privacy. An example is the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found