change kernel initializer to fix dpsgd=False tutorial

PiperOrigin-RevId: 230931823
This commit is contained in:
Nicolas Papernot 2019-01-25 10:59:28 -08:00 committed by A. Unique TensorFlower
parent 4f9cc8ef3e
commit 668888c1a6

View file

@ -47,17 +47,13 @@ def cnn_model_fn(features, labels, mode):
input_layer = tf.reshape(features['x'], [-1, 28, 28, 1]) input_layer = tf.reshape(features['x'], [-1, 28, 28, 1])
y = tf.keras.layers.Conv2D(16, 8, y = tf.keras.layers.Conv2D(16, 8,
strides=2, strides=2,
padding='same', padding='same').apply(input_layer)
kernel_initializer='he_normal').apply(input_layer)
y = tf.keras.layers.MaxPool2D(2, 1).apply(y) y = tf.keras.layers.MaxPool2D(2, 1).apply(y)
y = tf.keras.layers.Conv2D(32, 4, y = tf.keras.layers.Conv2D(32, 4, strides=2, padding='valid').apply(y)
strides=2,
padding='valid',
kernel_initializer='he_normal').apply(y)
y = tf.keras.layers.MaxPool2D(2, 1).apply(y) y = tf.keras.layers.MaxPool2D(2, 1).apply(y)
y = tf.keras.layers.Flatten().apply(y) y = tf.keras.layers.Flatten().apply(y)
y = tf.keras.layers.Dense(32, kernel_initializer='he_normal').apply(y) y = tf.keras.layers.Dense(32).apply(y)
logits = tf.keras.layers.Dense(10, kernel_initializer='he_normal').apply(y) logits = tf.keras.layers.Dense(10).apply(y)
# Calculate loss as a vector (to support microbatches in DP-SGD). # Calculate loss as a vector (to support microbatches in DP-SGD).
vector_loss = tf.nn.sparse_softmax_cross_entropy_with_logits( vector_loss = tf.nn.sparse_softmax_cross_entropy_with_logits(