From cebfbdd7231af8fc602b15f20bc55ef47c778ec7 Mon Sep 17 00:00:00 2001 From: changzherui Date: Tue, 15 Mar 2022 21:56:44 +0800 Subject: [PATCH] mod comment --- docs/api/api_python/mindspore/mindspore.export.rst | 2 +- .../train/mindspore.train.callback.LossMonitor.rst | 2 +- .../train/mindspore.train.callback.ModelCheckpoint.rst | 1 + mindspore/ccsrc/debug/rdr/base_recorder.h | 2 +- mindspore/python/mindspore/train/callback/_checkpoint.py | 2 ++ .../python/mindspore/train/callback/_lambda_callback.py | 2 +- mindspore/python/mindspore/train/model.py | 6 +++--- mindspore/python/mindspore/train/serialization.py | 4 ++-- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/api/api_python/mindspore/mindspore.export.rst b/docs/api/api_python/mindspore/mindspore.export.rst index 434139a375..0e3ae9c026 100644 --- a/docs/api/api_python/mindspore/mindspore.export.rst +++ b/docs/api/api_python/mindspore/mindspore.export.rst @@ -12,7 +12,7 @@ mindspore.export **参数:** - **net** (Cell) – MindSpore网络结构。 - - **inputs** (Tensor) – 网络的输入,如果网络有多个输入,需要将张量组成元组。 + - **inputs** (Union[Tensor, Dasaset) – 网络的输入,如果网络有多个输入,需要一同传入。当传入的类型为 `Dataset` 时,将会把数据预处理行为同步保存起来。需要手动调整batch的大小,当前仅支持获取 `Dataset` 的 `image` 列。 - **file_name** (str) – 导出模型的文件名称。 - **file_format** (str) – MindSpore目前支持导出"AIR","ONNX"和"MINDIR"格式的模型。 diff --git a/docs/api/api_python/train/mindspore.train.callback.LossMonitor.rst b/docs/api/api_python/train/mindspore.train.callback.LossMonitor.rst index e2c23f1f73..6c8f0c975a 100644 --- a/docs/api/api_python/train/mindspore.train.callback.LossMonitor.rst +++ b/docs/api/api_python/train/mindspore.train.callback.LossMonitor.rst @@ -10,7 +10,7 @@ **参数:** - **per_print_times** (int) - 表示每隔多少个step打印一次loss。默认值:1。 - - **has_trained_epoch** (int) - 表示已经训练了多少个epoch,如何设置了该参数,LossMonitor将监控该数值之后epoch的loss值。默认值:0。 + - **has_trained_epoch** (int) - 表示已经训练了多少个epoch,如果设置了该参数,LossMonitor将监控该数值之后epoch的loss值。默认值:0。 **异常:** diff --git a/docs/api/api_python/train/mindspore.train.callback.ModelCheckpoint.rst b/docs/api/api_python/train/mindspore.train.callback.ModelCheckpoint.rst index da74d57475..18b9e4ae00 100644 --- a/docs/api/api_python/train/mindspore.train.callback.ModelCheckpoint.rst +++ b/docs/api/api_python/train/mindspore.train.callback.ModelCheckpoint.rst @@ -6,6 +6,7 @@ .. note:: 在分布式训练场景下,请为每个训练进程指定不同的目录来保存checkpoint文件。否则,可能会训练失败。 + 如何在 `model` 方法中使用此回调函数,默认将会把优化器中的参数保存到checkpoint文件中。 **参数:** diff --git a/mindspore/ccsrc/debug/rdr/base_recorder.h b/mindspore/ccsrc/debug/rdr/base_recorder.h index d658dd0903..dd94befdf6 100644 --- a/mindspore/ccsrc/debug/rdr/base_recorder.h +++ b/mindspore/ccsrc/debug/rdr/base_recorder.h @@ -24,7 +24,7 @@ #include "debug/env_config_parser.h" #include "mindspore/core/utils/log_adapter.h" -const int maxNameLength = 32; +const int maxNameLength = 64; namespace mindspore { class BaseRecorder { public: diff --git a/mindspore/python/mindspore/train/callback/_checkpoint.py b/mindspore/python/mindspore/train/callback/_checkpoint.py index 8479bfc76b..76255f91de 100644 --- a/mindspore/python/mindspore/train/callback/_checkpoint.py +++ b/mindspore/python/mindspore/train/callback/_checkpoint.py @@ -344,6 +344,8 @@ class ModelCheckpoint(Callback): Note: In the distributed training scenario, please specify different directories for each training process to save the checkpoint file. Otherwise, the training may fail. + If this callback is used in the `model` function, the checkpoint file will saved + parameters of the optimizer by default. Args: prefix (str): The prefix name of checkpoint files. Default: "CKP". diff --git a/mindspore/python/mindspore/train/callback/_lambda_callback.py b/mindspore/python/mindspore/train/callback/_lambda_callback.py index 89a0c56bc3..8f6c68125f 100644 --- a/mindspore/python/mindspore/train/callback/_lambda_callback.py +++ b/mindspore/python/mindspore/train/callback/_lambda_callback.py @@ -36,7 +36,7 @@ class LambdaCallback(Callback): Examples: >>> import numpy as np >>> import mindspore.dataset as ds - >>> from mindspore.train.callback import History + >>> from mindspore.train.callback import LambdaCallback >>> from mindspore import Model, nn >>> data = {"x": np.float32(np.random.rand(64, 10)), "y": np.random.randint(0, 5, (64,))} >>> train_dataset = ds.NumpySlicesDataset(data=data).batch(32) diff --git a/mindspore/python/mindspore/train/model.py b/mindspore/python/mindspore/train/model.py index fbafa49a17..42e0660154 100644 --- a/mindspore/python/mindspore/train/model.py +++ b/mindspore/python/mindspore/train/model.py @@ -172,7 +172,7 @@ class Model: >>> model = Model(net, loss_fn=loss, optimizer=optim, metrics=None) >>> # For details about how to build the dataset, please refer to the function `create_dataset` in tutorial >>> # document on the official website: - >>> # https://www.mindspore.cn/tutorials/zh-CN/master/quick_start.html + >>> # https://www.mindspore.cn/tutorials/zh-CN/master/beginner/quick_start.html >>> dataset = create_custom_dataset() >>> model.train(2, dataset) """ @@ -953,8 +953,8 @@ class Model: if context.get_context("device_target") == "CPU" and dataset_sink_mode: dataset_sink_mode = False - logger.warning("CPU cannot support dataset sink mode currently." - "So the evaluating process will be performed with dataset non-sink mode.") + logger.info("CPU cannot support dataset sink mode currently." + "So the evaluating process will be performed with dataset non-sink mode.") with _CallbackManager(callbacks) as list_callback: if dataset_sink_mode: diff --git a/mindspore/python/mindspore/train/serialization.py b/mindspore/python/mindspore/train/serialization.py index a962b769c5..f9b56b2e2c 100644 --- a/mindspore/python/mindspore/train/serialization.py +++ b/mindspore/python/mindspore/train/serialization.py @@ -785,8 +785,8 @@ def export(net, *inputs, file_name, file_format='AIR', **kwargs): Args: net (Cell): MindSpore network. - inputs (Union[Tensor, tuple(Tensor), Dataset]): While the input type is Tensor, it represents the inputs - of the `net`, if the network has multiple inputs, incoming tuple(Tensor). While its type is Dataset, + inputs (Union[Tensor, Dataset]): While the input type is Tensor, it represents the inputs + of the `net`, if the network has multiple inputs, set them together. While its type is Dataset, it represents the preprocess behavior of the `net`, data preprocess operations will be serialized. In second situation, you should adjust batch size of dataset script manually which will impact on the batch size of 'net' input. Only supports parse "image" column from dataset currently.