qdtsne
A quick and dirty t-SNE C++ library
Loading...
Searching...
No Matches
initialize.hpp
Go to the documentation of this file.
1#ifndef QDTSNE_INITIALIZE_HPP
2#define QDTSNE_INITIALIZE_HPP
3
5
6#include <vector>
7#include <stdexcept>
8
9#include "Status.hpp"
10#include "Options.hpp"
11#include "gaussian.hpp"
12#include "symmetrize.hpp"
13
19namespace qdtsne {
20
24namespace internal {
25
26template<int num_dim_, typename Index_, typename Float_>
27Status<num_dim_, Index_, Float_> initialize(NeighborList<Index_, Float_> nn, Float_ perp, const Options& options) {
28 compute_gaussian_perplexity(nn, perp, options.num_threads);
29 symmetrize_matrix(nn);
30 return Status<num_dim_, Index_, Float_>(std::move(nn), options);
31}
32
33}
52template<int num_dim_, typename Index_, typename Float_>
55 if (options.infer_perplexity && neighbors.size()) {
56 perp = static_cast<Float_>(neighbors.front().size())/3;
57 } else {
58 perp = options.perplexity;
59 }
60 return internal::initialize<num_dim_>(std::move(neighbors), perp, options);
61}
62
77template<int num_dim_, typename Dim_, typename Index_, typename Float_>
79 const int K = perplexity_to_k(options.perplexity);
80 auto neighbors = find_nearest_neighbors(prebuilt, K, options.num_threads);
81 return internal::initialize<num_dim_>(std::move(neighbors), static_cast<Float_>(options.perplexity), options);
82}
83
101template<int num_dim_, typename Dim_, typename Index_, typename Float_>
112
113}
114
115#endif
Options for the t-SNE algorithm.
Status of the t-SNE iterations.
Status of the t-SNE iterations.
Definition Status.hpp:64
Quick and dirty t-SNE.
int perplexity_to_k(double perplexity)
Definition utils.hpp:44
Status< num_dim_, Index_, Float_ > initialize(NeighborList< Index_, Float_ > neighbors, const Options &options)
Definition initialize.hpp:53
Options for initialize().
Definition Options.hpp:14