flambe.nn.distance
¶
Submodules¶
Package Contents¶
-
class
flambe.nn.distance.
DistanceModule
[source]¶ Bases:
flambe.nn.module.Module
Implement a DistanceModule object.
-
forward
(self, mat_1: Tensor, mat_2: Tensor)¶ Performs a forward pass through the network.
Parameters: data (torch.Tensor) – The input data, as a float tensor Returns: The encoded output, as a float tensor Return type: torch.Tensor
-
-
class
flambe.nn.distance.
MeanModule
(detach_mean: bool = False)[source]¶ Bases:
flambe.nn.module.Module
Implement a MeanModule object.
-
forward
(self, data: Tensor)¶ Performs a forward pass through the network.
Parameters: data (torch.Tensor) – The input data, as a float tensor Returns: The encoded output, as a float tensor Return type: torch.Tensor
-
-
class
flambe.nn.distance.
EuclideanDistance
[source]¶ Bases:
flambe.nn.distance.distance.DistanceModule
Implement a EuclideanDistance object.
-
forward
(self, mat_1: Tensor, mat_2: Tensor)¶ Returns the squared euclidean distance between each element in mat_1 and each element in mat_2.
Parameters: - mat_1 (torch.Tensor) – matrix of shape (n_1, n_features)
- mat_2 (torch.Tensor) – matrix of shape (n_2, n_features)
Returns: dist – distance matrix of shape (n_1, n_2)
Return type: torch.Tensor
-
-
class
flambe.nn.distance.
EuclideanMean
[source]¶ Bases:
flambe.nn.distance.distance.MeanModule
Implement a EuclideanMean object.
-
forward
(self, data: Tensor)¶ Performs a forward pass through the network.
Parameters: data (torch.Tensor) – The input data, as a float tensor Returns: The encoded output, as a float tensor Return type: torch.Tensor
-
-
class
flambe.nn.distance.
CosineDistance
(eps: float = 1e-08)[source]¶ Bases:
flambe.nn.distance.DistanceModule
Implement a CosineDistance object.
-
forward
(self, mat_1: Tensor, mat_2: Tensor)¶ Returns the cosine distance between each element in mat_1 and each element in mat_2.
Parameters: - mat_1 (torch.Tensor) – matrix of shape (n_1, n_features)
- mat_2 (torch.Tensor) – matrix of shape (n_2, n_features)
Returns: dist – distance matrix of shape (n_1, n_2)
Return type: torch.Tensor
-
-
class
flambe.nn.distance.
CosineMean
[source]¶ Bases:
flambe.nn.distance.MeanModule
Implement a CosineMean object.
-
forward
(self, data: Tensor)¶ Performs a forward pass through the network.
Parameters: data (torch.Tensor) – The input data, as a float tensor Returns: The encoded output, as a float tensor Return type: torch.Tensor
-
-
class
flambe.nn.distance.
HyperbolicDistance
[source]¶ Bases:
flambe.nn.distance.distance.DistanceModule
Implement a HyperbolicDistance object.
-
forward
(self, mat_1: Tensor, mat_2: Tensor)¶ Returns the squared euclidean distance between each element in mat_1 and each element in mat_2.
Parameters: - mat_1 (torch.Tensor) – matrix of shape (n_1, n_features)
- mat_2 (torch.Tensor) – matrix of shape (n_2, n_features)
Returns: dist – distance matrix of shape (n_1, n_2)
Return type: torch.Tensor
-
-
class
flambe.nn.distance.
HyperbolicMean
[source]¶ Bases:
flambe.nn.distance.distance.MeanModule
Compute the mean point in the hyperboloid model.
-
forward
(self, data: Tensor)¶ Performs a forward pass through the network.
Parameters: data (torch.Tensor) – The input data, as a float tensor Returns: The encoded output, as a float tensor Return type: torch.Tensor
-
-
flambe.nn.distance.
get_distance_module
(metric: str) → DistanceModule[source]¶ Get the distance module from a string alias.
Currently available: . euclidean . cosine . hyperbolic
Parameters: metric (str) – The distance metric to use Raises: ValueError
– Unvalid distance string alias providedReturns: The instantiated distance module Return type: DistanceModule
-
flambe.nn.distance.
get_mean_module
(metric: str) → MeanModule[source]¶ Get the mean module from a string alias.
Currently available: . euclidean . cosine . hyperbolic
Parameters: metric (str) – The distance metric to use Raises: ValueError
– Unvalid distance string alias providedReturns: The instantiated distance module Return type: DistanceModule