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

zh-CN:translate save_and_restore_models.ipynb #895

Merged
merged 5 commits into from Aug 7, 2019

Conversation

@ccw1996
Copy link
Contributor

commented Aug 1, 2019

translate blob/master/site/en/r2/tutorials/keras/save_and_restore_models.ipynb

@tfdocsbot

This comment has been minimized.

Copy link
Collaborator

commented Aug 1, 2019

Preview and run these notebook edits with Google Colab:

Notebook diffs available on ReviewNB.com.
@tfdocsbot

This comment has been minimized.

Copy link
Collaborator

commented Aug 1, 2019

Reviewers added, please take a look.
@kuri-leo, @JayYip, @yantaozhao, @loveunk, @Wind2esg, @tigerneil, @MofiiTech, @gaoljhy, @Mr-Linus, @flopsySong, @echosun1996

When your review is finished, approve the pull request or include "LGTM" in your comment.

" </td>\n",
"</table>"
]
},

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 1, 2019

Contributor

82-103行 请参考 https://docs.google.com/document/d/1v7kwEhvtbbI4S4gulxLJDDN78gv0ZlDJ0cN92BUPrm0 修改,注意将按钮和链接汉化并修改

This comment has been minimized.

Copy link
@ccw1996

ccw1996 Aug 2, 2019

Author Contributor

已经根据文档要求进行修改,上次开会有事没参加,对这块没能及时跟进,非常感谢你能指出

" <a target=\"_blank\" href=\"https://tensorflow.google.cn/beta/tutorials/keras/save_and_restore_models\"><img src=\"https://tensorflow.google.cn/images/tf_logo_32px.png\" />在 tensorflow.google.cn 上查看</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/r2/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/colab_logo_32px.png\" />在 Google Colab 运行</a>\n",

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 3, 2019

Contributor
Suggested change
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/r2/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/colab_logo_32px.png\" />在 Google Colab 运行</a>\n",
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/docs/blob/master/site/zh-cn/beta/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/colab_logo_32px.png\" />在 Google Colab 运行</a>\n",

This comment has been minimized.

Copy link
@ccw1996

ccw1996 Aug 5, 2019

Author Contributor

你提供的链接显示not found,所以,需要修改嘛?

" <a target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/r2/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/colab_logo_32px.png\" />在 Google Colab 运行</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://github.com/tensorflow/docs/blob/master/site/en/r2/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/GitHub-Mark-32px.png\" />在 Github 上查看源代码</a>\n",

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 3, 2019

Contributor
Suggested change
" <a target=\"_blank\" href=\"https://github.com/tensorflow/docs/blob/master/site/en/r2/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/GitHub-Mark-32px.png\" />在 Github 上查看源代码</a>\n",
" <a target=\"_blank\" href=\"https://github.com/tensorflow/docs/blob/master/site/zh-cn/beta/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/GitHub-Mark-32px.png\" />在 Github 上查看源代码</a>\n",

This comment has been minimized.

Copy link
@ccw1996

ccw1996 Aug 5, 2019

Author Contributor

你提供的链接显示not found,所以,需要修改嘛?

" <a target=\"_blank\" href=\"https://github.com/tensorflow/docs/blob/master/site/en/r2/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/GitHub-Mark-32px.png\" />在 Github 上查看源代码</a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://storage.googleapis.com/tensorflow_docs/docs/site/en/r2/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/download_logo_32px.png\" />下载此 notebook</a>\n",

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 3, 2019

Contributor
Suggested change
" <a href=\"https://storage.googleapis.com/tensorflow_docs/docs/site/en/r2/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/download_logo_32px.png\" />下载此 notebook</a>\n",
" <a href=\"https://storage.googleapis.com/tensorflow_docs/docs/site/zh-cn/beta/tutorials/keras/save_and_restore_models.ipynb\"><img src=\"https://tensorflow.google.cn/images/download_logo_32px.png\" />下载此 notebook</a>\n",

This comment has been minimized.

Copy link
@ccw1996

ccw1996 Aug 5, 2019

Author Contributor

你提供的链接显示not exist,所以,需要修改嘛?

