forked from cshen/barnes-hut-sne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtsne.h
42 lines (31 loc) · 1.54 KB
/
tsne.h
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
/*
* tsne.h
* Header file for t-SNE.
*
* Created by Laurens van der Maaten.
* Copyright 2012, Delft University of Technology. All rights reserved.
*
*/
#ifndef TSNE_H
#define TSNE_H
static inline double sign(double x) { return (x == .0 ? .0 : (x < .0 ? -1.0 : 1.0)); }
class TSNE
{
public:
void run(double* X, int N, int D, double* Y, int no_dims, double perplexity, double theta);
bool load_data(double** data, int* n, int* d, double* theta, double* perplexity);
void save_data(double* data, int* landmarks, double* costs, int n, int d);
void symmetrizeMatrix(int** row_P, int** col_P, double** val_P, int N); // should be static?!
private:
void computeGradient(double* P, int* inp_row_P, int* inp_col_P, double* inp_val_P, double* Y, int N, int D, double* dC, double theta);
void computeExactGradient(double* P, double* Y, int N, int D, double* dC);
double evaluateError(double* P, double* Y, int N);
double evaluateError(int* row_P, int* col_P, double* val_P, double* Y, int N, double theta);
void zeroMean(double* X, int N, int D);
void computeGaussianPerplexity(double* X, int N, int D, double* P, double perplexity);
void computeGaussianPerplexity(double* X, int N, int D, int** _row_P, int** _col_P, double** _val_P, double perplexity, int K);
void computeGaussianPerplexity(double* X, int N, int D, int** _row_P, int** _col_P, double** _val_P, double perplexity, double threshold);
void computeSquaredEuclideanDistance(double* X, int N, int D, double* DD);
double randn();
};
#endif