PySyft-TensorFlow icon indicating copy to clipboard operation
PySyft-TensorFlow copied to clipboard

Problem with tf.keras and PySyft

Open aditya-malte opened this issue 6 years ago • 14 comments

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.

aditya-malte avatar Jan 06 '20 14:01 aditya-malte

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

karlhigley avatar Jan 06 '20 15:01 karlhigley

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

aditya-malte avatar Jan 06 '20 15:01 aditya-malte

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

jvmncs avatar Jan 06 '20 18:01 jvmncs

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.

Madhura12gj avatar Jan 07 '20 07:01 Madhura12gj

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

jvmncs avatar Jan 07 '20 14:01 jvmncs

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

aditya-malte avatar Jan 07 '20 15:01 aditya-malte

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.

Sharma-Pranav avatar Jan 17 '20 11:01 Sharma-Pranav

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

nguyenduchuyvn avatar Mar 03 '20 07:03 nguyenduchuyvn

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.

KCC13 avatar Mar 24 '20 13:03 KCC13

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

Mesilenceki avatar May 01 '20 08:05 Mesilenceki

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.

harshitadd avatar May 20 '20 11:05 harshitadd

@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.

KCC13 avatar May 20 '20 13:05 KCC13

@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.

harshitadd avatar May 22 '20 10:05 harshitadd

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

apapadaki avatar Dec 15 '20 18:12 apapadaki