reid from https://github.com/michuanhaohao/reid-strong-baseline
zhangmeng
2020-01-11 bdf3ad71583fb4ef100d3819ecdae8fd9f70083e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once
 
#include <torch/csrc/WindowsTorchApiMacro.h>
#include <torch/types.h>
 
#include <cstddef>
#include <vector>
#include <mutex>
 
namespace torch {
namespace serialize {
class OutputArchive;
class InputArchive;
} // namespace serialize
} // namespace torch
 
namespace torch {
namespace data {
namespace samplers {
/// A `Sampler` is an object that yields an index with which to access a
/// dataset.
template <typename BatchRequest = std::vector<size_t>>
class Sampler {
 public:
  using BatchRequestType = BatchRequest;
 
  virtual ~Sampler() = default;
 
  /// Resets the `Sampler`'s internal state.
  /// Typically called before a new epoch.
  /// Optionally, accepts a new size when reseting the sampler.
  virtual void reset(optional<size_t> new_size) = 0;
 
  /// Returns the next index if possible, or an empty optional if the
  /// sampler is exhausted for this epoch.
  virtual optional<BatchRequest> next(size_t batch_size) = 0;
 
  /// Serializes the `Sampler` to the `archive`.
  virtual void save(serialize::OutputArchive& archive) const = 0;
 
  /// Deserializes the `Sampler` from the `archive`.
  virtual void load(serialize::InputArchive& archive) = 0;
};
 
} // namespace samplers
} // namespace data
} // namespace torch