Open jpgard opened 4 years ago
Same issue for me when running the script (or any other training) with tensorflow 2.4.1.
Same issue for me .,but I changed the layers of convolutional network like this:
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation='softmax')
])
Trained and Tested accuracy will be nearly 96%. But I don't know why code in ' mnist_dpsgd_tutorial_keras.py ' got low accuracy.
Same issue for me .,but I changed the layers of convolutional network like this:
model = tf.keras.models.Sequential([ tf.keras.layers.Flatten(input_shape=(28, 28)), tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(10, activation='softmax') ])
Trained and Tested accuracy will be nearly 96%. But I don't know why code in ' mnist_dpsgd_tutorial_keras.py ' got low accuracy.
the effect of this code like this:
Same issue for me .,but I changed the layers of convolutional network like this:
model = tf.keras.models.Sequential([ tf.keras.layers.Flatten(input_shape=(28, 28)), tf.keras.layers.Dense(128, activation='relu'), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(10, activation='softmax') ])
Trained and Tested accuracy will be nearly 96%. But I don't know why code in ' mnist_dpsgd_tutorial_keras.py ' got low accuracy.
the effect of this code like this:
Finally I changed the version of tensorflow and tensorflow_privacy, and used the convolutional network of mnist_dpsgd_tutorial_keras.py , got the learn/achieve accuracy.
tensorflow-gpu 2.2.0 -> 2.4.1, tensorflow_privacy 0.4.0 -> 0.5.1
Maybe you can check your version of tensorflow_privacy.
When running the
mnist_dpsgd_tutorial_keras.py
with all default parameters, the train/test accuracies do not improve over the course of training. The final accuracy is around 10%, which is of course equivalent to random guessing on MNIST.This seems related to issues about training in eager mode, e.g. #87 .
Also, I see that the main README currently suggests using TensorFlow 2.4, but I don't even see a public release of TensorFlow 2.4 yet at https://github.com/tensorflow/tensorflow/releases .
As a side note, the training steps are extremely fast when running the buggy version of the script vs. using the workaround below. This suggests to me that the gradients aren't being fully computed or applied.
Expected behavior: based on the results table in the tutorials README, I would expect accuracy of at least 95%.
Steps to reproduce: Install tensorflow and tensorflow privacy; specifically I am using
tensorflow==2.3.1
andtensorflow_privacy==0.5.1
. Then runpython3 mnist_dpsgd_tutorial_keras.py
.Workaround: Insert
tf.compat.v1.disable_eager_execution()
in the line immediately followingimport tensorflow as tf
. Of course, this means we lose all of the benefits of eager execution, but training works as expected.Sample of output from
mnist_dpsgd_tutorial_keras.py
: