oneflow.decode_onerec¶
-
oneflow.
decode_onerec
(input: Tensor, key: str, dtype, shape, is_dynamic=False, reshape=None, batch_padding=None) → Tensor¶ Decode a tensor from input which should be generated before by oneflow.nn.OneRecReader.
- Parameters
input – (Tensor): The tensor generated by oneflow.nn.OneRecReader before.
key (str) – The field name of the tensor to be decode
shape (bool) – The shape of the tensor to be decode
is_dynamic (bool) – The tensor shape is dynamic or not
reshape (tuple) – Set it if you want to reshape the tensor
batch_padding (tuple) – Set it if batch padding is needed
For example:
import oneflow as flow files = ['file01.onerec', 'file02.onerec'] # read onerec dataset form files reader = flow.nn.OneRecReader(files, 10, True, "batch") readdata = reader() # decode labels = flow.decode_onerec(readdata, key="labels", dtype=flow.int32, shape=(1,)) dense_fields = flow.decode_onerec(readdata, key="dense_fields", dtype=flow.float, shape=(13,))