【冠道汽车图片】广汽本田

class paddle.io. TensorDataset ( tensors: Sequence[Tensor] ) [source]
百度   农业农村部的主要职责是,统筹研究和组织实施“三农”工作战略、规划和政策,监督管理种植业、畜牧业、渔业、农垦、农业机械化、农产品质量安全,负责农业投资管理等。

Dataset defined by a list of tensors.

Each tensor should be in shape of [N, …], while N is the sample number, and each tensor contains a field of sample, TensorDataset retrieve each sample by indexing tensors in the 1st dimension.

Parameters

tensors (list|tuple) – A list/tuple of tensors with same shape in the 1st dimension.

Returns

a Dataset instance wrapping tensors.

Return type

Dataset

Examples

>>> import numpy as np
>>> import paddle
>>> from paddle.io import TensorDataset


>>> input_np = np.random.random([2, 3, 4]).astype('float32')
>>> input = paddle.to_tensor(input_np)
>>> label_np = np.random.random([2, 1]).astype('int32')
>>> label = paddle.to_tensor(label_np)

>>> dataset = TensorDataset([input, label])

>>> for i in range(len(dataset)):
...     input, label = dataset[i]
...     # do something