Doubled square with two holes
[1]:
%matplotlib inline
[2]:
# Not really required
import sys
sys.path.insert(0, '../../..')
[3]:
from pyLDLE2 import datasets
from pyLDLE2 import buml_, util_
matplotlib.get_backend() = module://matplotlib_inline.backend_inline
[4]:
save_dir_root = '../data/pyLDLE2/doubled_squarewithtwoholes/'
[5]:
X, labelsMat, ddX = datasets.Datasets().squarewithtwoholes()
X.shape = (9169, 2)
[6]:
# The supplied options would override the default options
buml_obj = buml_.BUML(local_opts={'algo':'LDLE'},
intermed_opts={'algo':'best', 'eta_min': 5},
vis_opts={'c': labelsMat[:,0], 'save_dir': save_dir_root},
verbose=True, debug=True)
local_opts['k_nn0'] = 700 is created.
Options provided:
local_opts:
{
"Atilde_method": "LDLE_1",
"N": 100,
"U_method": "k_nn",
"algo": "LDLE",
"alpha": 1,
"debug": true,
"delta": 0.9,
"gl_type": "unnorm",
"k": 28,
"k_nn": 49,
"k_nn0": 700,
"k_tune": 7,
"lambda1_decay": 0.75,
"lambda1_init": 8,
"lambda1_min": 0.001,
"max_iter": 300,
"max_sparsity": 0.9,
"metric": "euclidean",
"n_proc": 32,
"p": 0.99,
"power": 5,
"pp_n_thresh": 32,
"radius": 0.5,
"reg": 0.0,
"scale_by": "gamma",
"tau": 50,
"to_postprocess": true,
"verbose": true
}
intermed_opts:
{
"algo": "best",
"debug": true,
"eta_max": 25,
"eta_min": 5,
"len_S_thresh": 256,
"local_algo": "LDLE",
"metric": "euclidean",
"n_proc": 32,
"n_times": 4,
"verbose": true
}
global_opts:
{
"add_dim": false,
"align_transform": "rigid",
"align_w_parent_only": true,
"alpha": 0.3,
"beta": {
"align": null,
"repel": 1
},
"color_tear": true,
"compute_error": false,
"debug": true,
"eps": 1e-08,
"err_tol": 0.0001,
"far_off_points_type": "reuse_fixed",
"init_algo_name": "procrustes",
"k": 28,
"max_internal_iter": 100,
"max_iter": 20,
"metric": "euclidean",
"n_proc": 32,
"n_repel": 0,
"nu": 3,
"patience": 5,
"refine_algo_name": "rgd",
"repel_by": 0.0,
"to_tear": true,
"verbose": true,
"vis_before_init": false
}
[7]:
buml_obj.fit(X=X, ddX=ddX)
Doubling manifold.
No. of points on the boundary = 540
/home/dhruv/anaconda3/lib/python3.9/site-packages/sklearn/neighbors/_base.py:234: EfficiencyWarning: Precomputed sparse input was not sorted by row values. Use the function sklearn.neighbors.sort_graph_by_row_values to sort the input by row values, with warn_when_not_sorted=False to remove this warning.
warnings.warn(
Done.
##############################
Time elapsed from last time log: 40.9 seconds
Total time elapsed: 40.9 seconds
##############################
Computing local views using LDLE
Constructing unnorm graph Laplacian + its eigendecomposition.
Done.
##############################
Time elapsed from last time log: 7.2 seconds
Total time elapsed: 7.2 seconds
##############################
Computing Atilde: Inner Prod of Grad of EigFuncs.
FEM for Atilde.
Atilde: 0 points processed...
Atilde: 4449 points processed...
Atilde: 8898 points processed...
Atilde: 13347 points processed...
Atilde: 17796 points processed...
Atilde: all points processed...
Done.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 8.8 seconds
##############################
Computing LDLE.
local_param: all 17798 points processed...
max distortion is 7881.317289
Done.
##############################
Time elapsed from last time log: 2.2 seconds
Total time elapsed: 11.1 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 16816, max distortion: 11.101724
#Param replaced: 8219, max distortion: 11.101724
#Param replaced: 2668, max distortion: 11.101724
#Param replaced: 659, max distortion: 11.101724
#Param replaced: 157, max distortion: 11.101724
#Param replaced: 40, max distortion: 11.101724
#Param replaced: 6, max distortion: 11.101724
#Param replaced: 1, max distortion: 11.101724
#Param replaced: 5, max distortion: 11.101724
#Param replaced: 0, max distortion: 11.101724
Max local distortion after postprocessing: 11.101724016147374
Done.
##############################
Time elapsed from last time log: 11.7 seconds
Total time elapsed: 22.7 seconds
##############################
Halving objects.
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 33.0 seconds
##############################
Max local distortion = 11.098097934407262
Constructing intermediate views.
eta = 2.
#non-empty views with sz < 2 = 9169
#nodes in views with sz < 2 = 9169
/home/dhruv/codebase/pyLDLE2/docs/ldle_nbks/doubled_manifolds/../../../pyLDLE2/intermed_views_.py:122: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
neigh_ind = np.array(neigh_ind)
Costs computed when eta = 2.
##############################
Time elapsed from last time log: 5.8 seconds
Total time elapsed: 6.5 seconds
##############################
ctr=7060, total_len_S=44579, avg_len_S=6.314
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 199.7 seconds
Total time elapsed: 206.2 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 486
#nodes in views with sz < 3 = 972
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 1.9 seconds
Total time elapsed: 208.1 seconds
##############################
ctr=837, total_len_S=15061, avg_len_S=17.994
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 7.9 seconds
Total time elapsed: 216.1 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 386
#nodes in views with sz < 4 = 1158
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 2.1 seconds
Total time elapsed: 218.1 seconds
##############################
ctr=1029, total_len_S=27118, avg_len_S=26.354
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 17.3 seconds
Total time elapsed: 235.4 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 279
#nodes in views with sz < 5 = 1116
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.8 seconds
Total time elapsed: 237.2 seconds
##############################
ctr=1000, total_len_S=32863, avg_len_S=32.863
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 20.4 seconds
Total time elapsed: 257.7 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 0.7 seconds
Total time elapsed: 258.4 seconds
##############################
After clustering, max distortion is 12.652919
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 2.0 seconds
Total time elapsed: 2.0 seconds
##############################
Computing a lateration.
Seq of intermediate views and their predecessors computed.
No. of connected components = 1
Done.
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 2.0 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 2.0 seconds
##############################
Initial alignment of 278 views completed
Initial alignment of 556 views completed
Initial alignment of 834 views completed
Initial alignment of 1112 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 1.1 seconds
Total time elapsed: 3.2 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 0
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 6.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.1 seconds
Total time elapsed: 14.3 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 1
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 15.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 15.5 seconds
Total time elapsed: 31.2 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 2
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 32.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.8 seconds
Total time elapsed: 43.4 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 3
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 44.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 53.5 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 4
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 54.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 63.7 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 5
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 64.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.7 seconds
Total time elapsed: 74.5 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 6
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 75.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.8 seconds
Total time elapsed: 86.6 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 7
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 87.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.1 seconds
Total time elapsed: 97.0 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 8
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 98.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 107.3 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 9
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 109.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 117.4 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 10
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 119.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.5 seconds
Total time elapsed: 128.0 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 11
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 130.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 139.0 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 12
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 140.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.3 seconds
Total time elapsed: 150.7 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 13
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 152.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.5 seconds
Total time elapsed: 161.5 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 14
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 163.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.4 seconds
Total time elapsed: 173.4 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 15
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 174.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.8 seconds
Total time elapsed: 185.5 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 16
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 187.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.5 seconds
Total time elapsed: 197.4 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 17
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 198.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 11.1 seconds
Total time elapsed: 210.0 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 18
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 211.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 19.6 seconds
Total time elapsed: 231.1 seconds
##############################
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 19
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 232.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 15.4 seconds
Total time elapsed: 248.2 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 1115 multiplied with B
Computing svd
Done
Alignment error: 0.788759
##############################
Time elapsed from last time log: 4.3 seconds
Total time elapsed: 252.5 seconds
##############################
[7]:
array([[-0.6541161 , 0.06828348],
[-0.65445237, 0.06784278],
[-0.65000124, 0.06514797],
...,
[ 0.67181086, -0.06771397],
[ 0.67351496, -0.06988415],
[ 0.677381 , -0.07153926]])
[8]:
buml_obj.GlobalViews.vis_embedding(buml_obj.GlobalViews.y_final, buml_obj.vis, buml_obj.vis_opts,
buml_obj.GlobalViews.color_of_pts_on_tear_final,
title='Final global embedding', )
[9]:
util_.save(save_dir_root, 'ldle.dat', [X, labelsMat, buml_obj])