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/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': 10},
                  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": 10,
    "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)
Computing local views using LDLE
Constructing unnorm graph Laplacian + its eigendecomposition.
Done.
##############################
Time elapsed from last time log: 2.7 seconds
Total time elapsed: 2.7 seconds
##############################
Computing Atilde: Inner Prod of Grad of EigFuncs.
FEM for Atilde.
Atilde: 0 points processed...
Atilde: 2292 points processed...
Atilde: 4584 points processed...
Atilde: 6876 points processed...
Atilde: 9168 points processed...
Atilde: all points processed...
Done.
##############################
Time elapsed from last time log: 0.7 seconds
Total time elapsed: 3.4 seconds
##############################
Computing LDLE.
local_param: all 9169 points processed...
max distortion is 141203.881512
Done.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 4.9 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 8581, max distortion: 10.887755
#Param replaced: 2529, max distortion: 9.086094
#Param replaced: 318, max distortion: 9.086094
#Param replaced: 51, max distortion: 9.060404
#Param replaced: 2, max distortion: 9.060404
#Param replaced: 0, max distortion: 9.060404
Max local distortion after postprocessing: 9.06040357758859
Done.
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 9.8 seconds
##############################
Max local distortion = 9.06040357758859
Constructing intermediate views.
eta = 2.
#non-empty views with sz < 2 = 9169
#nodes in views with sz < 2 = 9169
Costs computed when eta = 2.
##############################
Time elapsed from last time log: 7.2 seconds
Total time elapsed: 7.9 seconds
##############################
ctr=6971, total_len_S=42851, avg_len_S=6.147
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 138.0 seconds
Total time elapsed: 145.9 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 543
#nodes in views with sz < 3 = 1086
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 147.6 seconds
##############################
ctr=964, total_len_S=17858, avg_len_S=18.525
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 9.1 seconds
Total time elapsed: 156.7 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 419
#nodes in views with sz < 4 = 1257
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 158.3 seconds
##############################
ctr=1113, total_len_S=28798, avg_len_S=25.874
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 16.6 seconds
Total time elapsed: 174.9 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 253
#nodes in views with sz < 5 = 1012
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 176.5 seconds
##############################
ctr=904, total_len_S=29839, avg_len_S=33.008
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 13.7 seconds
Total time elapsed: 190.1 seconds
##############################
eta = 6.
#non-empty views with sz < 6 = 208
#nodes in views with sz < 6 = 1040
Costs computed when eta = 6.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 191.6 seconds
##############################
ctr=946, total_len_S=35875, avg_len_S=37.923
Remaining #nodes in views with sz < 6 = 0
Done with eta = 6.
##############################
Time elapsed from last time log: 19.6 seconds
Total time elapsed: 211.2 seconds
##############################
eta = 7.
#non-empty views with sz < 7 = 158
#nodes in views with sz < 7 = 948
Costs computed when eta = 7.
##############################
Time elapsed from last time log: 1.4 seconds
Total time elapsed: 212.6 seconds
##############################
ctr=842, total_len_S=36071, avg_len_S=42.840
Remaining #nodes in views with sz < 7 = 0
Done with eta = 7.
##############################
Time elapsed from last time log: 17.3 seconds
Total time elapsed: 229.9 seconds
##############################
eta = 8.
#non-empty views with sz < 8 = 103
#nodes in views with sz < 8 = 721
Costs computed when eta = 8.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 231.4 seconds
##############################
ctr=691, total_len_S=32243, avg_len_S=46.661
Remaining #nodes in views with sz < 8 = 0
Done with eta = 8.
##############################
Time elapsed from last time log: 14.0 seconds
Total time elapsed: 245.4 seconds
##############################
eta = 9.
#non-empty views with sz < 9 = 95
#nodes in views with sz < 9 = 760
Costs computed when eta = 9.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 246.9 seconds
##############################
ctr=703, total_len_S=35554, avg_len_S=50.575
Remaining #nodes in views with sz < 9 = 0
Done with eta = 9.
##############################
Time elapsed from last time log: 15.8 seconds
Total time elapsed: 262.7 seconds
##############################
eta = 10.
#non-empty views with sz < 10 = 58
#nodes in views with sz < 10 = 522
Costs computed when eta = 10.
##############################
Time elapsed from last time log: 1.3 seconds
Total time elapsed: 264.0 seconds
##############################
ctr=452, total_len_S=24807, avg_len_S=54.883
Remaining #nodes in views with sz < 10 = 0
Done with eta = 10.
##############################
Time elapsed from last time log: 12.7 seconds
Total time elapsed: 276.7 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 0.6 seconds
Total time elapsed: 277.3 seconds
##############################
After clustering, max distortion is 13.978852
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 1.5 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: 1.5 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 1.5 seconds
##############################
Initial alignment of 145 views completed
Initial alignment of 290 views completed
Initial alignment of 435 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 0.7 seconds
Total time elapsed: 2.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_1.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 0
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 6.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 10.9 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_3.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 1
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 13.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 18.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_5.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 2
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 21.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.0 seconds
Total time elapsed: 26.8 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_7.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 3
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 30.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 34.8 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_9.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 4
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 37.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.0 seconds
Total time elapsed: 42.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_11.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 5
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 45.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 50.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_13.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 6
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 53.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.0 seconds
Total time elapsed: 58.0 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_15.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 7
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 60.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.8 seconds
Total time elapsed: 65.1 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_17.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 8
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 67.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.7 seconds
Total time elapsed: 72.1 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_19.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 9
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 74.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.6 seconds
Total time elapsed: 79.1 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_21.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 10
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 81.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.2 seconds
Total time elapsed: 86.8 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_23.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 11
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 89.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.0 seconds
Total time elapsed: 94.0 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_25.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 12
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 95.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.1 seconds
Total time elapsed: 100.7 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_27.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 13
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 102.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.1 seconds
Total time elapsed: 107.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_29.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 14
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 108.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 113.7 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_31.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 15
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 115.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 119.9 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_33.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 16
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 121.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.8 seconds
Total time elapsed: 126.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_35.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 17
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 127.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.7 seconds
Total time elapsed: 132.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_37.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 18
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 133.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 138.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_39.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 19
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 140.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 144.9 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9169 + 580 multiplied with B
Computing svd
Done
Alignment error: 1.942816
##############################
Time elapsed from last time log: 2.0 seconds
Total time elapsed: 146.9 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_7_41.png
[7]:
array([[-0.65999627, -0.03229066],
       [-0.65081979, -0.03337502],
       [-0.64528303, -0.03729237],
       ...,
       [ 0.64603292,  0.0334619 ],
       [ 0.65010945,  0.02909991],
       [ 0.65660893,  0.02708596]])
[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', )
../../_images/ldle_nbks_manifolds_with_boundary_squarewithtwoholes_8_0.png
[9]:
util_.save(save_dir_root, 'ldle.dat', [X, labelsMat, buml_obj])