OpenMined / PySyft-TensorFlow

SOON TO BE DEPRECATED - The TensorFlow bindings for PySyft
Apache License 2.0
57 stars 11 forks source link

Problem with tf.keras and PySyft #43

Open aditya-malte opened 4 years ago

aditya-malte commented 4 years ago

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 commented 4 years ago

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

aditya-malte commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

aditya-malte commented 4 years ago

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 commented 4 years ago

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] 7) pip install syft-tensorflow pip install pysyft 8) pip install syft[tensorflow] pip install syft-tensorflow 9) 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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

harshitadd commented 4 years ago

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 -

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

KCC13 commented 4 years ago

@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 commented 4 years ago

@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 commented 3 years ago

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