Table Of Contents
Table Of Contents

pack

mxnet.recordio.pack(header, s)[source]

Pack a string into MXImageRecord.

Parameters:
  • header (IRHeader) – Header of the image record. header.label can be a number or an array. See more detail in IRHeader.
  • s (str) – Raw image string to be packed.
Returns:

s – The packed string.

Return type:

str

Examples

>>> label = 4 # label can also be a 1-D array, for example: label = [1,2,3]
>>> id = 2574
>>> header = mx.recordio.IRHeader(0, label, id, 0)
>>> with open(path, 'r') as file:
...     s = file.read()
>>> packed_s = mx.recordio.pack(header, s)