mirror of
https://github.com/ArthurDanjou/handson-ml3.git
synced 2026-01-14 12:14:36 +01:00
Replace HDF5 with TF format
This commit is contained in:
@@ -229,7 +229,7 @@
|
||||
"model_name = \"my_mnist_model\"\n",
|
||||
"model_version = \"0001\"\n",
|
||||
"model_path = Path(model_name) / model_version\n",
|
||||
"model.save(model_path)"
|
||||
"model.save(model_path, save_format=\"tf\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -706,7 +706,7 @@
|
||||
"source": [
|
||||
"model_version = \"0002\"\n",
|
||||
"model_path = Path(model_name) / model_version\n",
|
||||
"model.save(model_path)"
|
||||
"model.save(model_path, save_format=\"tf\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1830,7 +1830,7 @@
|
||||
"source": [
|
||||
"# extra code – shows that saving a model does not preserve its distribution\n",
|
||||
"# strategy\n",
|
||||
"model.save(\"my_mirrored_model\")\n",
|
||||
"model.save(\"my_mirrored_model\", save_format=\"tf\")\n",
|
||||
"model = tf.keras.models.load_model(\"my_mirrored_model\")\n",
|
||||
"type(model.weights[0])"
|
||||
]
|
||||
@@ -2151,10 +2151,10 @@
|
||||
"model.fit(X_train, y_train, validation_data=(X_valid, y_valid), epochs=10)\n",
|
||||
"\n",
|
||||
"if resolver.task_id == 0: # the chief saves the model to the right location\n",
|
||||
" model.save(\"my_mnist_multiworker_model\")\n",
|
||||
" model.save(\"my_mnist_multiworker_model\", save_format=\"tf\")\n",
|
||||
"else:\n",
|
||||
" tmpdir = tempfile.mkdtemp() # other workers save to a temporary directory\n",
|
||||
" model.save(tmpdir)\n",
|
||||
" model.save(tmpdir, save_format=\"tf\")\n",
|
||||
" tf.io.gfile.rmtree(tmpdir) # and we can delete this directory at the end!"
|
||||
]
|
||||
},
|
||||
@@ -2319,7 +2319,7 @@
|
||||
"\n",
|
||||
"model.fit(X_train, y_train, validation_data=(X_valid, y_valid), epochs=10,\n",
|
||||
" callbacks=callbacks)\n",
|
||||
"model.save(model_dir)"
|
||||
"model.save(model_dir, save_format=\"tf\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2471,7 +2471,7 @@
|
||||
"model = build_model(args)\n",
|
||||
"history = model.fit(X_train, y_train, validation_data=(X_valid, y_valid),\n",
|
||||
" epochs=10, callbacks=callbacks)\n",
|
||||
"model.save(model_dir) # extra code\n",
|
||||
"model.save(model_dir, save_format=\"tf\") # extra code\n",
|
||||
"\n",
|
||||
"import hypertune\n",
|
||||
"\n",
|
||||
@@ -2771,7 +2771,7 @@
|
||||
"if tuner_id == \"chief\":\n",
|
||||
" best_hp = hyperband_tuner.get_best_hyperparameters()[0]\n",
|
||||
" best_model = hyperband_tuner.hypermodel.build(best_hp)\n",
|
||||
" best_model.save(os.getenv(\"AIP_MODEL_DIR\"))"
|
||||
" best_model.save(os.getenv(\"AIP_MODEL_DIR\"), save_format=\"tf\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user