• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1mindspore.dataset.Dataset.save
2===============================
3
4.. py:method:: mindspore.dataset.Dataset.save(file_name, num_files=1, file_type='mindrecord')
5
6    将数据处理管道中正处理的数据保存为通用的数据集格式。数据集格式仅支持: ``'mindrecord'`` 。可以使用 :class:`mindspore.dataset.MindDataset` 类来读取保存的 ``'mindrecord'`` 文件。
7
8    将数据保存为 ``'mindrecord'`` 格式时存在隐式类型转换。转换表展示如何执行类型转换。
9
10    .. list-table:: 保存为 'mindrecord' 格式时的隐式类型转换
11       :widths: 25 25 50
12       :header-rows: 1
13
14       * - 'dataset'类型
15         - 'mindrecord'类型
16         - 说明
17       * - bool
18         - int32
19         - 变更为int32
20       * - int8
21         - int32
22         -
23       * - uint8
24         - int32
25         -
26       * - int16
27         - int32
28         -
29       * - uint16
30         - int32
31         -
32       * - int32
33         - int32
34         -
35       * - uint32
36         - int64
37         -
38       * - int64
39         - int64
40         -
41       * - uint64
42         - int64
43         - 有可能反转
44       * - float16
45         - float32
46         -
47       * - float32
48         - float32
49         -
50       * - float64
51         - float64
52         -
53       * - string
54         - string
55         - 不支持多维字符串
56       * - bytes
57         - bytes
58         - 不支持多维bytes
59
60    .. note::
61        1. 如需按顺序保存数据,将数据集的 `shuffle` 设置为 ``False`` ,将 `num_files` 设置为 ``1`` 。
62        2. 在执行保存操作之前,不要使用batch操作、repeat操作或具有随机属性的数据增强的map操作。
63        3. 当数据的维度可变时,只支持一维数组或者在第零维变化的多维数组。
64        4. 不支持多维string类型、多维bytes类型。
65
66    参数:
67        - **file_name** (str) - 数据集文件的路径。
68        - **num_files** (int, 可选) - 数据集文件的数量。默认值: ``1`` 。
69        - **file_type** (str, 可选) - 数据集格式。默认值: ``'mindrecord'`` 。
70