pyFM.FMN.FMN.FMN¶
- class pyFM.FMN.FMN.FMN(meshlist, maps_dict=None)¶
Bases:
objectFunctional Map Network.
- Parameters:
- property n_meshes¶
Return the number of meshes (nodes) in the network.
- Returns:
n_meshes – Number of meshes in the network.
- Return type:
- property M¶
Return the current shared dimension for functional maps (which are square matrices).
If not specified, returns the size of the first found map.
- Returns:
M – Size of the functional maps.
- Return type:
- property m_cclb¶
Return the dimension of the Canonical Consistent Latent Basis.
- Returns:
m – Size of the CCLB.
- Return type:
- set_maps(maps_dict, verbose=False)¶
Set the edges of the graph with maps.
Saves extra information about the edges.
- Parameters:
- Returns:
self – The current object, with edges set.
- Return type:
- set_subsample(subsample)¶
Set the subsample of vertices on all shapes in the network.
- Parameters:
subsample ((n, size) np.ndarray) – Array of indices of vertices to subsample on each shape.
- Returns:
self – The current object, with the subsample set.
- Return type:
- compute_subsample(size=1000, geodesic=False, verbose=False)¶
Subsample vertices on each shape using farthest point sampling.
Store the result in an (n, size) array of indices.
- Parameters:
- Returns:
The subsample is stored in
self.subsamplein place.- Return type:
None
- set_weights(weights=None, weight_type='icsm', verbose=False)¶
Set weights for each edge in the graph.
- Parameters:
weights ((n, n) sparse matrix, optional) – Matrix of edge weights. If not specified, sets weights according to the
weight_typeargument.weight_type (str, optional) – ‘icsm’ | ‘adjacency’. If
weightsis not specified, computes weights according to the Consistent Zoomout adaptation of icsm or using the adjacency matrix of the graph.verbose (bool, optional) – Whether to print information during computation.
- Returns:
self – The current object, with weights set.
- Return type:
- set_isometries(M=None)¶
Symmetrize functional maps of reciprocal edges.
For each edge (i, j), if (j, i) is also an edge, the corresponding functional maps are set as the transpose of each other, choosing the closest to orthogonal of both.
Since this modifies the maps, icsm weights are deleted.
- Parameters:
M (int, optional) – Dimension with which to compare the functional maps. If None, uses the current
self.M.- Returns:
The maps are modified in place and map-dependent attributes reset.
- Return type:
None
- compute_W(M=None, verbose=False)¶
Compute the quadratic form for Consistent Latent Basis (CLB) computation.
- Parameters:
- Returns:
The quadratic form is stored in
self.Win place.- Return type:
None
- compute_CLB(equals_id=False, verbose=False)¶
Compute the Consistent Latent Basis (CLB) using the quadratic form.
The first M vectors for each basis are computed in order.
- compute_CCLB(m, verbose=True)¶
Compute the Canonical Consistent Latent Basis (CCLB) from the CLB.
- get_CSD(i)¶
Return the Characteristic Shape Difference (CSD) operators for mesh i.
- Parameters:
i (int) – Index of the mesh on which to return the two CSD.
- Returns:
CSD_a ((m, m) np.ndarray) – Area-based CSD expressed in the latent space.
CSD_c ((m, m) np.ndarray) – Conformal CSD expressed in the latent space.
- get_LB(i, complete=True)¶
Return the latent basis (LB) for mesh i.
- compute_p2p(complete=True, n_jobs=None)¶
Compute vertex-to-vertex maps for each (directed) edge from the CCLB.
Uses the factorization of functional maps through the CCLB. Only maps related to existing edges are computed. Vertex-to-vertex maps are saved in a dictionary the same way as functional maps, although their direction is reversed.
- Parameters:
- Returns:
The pointwise maps are stored in
self.p2pin place.- Return type:
None
- compute_maps(M, complete=True)¶
Convert pointwise maps into functional maps of size M.
- Parameters:
- Returns:
The functional maps are stored in
self.mapsin place and map-dependent attributes are reset.- Return type:
None
- extract_3_cycles()¶
Extract all 3-cycles from the graph as a list of 3-tuples (i, j, k).
- Returns:
The cycles are stored in
self.cyclesin place.- Return type:
None
- compute_Amat()¶
Compute matrix A for icsm weights optimization.
Binary matrix telling which edge belongs to which cycle. Uses the arbitrary edge ordering created in the
self.set_mapsmethod.- Returns:
The matrix is stored in
self.A(as a sparse matrix) and the indices of edges in a cycle inself.A_sub, in place.- Return type:
None
- compute_3cycle_weights(M=None)¶
Compute per-cycle costs and per-edge costs for icsm optimization.
Cycle weights are given by the
self.get_cycle_weightmethod (deviation from the identity map). Each edge weight is the inverse of the sum of all weights of the cycles the edge belongs to.- Parameters:
M (int, optional) – Dimension of functional maps to use. If None, uses
self.M.- Returns:
Cycle weights are stored in
self.cycle_weightand edge weights inself.edge_weights, in place.- Return type:
None
- optimize_icsm(verbose=False)¶
Solve the linear problem for icsm weights computation.
Solves \(\min w^{\top} x\) subject to \(A x \geq C_{\gamma}\) and \(x \geq 0\). Edges which are not part of a cycle are given zero weights.
- Parameters:
verbose (bool, optional) – Whether to print information during optimization.
- Returns:
opt_weights – (positive) weights for each edge.
- Return type:
(n_edges,) np.ndarray
- get_cycle_weight(cycle, M=None)¶
Compute the cost of a cycle (i, j, k) using the functional maps.
Cost is given as the maximum deviation to the identity map when going through the complete cycle (3 possibilities).
- zoomout_iteration(cclb_size, M_init, M_final, isometric=True, weight_type='icsm', n_jobs=None, equals_id=False, complete=False)¶
Perform an iteration of Consistent Zoomout refinement.
- Parameters:
cclb_size (int) – Size of the CCLB to compute.
M_init (int) – Initial dimension of maps.
M_final (int) – Dimension at the end of the iteration.
isometric (bool, optional) – Whether to use the reduced space strategy of ConsistentZoomout-iso.
weight_type (str, optional) – ‘icsm’ or ‘adjacency’, type of weights to use.
n_jobs (int, optional) – Number of parallel jobs. None (default) decides automatically.
equals_id (bool, optional) – Whether the CLB optimization uses Id or n * Id as a constraint.
complete (bool, optional) – Whether vertex-to-vertex and functional maps should be computed with all vertices instead of the subsampling.
- Returns:
The maps are refined in place.
- Return type:
None
- zoomout_refine(nit=10, step=1, subsample=1000, isometric=True, weight_type='icsm', M_init=None, cclb_ratio=0.9, n_jobs=None, equals_id=False, verbose=False)¶
Refine the functional maps using Consistent Zoomout refinement.
- Parameters:
nit (int, optional) – Number of zoomout iterations.
step (int, optional) – Dimension increase at each iteration.
subsample (int or np.ndarray, optional) – Size of vertices subsample. If set to 0 or None, all vertices are used.
isometric (bool, optional) – Whether to use the reduced space strategy of ConsistentZoomout-iso.
weight_type (str, optional) – ‘icsm’ or ‘adjacency’, type of weights to use.
M_init (int, optional) – Original size of functional maps. If None, uses
self.M.cclb_ratio (float, optional) – Size of CCLB as a ratio of the current dimension M.
n_jobs (int, optional) – Number of parallel jobs. None (default) decides automatically.
equals_id (bool, optional) – Whether the CLB optimization uses Id or n * Id as a constraint.
verbose (bool, optional) – Whether to print information during refinement.
- Returns:
The maps are refined in place.
- Return type:
None