reid from https://github.com/michuanhaohao/reid-strong-baseline
zhangmeng
2020-01-16 a47fccb11fa3470901aebcb27f861d242d0925e1
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
 
#include <torch/nn/cloneable.h>
#include <torch/nn/functional/distance.h>
#include <torch/nn/options/distance.h>
#include <torch/nn/pimpl.h>
#include <torch/types.h>
 
#include <torch/csrc/WindowsTorchApiMacro.h>
 
namespace torch {
namespace nn {
 
/// Returns the cosine similarity between :math:`x_1` and :math:`x_2`, computed
/// along `dim`.
class TORCH_API CosineSimilarityImpl : public Cloneable<CosineSimilarityImpl> {
 public:
  explicit CosineSimilarityImpl(const CosineSimilarityOptions& options_ = {});
 
  void reset() override;
 
  /// Pretty prints the `CosineSimilarity` module into the given `stream`.
  void pretty_print(std::ostream& stream) const override;
 
  Tensor forward(const Tensor& input1, const Tensor& input2);
 
  /// The options with which this `Module` was constructed.
  CosineSimilarityOptions options;
};
 
/// A `ModuleHolder` subclass for `CosineSimilarityImpl`.
/// See the documentation for `CosineSimilarityImpl` class to learn what methods
/// it provides, or the documentation for `ModuleHolder` to learn about
/// Pytorch's module storage semantics.
TORCH_MODULE(CosineSimilarity);
 
// ============================================================================
 
/// Returns the batchwise pairwise distance between vectors :math:`v_1`,
/// :math:`v_2` using the p-norm.
class TORCH_API PairwiseDistanceImpl : public Cloneable<PairwiseDistanceImpl> {
 public:
  explicit PairwiseDistanceImpl(const PairwiseDistanceOptions& options_ = {});
 
  void reset() override;
 
  /// Pretty prints the `PairwiseDistance` module into the given `stream`.
  void pretty_print(std::ostream& stream) const override;
 
  Tensor forward(const Tensor& input1, const Tensor& input2);
 
  /// The options with which this `Module` was constructed.
  PairwiseDistanceOptions options;
};
 
/// A `ModuleHolder` subclass for `PairwiseDistanceImpl`.
/// See the documentation for `PairwiseDistanceImpl` class to learn what methods
/// it provides, or the documentation for `ModuleHolder` to learn about
/// Pytorch's module storage semantics.
TORCH_MODULE(PairwiseDistance);
 
} // namespace nn
} // namespace torch