RandomFeatureMaps

Documentation for RandomFeatureMaps.

RandomFeatureMaps.RandomFourierFeaturesType
RandomFourierFeatures(n => m, σ)

Maps n-dimensional data and projects it to m-dimensional random fourier features.

This type has no trainable parameters.

Examples

julia> rff = RandomFourierFeatures(2 => 4, 1.0); # maps 2D data to 4D

julia> rff(rand(2, 3)) |> size # 3 samples
(4, 3)

julia> rff(rand(2, 3, 5)) |> size # extra batch dim
(4, 3, 5)
source
RandomFeatureMaps.RandomOrientationFeaturesType
RandomOrientationFeatures

Holds two random matrices which are used to embed rigid transformations.

This type has no trainable parameters.

Methods

  • (::RandomOrientationFeatures)(rigid1, rigid2): returns the distances between the corresponding

rigid transformations, embedded using the two random matrices of the random orientation features.

  • (::RandomOrientationFeatures)(rigid1, rigid2; dims::Int): unsqueezes batch dimension dim+1

of rigid1 and dim of rigid2 to broadcast the rof call and produce a pairwise map.

  • (::RandomOrientationFeatures)(rigid1, rigid2, graph::GraphNeuralNetworks.GNNGraph): similar to

the first method, but takes two sets rigid transformations of equal size and unrolls a graph to get the pairs of rigid transformations. Equivalent to the second method (with broadcasted dimensions flattened) when the graph is complete.

Each of these have single rigid argument methods for when rigid1 == rigid2, i.e. rof(rigid)

Examples

julia> rof = RandomOrientationFeatures(10, 0.1f0);

julia> rigid = rand_rigid(Float32, (4, 3));

julia> rof(rigid, rigid) |> size
(10, 4, 3)

julia> rigid1, rigid2 = rand_rigid(Float32, (4, 2)), rand_rigid(Float32, (3, 2));

julia> rof(rigid1, rigid2; pairdim=1) |> size
(10, 4, 3, 2)

julia> using GraphNeuralNetworks

julia> graph = GNNGraph(Bool[1 0; 1 1], graph_type=:dense)
GNNGraph:
  num_nodes: 2
  num_edges: 3

julia> rigid = rand_rigid(Float32, (2,));

julia> rof(rigid, graph) |> size
(10, 3)
source
RandomFeatureMaps.RandomTriangleFeaturesType
RandomFourierFeatures(n => m, σ)

Maps n-dimensional data and projects it to m-dimensional random fourier features.

This type has no trainable parameters.

Examples

julia> rff = RandomFourierFeatures(2 => 4, 1.0); # maps 2D data to 4D

julia> rff(rand(2, 3)) |> size # 3 samples
(4, 3)

julia> rff(rand(2, 3, 5)) |> size # extra batch dim
(4, 3, 5)
source
RandomFeatureMaps.get_rigidMethod
get_rigid(R::AbstractArray, t::AbstractArray)

Converts a rotation R and translation t to a BatchedTransformations.Rigid, designed to handle batch dimensions.

The transformation gets applied according to NNlib.batched_mul(R, x) .+ t

source