Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with tf.keras and PySyft #43

Open
aditya-malte opened this issue Jan 6, 2020 · 14 comments
Open

Problem with tf.keras and PySyft #43

aditya-malte opened this issue Jan 6, 2020 · 14 comments

Comments

@aditya-malte
Copy link

aditya-malte commented Jan 6, 2020

Environment: TF 2.0, Python 3, Colab
Hi,
I am facing the following problem while installing pysyft-tensorflow:

When I try to import syft after installation(of pysyft-tensorflow), it returns a "no module found" error.
Please suggest a solution.
Thanks in advance.

@karlhigley
Copy link

pysyft-tensorflow doesn't automatically install pysyft, which needs to be installed manually.

@aditya-malte
Copy link
Author

aditya-malte commented Jan 6, 2020

Hi,
Thanks for the quick response.
I had tried pip install pysyft too( with and without the udacity flag) but then there were two problems:

  1. I lose tf2.0 and am instead am given an older 1.x version of tf.
  2. While compiling a model using tf.keras it gives an error that did not occur before:
    “Operation object has no attribute : native_create_with_tf_output”
    Thank you

@jvmncs
Copy link
Contributor

jvmncs commented Jan 6, 2020

pip install syft[tensorflow] instead of pip install syft[udacity] is intended to fix (1)

it would be helpful if you were to supply steps to reproduce the issue, ideally some code for reference

@Madhura12gj
Copy link

pip install syft[tensorflow] instead of pip install syft[udacity] is intended to fix (1)

it would be helpful if you were to supply steps to reproduce the issue, ideally some code for reference

from pandas import read_csv
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from sklearn.metrics import confusion_matrix
from tensorflow.keras import Sequential
from tensorflow.keras.layers import Dense
import numpy as np
import pandas as pd
import syft as sy
import tensorflow as tf

hook = sy.TensorFlowHook(tf)
bob = sy.VirtualWorker(hook, id="bob")
alice = sy.VirtualWorker(hook, id="alice")

#downloading the dataset
url='https://raw.githubusercontent.com/Madhura12gj/Hands-on-Pytorch/master/diabetes.csv'
df=pd.read_csv(url)
x = df.iloc[:, :-1].values
y = df.iloc[:, -1].values

#splitting it into testing and training set
x_train, x_test,y_train, y_test= train_test_split(x,y,test_size=0.2,random_state=1)
print(x_train.shape, x_test.shape, y_train.shape, y_test.shape)

x_train, y_train = tf.convert_to_tensor(x_train), tf.convert_to_tensor(y_train)
x_test, y_test = tf.convert_to_tensor(x_test), tf.convert_to_tensor(y_test)

n_features = x_train.shape[1]
print(n_features)

bob_dataset=(x_train[:300].send(bob),y_train[:300].send(bob))
alice_dataset =(x_train[300:].send(alice),y_train[300:].send(alice))

#defining the model
model = tf.keras.models.Sequential([tf.keras.layers.Flatten(input_shape=(n_features,)),
tf.keras.layers.Dense(16, activation='relu'),
tf.keras.layers.Dense(8, activation='relu'),
tf.keras.layers.Dense(1, activation='sigmoid')])

And right after this code we face the error.

@jvmncs
Copy link
Contributor

jvmncs commented Jan 7, 2020

sorry, I meant the installation code (since this seems to be an installation error)

@aditya-malte
Copy link
Author

aditya-malte commented Jan 7, 2020

Hi,
So we had tried the following (and some combinations as well):

  1. pip install syft[tensorflow]

2.pip install syft-tensorflow
pip install syft

3.pip install syft-tensorflow
pip install syft[udacity]

And some combinations. None of them seemed to work. and raised an error when the model was declared(something like:
"Operation" has no attribute native_create_tf_output...)
Surprisingly, if we kept the sy.VirtualWorked(id=..,hook) after model declaration the model compiled successfully, so I suppose there is an issue with the TF hooks.
Thanks

@Sharma-Pranav
Copy link

Hello,