"id": "soDE0W_KH8rG"
},
"source": [
"## 在训练期间保存模型(以checkpoints形式保存)"

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 3, 2019

Contributor
Suggested change
"## 在训练期间保存模型(以checkpoints形式保存"
"## 在训练期间保存模型(以 checkpoints 形式保存"
"checkpoint_path = \"training_2/cp-{epoch:04d}.ckpt\"\n",
"checkpoint_dir = os.path.dirname(checkpoint_path)\n",
"\n",
"# 创建一个回调,每5个 epochs 保存模型的权重\n",

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 3, 2019

Contributor
Suggested change
"# 创建一个回调,每5个 epochs 保存模型的权重\n",
"# 创建一个回调,每 5 个 epochs 保存模型的权重\n",
"source": [
"## 手动保存权重\n",
"\n",
"您将了解如何将权重加载到模型中。使用 `Model.save_weights` 方法手动保存它们同样简单。默认情况下, `tf.keras` ——和 `save_weights` 特别使用 TensorFlow [checkpoints](../../guide/keras/checkpoints) 格式 `.ckpt` 扩展名和 ( 保存在 [HDF5](https://js.tensorflow.org/tutorials/import-keras.html) 扩展名为 `.h5` [保存并序列化模型](../../guide/keras/saving_and_serializing#weights-only_saving_in_savedmodel_format) ):"

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 3, 2019

Contributor
Suggested change
"您将了解如何将权重加载到模型中。使用 `Model.save_weights` 方法手动保存它们同样简单。默认情况下, `tf.keras` ——和 `save_weights` 特别使用 TensorFlow [checkpoints](../../guide/keras/checkpoints) 格式 `.ckpt` 扩展名和 ( 保存在 [HDF5](https://js.tensorflow.org/tutorials/import-keras.html) 扩展名为 `.h5` [保存并序列化模型](../../guide/keras/saving_and_serializing#weights-only_saving_in_savedmodel_format) ):"
"您将了解如何将权重加载到模型中。使用 `Model.save_weights` 方法手动保存它们同样简单。默认情况下, `tf.keras` 和 `save_weights` 特别使用 TensorFlow [checkpoints](../../guide/keras/checkpoints) 格式 `.ckpt` 扩展名和 ( 保存在 [HDF5](https://js.tensorflow.org/tutorials/import-keras.html) 扩展名为 `.h5` [保存并序列化模型](../../guide/keras/saving_and_serializing#weights-only_saving_in_savedmodel_format) ):"
"\n",
"模型和优化器可以保存到包含其状态(权重和变量)和模型配置的文件中。这允许您导出模型,以便可以在不访问原始python代码的情况下使用它。由于恢复了优化器状态,您可以从中断的位置恢复训练。\n",
"\n",
"保存完整模型非常有用——您可以在 TensorFlow.js ([HDF5](https://js.tensorflow.org/tutorials/import-keras.html), [Saved Model](https://js.tensorflow.org/tutorials/import-saved-model.html)) 加载他们,然后在 web 浏览器中训练和运行它们,或者使用 TensorFlow Lite 将它们转换为在移动设备上运行([HDF5](https://tensorflow.google.cn/lite/convert/python_api#exporting_a_tfkeras_file_), [Saved Model](https://tensorflow.google.cn/lite/convert/python_api#exporting_a_savedmodel_))"

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 3, 2019

Contributor

语句不通顺,请重新翻译

This comment has been minimized.

Copy link
@ccw1996

ccw1996 Aug 5, 2019

Author Contributor

这句话我还是有点拿捏不准,麻烦你再看一下。

"* 模型配置(结构)\n",
"* 优化器配置\n",
"\n",
"Keras 通过检查网络结构来保存模型。目前,它无法保存Tensorflow优化器(调用自 `tf.train`)。使用这些的时候,您需要在加载后重新编译模型,否则您将失去优化器的状态。\n"

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 3, 2019

Contributor
Suggested change
"Keras 通过检查网络结构来保存模型。目前,它无法保存Tensorflow优化器(调用自 `tf.train`)。使用这些的时候,您需要在加载后重新编译模型,否则您将失去优化器的状态。\n"
"Keras 通过检查网络结构来保存模型。目前,它无法保存 Tensorflow 优化器(调用自 `tf.train`)。使用这些的时候,您需要在加载后重新编译模型,否则您将失去优化器的状态。\n"
"id": "B7qfpvpY9HCe"
},
"source": [
"从保存的模型重新加载新的Keras模型:"

This comment has been minimized.

Copy link
@Mr-Linus

Mr-Linus Aug 3, 2019

Contributor
Suggested change
"从保存的模型重新加载新的Keras模型"
"从保存的模型重新加载新的 Keras 模型"

This comment has been minimized.

Copy link
@ccw1996

ccw1996 Aug 5, 2019

Author Contributor

除了上面单独提到的问题,其他都已经解决。非常感谢你能够仔细地校对。

@Mr-Linus

This comment has been minimized.

Copy link
Contributor

commented Aug 5, 2019

@ccw1996 404是因为这个PR还没有合并,当PR被合并后才会显示
The page displays 404 because the PR has not been merged yet.

@ccw1996

This comment has been minimized.

Copy link
Contributor Author

commented Aug 5, 2019

@ccw1996 404是因为这个PR还没有合并,当PR被合并后才会显示
The page displays 404 because the PR has not been merged yet.

谢谢,均修改完成

@Mr-Linus
Copy link
Contributor

left a comment

LGTM
Thank you for your contribution !
辛苦啦~ 😆

@lamberta
Copy link
Member

left a comment

Great—thank you both!

@TensorFlow-Docs-Copybara TensorFlow-Docs-Copybara merged commit 72a98da into tensorflow:master Aug 7, 2019

2 checks passed

cla/google All necessary CLAs are signed
import/copybara Change imported to the internal review system
Details

TensorFlow-Docs-Copybara pushed a commit that referenced this pull request Aug 7, 2019

Copybara-Service
Merge pull request #895 from ccw1996:master
PiperOrigin-RevId: 262029892
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.