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

Update deprecated code snippets in ZH-CN translations #738

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90\nbGliIHZlcnNpb24zLjYuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/av/WaAAAACXBIWXMAAAsT\nAAALEwEAmpwYAAAN6klEQVR4nO3dfaxU9Z3H8c/Ha4sijQGMhlB20canjXGtEt2EZtHU1od/pBJI\nMTbqNqEJmlSzyS52/9Bk3WhcuutfPlAfYNdqUyNWggutAbN2MWm8GlaxbCurbotcQReM+BQVvvvH\nPWyueOc3l5kzcwa+71dyMzPne8853wz3wzkzvzPzc0QIwJHvqKYbANAfhB1IgrADSRB2IAnCDiRx\ndD93Zpu3/oEeiwiPt7yrI7vtS23/zvY228u62RaA3nKn4+y2hyT9XtK3JG2X9LykxRHx28I6HNmB\nHuvFkf18Sdsi4rWI+ETSzyRd0cX2APRQN2GfKemPYx5vr5Z9ju0ltodtD3exLwBd6uYNuvFOFb5w\nmh4RKyStkDiNB5rUzZF9u6RZYx5/VdKO7toB0CvdhP15SafaPtn2lyV9V9KaetoCULeOT+Mj4jPb\nN0j6paQhSQ9GxCu1dQagVh0PvXW0M16zAz3Xk4tqABw+CDuQBGEHkiDsQBKEHUiCsANJEHYgCcIO\nJEHYgSQIO5AEYQeSIOxAEoQdSIKwA0kQdiAJwg4kQdiBJAg7kARhB5Ig7EASh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2HA/B2s7jXc/HTTN+MA8d51Mf96tJsI+3tQ0gzT+NzcizpV0maTrq9NVTMw9kr6m0TkARyT9uMlmqmnGH5d0Y0S812QvY43TV1+etybCvl3SrDGPvyppRwN9jCsidlS3uyQ9odGXHYNk54EZdKvbXQ338/8iYmdE7IuI/ZJ+ogafu2qa8ccl/TQiVleLG3/uxuurX89bE2F/XtKptk+2/WVJ35W0poE+vsD2cdUbJ7J9nKRva/Cmol4j6Zrq/jWSnmywl88ZlGm8W00zroafu8anP4+Ivv9Iulyj78j/t6S/a6KHFn2dIuk/q59Xmu5N0qMaPa37VKNnRN+XNF3SBkmvVrfTBqi3f9Xo1N4vaTRYMxrq7RsafWn4kqTN1c/lTT93hb768rxxuSyQBFfQAUkQdiAJwg4kQdiBJAg7kARhB5Ig7EAS/wfgQlrpjsiFUAAAAABJRU5ErkJggg==",
"text/plain": [
"<Figure size 600x400 with 1 Axes>"
]
Expand Down Expand Up @@ -353,7 +353,7 @@
"BATCH_SPEC = collections.OrderedDict(\n",
" x=tf.TensorSpec(shape=[None, 784], dtype=tf.float32),\n",
" y=tf.TensorSpec(shape=[None], dtype=tf.int32))\n",
"BATCH_TYPE = tff.to_type(BATCH_SPEC)\n",
"BATCH_TYPE = tff.types.tensorflow_to_type(BATCH_SPEC)\n",
"\n",
"str(BATCH_TYPE)"
]
Expand Down Expand Up @@ -388,7 +388,7 @@
"MODEL_SPEC = collections.OrderedDict(\n",
" weights=tf.TensorSpec(shape=[784, 10], dtype=tf.float32),\n",
" bias=tf.TensorSpec(shape=[10], dtype=tf.float32))\n",
"MODEL_TYPE = tff.to_type(MODEL_SPEC)\n",
"MODEL_TYPE = tff.types.tensorflow_to_type(MODEL_SPEC)\n",
"print(MODEL_TYPE)"
]
},
Expand Down Expand Up @@ -527,7 +527,7 @@
},
"outputs": [],
"source": [
"@tff.tf_computation(MODEL_TYPE, BATCH_TYPE, tf.float32)\n",
"@tff.tensorflow.computation(MODEL_TYPE, BATCH_TYPE, np.float32)\n",
"def batch_train(initial_model, batch, learning_rate):\n",
" # Define a group of model variables and set them to `initial_model`. Must\n",
" # be defined outside the @tf.function.\n",
Expand Down Expand Up @@ -644,11 +644,11 @@
"source": [
"LOCAL_DATA_TYPE = tff.SequenceType(BATCH_TYPE)\n",
"\n",
"@tff.federated_computation(MODEL_TYPE, tf.float32, LOCAL_DATA_TYPE)\n",
"@tff.federated_computation(MODEL_TYPE, np.float32, LOCAL_DATA_TYPE)\n",
"def local_train(initial_model, learning_rate, all_batches):\n",
" \n",
"\n",
" # Reduction function to apply to each batch.\n",
" @tff.federated_computation((MODEL_TYPE, tf.float32), BATCH_TYPE)\n",
" @tff.federated_computation((MODEL_TYPE, np.float32), BATCH_TYPE)\n",
" def batch_fn(model_with_lr, batch):\n",
" model, lr = model_with_lr\n",
" return batch_train(model, batch, lr), lr\n",
Expand Down Expand Up @@ -745,7 +745,7 @@
"@tff.federated_computation(MODEL_TYPE, LOCAL_DATA_TYPE)\n",
"def local_eval(model, all_batches):\n",
"\n",
" @tff.tf_computation((MODEL_TYPE, tf.float32), BATCH_TYPE)\n",
" @tff.tensorflow.computation((MODEL_TYPE, np.float32), BATCH_TYPE)\n",
" def accumulate_evaluation(model_and_accumulator, batch):\n",
" model, accumulator = model_and_accumulator\n",
" return model, accumulator + batch_loss(model, batch)\n",
Expand Down Expand Up @@ -881,8 +881,8 @@
},
"outputs": [],
"source": [
"SERVER_MODEL_TYPE = tff.type_at_server(MODEL_TYPE)\n",
"CLIENT_DATA_TYPE = tff.type_at_clients(LOCAL_DATA_TYPE)"
"SERVER_MODEL_TYPE = tff.FederatedType(MODEL_TYPE, tff.SERVER)\n",
"CLIENT_DATA_TYPE = tff.FederatedType(LOCAL_DATA_TYPE, tff.CLIENTS)"
]
},
{
Expand Down Expand Up @@ -984,7 +984,7 @@
},
"outputs": [],
"source": [
"SERVER_FLOAT_TYPE = tff.type_at_server(tf.float32)\n",
"SERVER_FLOAT_TYPE = tff.FederatedType(np.float32, tff.SERVER)\n",
"\n",
"\n",
"@tff.federated_computation(SERVER_MODEL_TYPE, SERVER_FLOAT_TYPE,\n",
Expand Down