Caffe2 - C++ API
A deep learning, cross platform ML framework
example.h
1 #pragma once
2 
3 #include <torch/types.h>
4 
5 namespace torch {
6 namespace data {
7 
11 template <typename Data = Tensor, typename Target = Tensor>
12 struct Example {
13  using DataType = Data;
14  using TargetType = Target;
15 
16  Example() = default;
17  Example(Data data, Target target)
18  : data(std::move(data)), target(std::move(target)) {}
19 
20  Data data;
21  Target target;
22 };
23 
24 namespace example {
25 using NoTarget = void;
26 } // namespace example
27 
32 template <typename Data>
33 struct Example<Data, example::NoTarget> {
34  using DataType = Data;
35  using TargetType = example::NoTarget;
36 
37  Example() = default;
38  /* implicit */ Example(Data data) : data(std::move(data)) {}
39 
40  // When a DataLoader returns an Example like this, that example should be
41  // implicitly convertible to the underlying data type.
42 
43  operator Data&() {
44  return data;
45  }
46  operator const Data&() const {
47  return data;
48  }
49 
50  Data data;
51 };
52 
54 } // namespace data
55 } // namespace torch
An Example from a dataset.
Definition: example.h:12
Definition: jit_type.h:17