forked from huawei/mindspore2022
fix mindrecord api
This commit is contained in:
parent
4be2fb91d7
commit
8556f5adb3
|
|
@ -59,7 +59,7 @@ class FileWriter:
|
|||
... "data": b"\xaf\xafU<\xb8|6\xbd}\xc1\x99[\xeaj+\x8f\x84\xd3\xcc\xa0,i\xbb\xb9-\xcdz\xecp{T\xb1"}]
|
||||
>>> writer = FileWriter(file_name="test.mindrecord", shard_num=1)
|
||||
>>> writer.add_schema(schema_json, "test_schema")
|
||||
MSRStatus.SUCCESS
|
||||
0
|
||||
>>> writer.add_index(indexes)
|
||||
MSRStatus.SUCCESS
|
||||
>>> writer.write_raw_data(data)
|
||||
|
|
@ -100,7 +100,7 @@ class FileWriter:
|
|||
|
||||
@classmethod
|
||||
def open_for_append(cls, file_name):
|
||||
"""
|
||||
r"""
|
||||
Open MindRecord file and get ready to append data.
|
||||
|
||||
Args:
|
||||
|
|
@ -116,6 +116,17 @@ class FileWriter:
|
|||
MRMOpenForAppendError: If failed to open file for appending data.
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.mindrecord import FileWriter
|
||||
>>> schema_json = {"file_name": {"type": "string"}, "label": {"type": "int32"}, "data": {"type": "bytes"}}
|
||||
>>> data = [{"file_name": "1.jpg", "label": 0,
|
||||
... "data": b"\x10c\xb3w\xa8\xee$o&<q\x8c\x8e(\xa2\x90\x90\x96\xbc\xb1\x1e\xd4QER\x13?\xff"}]
|
||||
>>> writer = FileWriter(file_name="test.mindrecord", shard_num=1)
|
||||
>>> writer.add_schema(schema_json, "test_schema")
|
||||
0
|
||||
>>> writer.write_raw_data(data)
|
||||
MSRStatus.SUCCESS
|
||||
>>> writer.commit()
|
||||
MSRStatus.SUCCESS
|
||||
>>> write_append = FileWriter.open_for_append("test.mindrecord")
|
||||
>>> write_append.write_raw_data(data)
|
||||
MSRStatus.SUCCESS
|
||||
|
|
@ -317,7 +328,7 @@ class FileWriter:
|
|||
|
||||
Examples:
|
||||
>>> from mindspore.mindrecord import FileWriter
|
||||
>>> # define writer
|
||||
>>> writer = FileWriter(file_name="test.mindrecord", shard_num=1)
|
||||
>>> writer.set_header_size(1 << 25) # 32MB
|
||||
MSRStatus.SUCCESS
|
||||
"""
|
||||
|
|
@ -343,7 +354,7 @@ class FileWriter:
|
|||
|
||||
Examples:
|
||||
>>> from mindspore.mindrecord import FileWriter
|
||||
>>> # define writer
|
||||
>>> writer = FileWriter(file_name="test.mindrecord", shard_num=1)
|
||||
>>> writer.set_page_size(1 << 26) # 128MB
|
||||
MSRStatus.SUCCESS
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ class Cifar100ToMR:
|
|||
"""
|
||||
A class to transform from cifar100 to MindRecord.
|
||||
|
||||
Note:
|
||||
For details about Examples, please refer to `Converting the CIFAR-10 Dataset <https://
|
||||
www.mindspore.cn/docs/programming_guide/en/r1.5/dataset_conversion.html#converting-the-cifar-10-dataset>`_.
|
||||
|
||||
Args:
|
||||
source (str): the cifar100 directory to be transformed.
|
||||
destination (str): the MindRecord file path to transform into.
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ class Cifar10ToMR:
|
|||
"""
|
||||
A class to transform from cifar10 to MindRecord.
|
||||
|
||||
Note:
|
||||
For details about Examples, please refer to `Converting the CIFAR-10 Dataset <https://
|
||||
www.mindspore.cn/docs/programming_guide/en/r1.5/dataset_conversion.html#converting-the-cifar-10-dataset>`_.
|
||||
|
||||
Args:
|
||||
source (str): the cifar10 directory to be transformed.
|
||||
destination (str): the MindRecord file path to transform into.
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ class CsvToMR:
|
|||
"""
|
||||
A class to transform from csv to MindRecord.
|
||||
|
||||
Note:
|
||||
For details about Examples, please refer to `Converting CSV Dataset <https://
|
||||
www.mindspore.cn/docs/programming_guide/en/r1.5/dataset_conversion.html#converting-csv-dataset>`_.
|
||||
|
||||
Args:
|
||||
source (str): the file path of csv.
|
||||
destination (str): the MindRecord file path to transform into.
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ class ImageNetToMR:
|
|||
"""
|
||||
A class to transform from imagenet to MindRecord.
|
||||
|
||||
Note:
|
||||
For details about Examples, please refer to `Converting the ImageNet Dataset <https://
|
||||
www.mindspore.cn/docs/programming_guide/en/r1.5/dataset_conversion.html#converting-the-imagenet-dataset>`_.
|
||||
|
||||
Args:
|
||||
map_file (str): the map file that indicates label. The map file content should be like this:
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ class TFRecordToMR:
|
|||
"""
|
||||
A class to transform from TFRecord to MindRecord.
|
||||
|
||||
Note:
|
||||
For details about Examples, please refer to `Converting TFRecord Dataset <https://
|
||||
www.mindspore.cn/docs/programming_guide/en/r1.5/dataset_conversion.html#converting-tfrecord-dataset>`_.
|
||||
|
||||
Args:
|
||||
source (str): the TFRecord file to be transformed.
|
||||
destination (str): the MindRecord file path to transform into.
|
||||
|
|
|
|||
Loading…
Reference in New Issue