I am also trying to install this software on a windows computer. I have tried installing in mostly following ways as far as I remember:

  1. pip install syft-tensorflow
    pip install syft[udacity]
  2. pip install syft-tensorflow
    pip install syft[tensorflow]
  3. Installed everything in requirements files individually using Conda, then installed via pip install syft[tensorflow]
  4. Installed everything in requirements files individually using Conda, then installed via pip install pysyft
  5. pip install syft-tensorflow
    pip install syft[udacity]
  6. pip install syft-tensorflow
    pip install pysyft
  7. pip install syft[tensorflow]
    pip install syft-tensorflow
  8. Also I tried both installation of pytorch 1.3.0 via both anaconda and pip - to check whether errors happen due to this also.

In my case mostly, I got "no module found" error or "ImportError: DLL load failed".

Any suggesions for installation would be a great help.

@nguyenduchuyvn
Copy link

nguyenduchuyvn commented Mar 3, 2020

Hello,
I got the same issue when installing syft- tensorflow in Colab (TF2.0, Python Version 3.6).
I use :
pip install syft-tensorflow
or
pip install syft[tensorflow]

but in two cases, I always got "no module found" error when import syft.
Any suggestions for this issue? Thanks you in advance

@KCC13
Copy link

KCC13 commented Mar 24, 2020

Hi, I've encountered a similar issue on syft[tensorflow] 0.2.4. The following error message came out when I tried to import syft as sy.

syft.exceptions.UndefinedProtocolTypeError: tensorflow.python.framework.ops.EagerTensor is not defined in the protocol file

My environment setting:

  1. mac osx 10.14.6
  2. conda 4.8.2
  3. python 3.6.10
  4. syft[tensorflow] 0.2.4

Currently the latest version that I can successfully import syft is 0.2.0a2.

@Mesilenceki
Copy link

I do have the same problem now on google colab. Anyone fix it?

@harshitadd
Copy link

Hi, I've encountered a similar issue on syft[tensorflow] 0.2.4. The following error message came out when I tried to import syft as sy.

syft.exceptions.UndefinedProtocolTypeError: tensorflow.python.framework.ops.EagerTensor is not defined in the protocol file

My environment setting:

  1. mac osx 10.14.6
  2. conda 4.8.2
  3. python 3.6.10
  4. syft[tensorflow] 0.2.4

Currently the latest version that I can successfully import syft is 0.2.0a2.

Producing the same exception on google colab (with TensorFlow version - 2.2.0):
Tried -

  • pip install syft[tensorflow]
    import syft as sy

  • pip install syft-tensorflow
    import syft as sy

and the same exception is thrown in both cases. Any suggestions to work around this would be of much help.
Thanks in advance.

@KCC13
Copy link

KCC13 commented May 20, 2020

@harshitadd @Mesilenceki
You have to install PySyft manually after pip install syft-tensorflow since PySyft-TensorFlow doesn't include it.

Due to this repository has not been maintained for a long time, it's inconsistent with the latest version of PySyft, so you have to install an older version of PySyft.

In my case, pip install syft==0.2.0a2 solves the import problem, or you can follow the instructions of README.md to build the code from another branch of pysyft (which I haven't tried).

Note that openmined has warned us that this repository will soon be deprecated in favor of PySyft, so it's probably not a good idea to build any decent work on PySyft-TensorFlow.

@harshitadd
Copy link

@harshitadd @Mesilenceki
You have to install PySyft manually after pip install syft-tensorflow since PySyft-TensorFlow doesn't include it.

Due to this repository has not been maintained for a long time, it's inconsistent with the latest version of PySyft, so you have to install an older version of PySyft.

In my case, pip install syft==0.2.0a2 solves the import problem, or you can follow the instructions of README.md to build the code from another branch of pysyft (which I haven't tried).

Note that openmined has warned us that this repository will soon be deprecated in favor of PySyft, so it's probably not a good idea to build any decent work on PySyft-TensorFlow.

Thank you for your prompt reply @skywind29. Will bear the suggestions in mind.

@apapadaki
Copy link

pip install syft==0.2.9 worked for me for the same issue (python 3.6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants