/usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/torch/csrc/api/include/torch/data/example.h (1308B)
#pragma once
#include
namespace torch {
namespace data {
/// An `Example` from a dataset.
///
/// A dataset consists of data and an associated target (label).
template
struct Example {
using DataType = Data;
using TargetType = Target;
Example() = default;
Example(Data data, Target target)
: data(std::move(data)), target(std::move(target)) {}
Data data;
Target target;
};
namespace example {
using NoTarget = void;
} // namespace example
/// A specialization for `Example` that does not have have a target.
///
/// This class exists so that code can be written for a templated `Example`
/// type, and work both for labeled and unlabeled datasets.
template
struct Example {
using DataType = Data;
using TargetType = example::NoTarget;
Example() = default;
/* implicit */ Example(Data data) : data(std::move(data)) {}
// When a DataLoader returns an Example like this, that example should be
// implicitly convertible to the underlying data type.
operator Data&() {
return data;
}
operator const Data&() const {
return data;
}
Data data;
};
using TensorExample = Example;
} // namespace data
} // namespace torch