Browse Source

fix function description for SummaryCollector and SummaryRecord

tags/v1.2.0-rc1
jiangshuqiang 4 years ago
parent
commit
b21a98b062
3 changed files with 16 additions and 9 deletions
  1. +4
    -1
      mindspore/train/_utils.py
  2. +5
    -3
      mindspore/train/callback/_summary_collector.py
  3. +7
    -5
      mindspore/train/summary/summary_record.py

+ 4
- 1
mindspore/train/_utils.py View File

@@ -88,7 +88,10 @@ def _make_directory(path: str):
else: else:
logger.debug("The directory(%s) doesn't exist, will create it", path) logger.debug("The directory(%s) doesn't exist, will create it", path)
try: try:
os.makedirs(path, exist_ok=True, mode=0o700)
permissions = os.R_OK | os.W_OK | os.X_OK
os.umask(permissions << 3 | permissions)
mode = permissions << 6
os.makedirs(path, mode=mode, exist_ok=True)
real_path = path real_path = path
except PermissionError as e: except PermissionError as e:
logger.error("No write permission on the directory(%r), error = %r", path, e) logger.error("No write permission on the directory(%r), error = %r", path, e)


+ 5
- 3
mindspore/train/callback/_summary_collector.py View File

@@ -130,13 +130,15 @@ class SummaryCollector(Callback):
Default: None, which means no limit. For example, to write not larger than 4GB, Default: None, which means no limit. For example, to write not larger than 4GB,
specify `max_file_size=4 * 1024**3`. specify `max_file_size=4 * 1024**3`.
export_options (Union[None, dict]): Perform custom operations on the export data. export_options (Union[None, dict]): Perform custom operations on the export data.
Default: None, it means there is no export data.
Default: None, it means that the data is not exported.
Note that the size of export files is not limited by the max_file_size. Note that the size of export files is not limited by the max_file_size.
You can customize the export data with a dictionary. For example, you can set {'tensor_format': 'npy'} You can customize the export data with a dictionary. For example, you can set {'tensor_format': 'npy'}
to export tensor as npy file. The data that supports control is shown below. to export tensor as npy file. The data that supports control is shown below.


- tensor_format (Union[str, None]): Customize the export tensor format.
Default: None, it means there is no export tensor.
- tensor_format (Union[str, None]): Customize the export tensor format. Supports ["npy", None].
Default: None, it means that the tensor is not exported.

- npy: export tensor as npy file.


Raises: Raises:
ValueError: If the parameter value is not expected. ValueError: If the parameter value is not expected.


+ 7
- 5
mindspore/train/summary/summary_record.py View File

@@ -36,7 +36,7 @@ _summary_lock = threading.Lock()
# cache the summary data # cache the summary data
_summary_tensor_cache = {} _summary_tensor_cache = {}
_DEFAULT_EXPORT_OPTIONS = { _DEFAULT_EXPORT_OPTIONS = {
'tensor_format': {'npy'},
'tensor_format': {'npy', None},
} }




@@ -70,7 +70,7 @@ def process_export_options(export_options):


for export_option, export_format in export_options.items(): for export_option, export_format in export_options.items():
check_value_type('export_option', export_option, [str]) check_value_type('export_option', export_option, [str])
check_value_type('export_format', export_format, [str])
check_value_type('export_format', export_format, [str, type(None)])


unexpected_params = set(export_options) - set(_DEFAULT_EXPORT_OPTIONS) unexpected_params = set(export_options) - set(_DEFAULT_EXPORT_OPTIONS)
if unexpected_params: if unexpected_params:
@@ -115,13 +115,15 @@ class SummaryRecord:
raise_exception (bool, optional): Sets whether to throw an exception when a RuntimeError or OSError exception raise_exception (bool, optional): Sets whether to throw an exception when a RuntimeError or OSError exception
occurs in recording data. Default: False, this means that error logs are printed and no exception is thrown. occurs in recording data. Default: False, this means that error logs are printed and no exception is thrown.
export_options (Union[None, dict]): Perform custom operations on the export data. export_options (Union[None, dict]): Perform custom operations on the export data.
Default: None, it means there is no export data.
Default: None, it means that the data is not exported.
Note that the size of export files is not limited by the max_file_size. Note that the size of export files is not limited by the max_file_size.
You can customize the export data with a dictionary. For example, you can set {'tensor_format': 'npy'} You can customize the export data with a dictionary. For example, you can set {'tensor_format': 'npy'}
to export tensor as npy file. The data that supports control is shown below. to export tensor as npy file. The data that supports control is shown below.


- tensor_format (Union[str, None]): Customize the export tensor format.
Default: None, it means there is no export tensor.
- tensor_format (Union[str, None]): Customize the export tensor format. Supports ["npy", None].
Default: None, it means that the tensor is not exported.

- npy: export tensor as npy file.


Raises: Raises:
TypeError: If the parameter type is incorrect. TypeError: If the parameter type is incorrect.


Loading…
Cancel
Save