77 [[nodiscard]]
double at(int64_t row, int64_t col)
const;
90 std::size_t max_gram_bytes = std::size_t{2} << 30);
113 [[nodiscard]]
double at(int64_t i, int64_t j)
const;
172 int64_t permutations = 999, uint64_t seed = 0);
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Definition acquisition_functions.hpp:16
double LinearCka(const Tensor &x, const Tensor &y, CkaEstimator estimator=CkaEstimator::Debiased)
Linear CKA between two representations of the same inputs.
SvccaResult Svcca(const Tensor &x, const Tensor &y, const SvccaOptions &options={})
SVCCA: CanonicalCorrelations() between each representation's top singular directions.
RsaTestResult RsaPermutationTest(const Rdm &a, const Rdm &b, RdmComparison comparison=RdmComparison::Spearman, int64_t permutations=999, uint64_t seed=0)
Whether two RDMs agree more than chance: the Mantel test RSA uses.
double CompareRdms(const Rdm &a, const Rdm &b, RdmComparison comparison=RdmComparison::Spearman)
The correlation between two RDMs of the same inputs, in the same order.
Rdm RepresentationalDissimilarity(const Tensor &x, RdmMetric metric=RdmMetric::Correlation)
The RDM of a representation, shape (n, ...): a row per input, later dimensions flattened.
double Rsa(const Tensor &x, const Tensor &y, RdmMetric metric=RdmMetric::Correlation, RdmComparison comparison=RdmComparison::Spearman)
RSA between two representations of the same inputs: CompareRdms(RepresentationalDissimilarity(x),...
CkaMatrix LinearCkaMatrix(const std::vector< Tensor > &a, const std::vector< Tensor > &b, CkaEstimator estimator=CkaEstimator::Debiased, std::size_t max_gram_bytes=std::size_t{2}<< 30)
LinearCka() between every representation in a and every one in b.
@ Euclidean
Euclidean distance. Lower is nearer.
@ Cosine
Cosine similarity: the angle between vectors, ignoring their lengths. Higher is nearer....
std::vector< double > CanonicalCorrelations(const Tensor &x, const Tensor &y)
The canonical correlations between two representations of the same inputs, largest first: min(rank x,...
CkaEstimator
Which estimator of CKA to use.
Definition representation_similarity.hpp:45
@ Biased
Kornblith et al.'s original estimator. Between 0 and 1, but biased upwards when the inputs are few co...
@ Debiased
Unbiased HSIC in place of HSIC: near 0 for unrelated representations at any number of inputs....
RdmComparison
How CompareRdms() correlates two RDMs.
Definition representation_similarity.hpp:128
@ Pearson
Pearson's correlation of the distances themselves.
@ Spearman
Spearman's rank correlation, ties given their average rank (scipy's spearmanr). Only the order of the...
RdmMetric
How RepresentationalDissimilarity() measures the distance between two inputs.
Definition representation_similarity.hpp:95
@ Correlation
1 minus the Pearson correlation of the two rows, between 0 and 2: the classic RSA choice,...
CKA between every pair from two lists of representations, such as the layers of two models: values[i ...
Definition representation_similarity.hpp:72
std::vector< double > values
Definition representation_similarity.hpp:75
int64_t cols
Definition representation_similarity.hpp:74
double at(int64_t row, int64_t col) const
int64_t rows
Definition representation_similarity.hpp:73
A representational dissimilarity matrix: the distance between every pair of n inputs.
Definition representation_similarity.hpp:108
std::vector< double > values
Definition representation_similarity.hpp:110
int64_t n
Definition representation_similarity.hpp:109
double at(int64_t i, int64_t j) const
The distance between inputs i and j; 0 when they are the same.
RsaPermutationTest()'s result.
Definition representation_similarity.hpp:151
double p_value
One-sided: the share of relabelings, counting the real one, that score at least similarity....
Definition representation_similarity.hpp:156
int64_t permutations
Definition representation_similarity.hpp:157
double similarity
CompareRdms() of the two RDMs as given.
Definition representation_similarity.hpp:153
Svcca()'s settings.
Definition representation_similarity.hpp:193
int64_t directions
If above 0, keep exactly this many directions of each instead (capped at its rank),...
Definition representation_similarity.hpp:199
double variance_kept
Keep each representation's fewest top singular directions whose share of the variance exceeds this,...
Definition representation_similarity.hpp:196
Svcca()'s result.
Definition representation_similarity.hpp:203
std::vector< double > correlations
The canonical correlations between the kept directions, largest first.
Definition representation_similarity.hpp:207
int64_t y_directions
Definition representation_similarity.hpp:210
int64_t x_directions
How many singular directions of x and of y were kept.
Definition representation_similarity.hpp:209
double similarity
The mean canonical correlation, Raghu et al.'s similarity.
Definition representation_similarity.hpp:205
N-dimensional tensor – owns a buffer via DeviceBackend*, RAII (Rule of Five).