Skip to content

tenzr::data::TensorDataset

Dataset backed by an in-memory list of tensors.

#include <dataset.h>

Inherits from tenzr::data::Dataset

Public Functions

Name
TensorDataset(std::vector< Tensor > tensors)
virtual size_t Size() const override
virtual DataItem Get(size_t index) const override
const std::vector< Tensor > & Tensors() const

Additional inherited members

Public Functions inherited from tenzr::data::Dataset

Name
virtual ~Dataset() =default

Public Functions Documentation

function TensorDataset

explicit TensorDataset(
    std::vector< Tensor > tensors
)

Parameters:

  • tensors Column tensors, all with equal dim(0).

Wrap a list of tensors whose first dimension is the shared sample count.

function Size

inline virtual size_t Size() const override

Return: Number of samples.

Reimplements: tenzr::data::Dataset::Size

function Get

virtual DataItem Get(
    size_t index
) const override

Parameters:

  • index Zero-based sample index.
  • index Row index into the dataset.

Return:

  • Sliced sample tensors.
  • The selected row as one tensor per column.

Reimplements: tenzr::data::Dataset::Get

Fetch the tensors at index. Copy the sample at index across all columns into a new DataItem.

function Tensors

inline const std::vector< Tensor > & Tensors() const

Return: Const reference to the wrapped tensors.