Curved Torus

[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/curvedtorus3d/'
[5]:
X, labelsMat, ddX = datasets.Datasets().curvedtorus3d()
X.shape =  (10000, 3)
[6]:
# The supplied options would override the default options
buml_obj = buml_.BUML(local_opts={'algo':'LDLE'},
                  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
}
[8]:
buml_obj.fit(X=X)
Computing local views using LDLE
Constructing unnorm graph Laplacian + its eigendecomposition.
Done.
##############################
Time elapsed from last time log: 4.3 seconds
Total time elapsed: 4.3 seconds
##############################
Computing Atilde: Inner Prod of Grad of EigFuncs.
FEM for Atilde.
Atilde: 0 points processed...
Atilde: 2500 points processed...
Atilde: 5000 points processed...
Atilde: 7500 points processed...
Atilde: all points processed...
Done.
##############################
Time elapsed from last time log: 1.0 seconds
Total time elapsed: 5.3 seconds
##############################
Computing LDLE.
local_param: all 10000 points processed...
max distortion is 7454.867512
Done.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 7.0 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 9412, max distortion: 23.129115
#Param replaced: 2592, max distortion: 22.500799
#Param replaced: 565, max distortion: 18.717018
#Param replaced: 116, max distortion: 18.717018
#Param replaced: 34, max distortion: 18.717018
#Param replaced: 1, max distortion: 18.717018
#Param replaced: 1, max distortion: 18.717018
#Param replaced: 0, max distortion: 18.717018
Max local distortion after postprocessing: 18.7170183396597
Done.
##############################
Time elapsed from last time log: 6.7 seconds
Total time elapsed: 13.7 seconds
##############################
Max local distortion = 18.7170183396597
Constructing intermediate views.
eta = 2.
#non-empty views with sz < 2 = 10000
#nodes in views with sz < 2 = 10000
Costs computed when eta = 2.
##############################
Time elapsed from last time log: 8.8 seconds
Total time elapsed: 9.8 seconds
##############################
ctr=7282, total_len_S=38072, avg_len_S=5.228
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 123.6 seconds
Total time elapsed: 133.4 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 876
#nodes in views with sz < 3 = 1752
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 1.9 seconds
Total time elapsed: 135.3 seconds
##############################
ctr=1486, total_len_S=26416, avg_len_S=17.777
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 19.2 seconds
Total time elapsed: 154.5 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 536
#nodes in views with sz < 4 = 1608
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 1.8 seconds
Total time elapsed: 156.3 seconds
##############################
ctr=1376, total_len_S=34795, avg_len_S=25.287
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 23.0 seconds
Total time elapsed: 179.3 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 321
#nodes in views with sz < 5 = 1284
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.7 seconds
Total time elapsed: 181.0 seconds
##############################
ctr=1132, total_len_S=36027, avg_len_S=31.826
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 19.0 seconds
Total time elapsed: 200.0 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 0.9 seconds
Total time elapsed: 201.0 seconds
##############################
After clustering, max distortion is 23.188153
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 1.6 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.6 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 1.6 seconds
##############################
Initial alignment of 311 views completed
Initial alignment of 622 views completed
Initial alignment of 933 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 1.4 seconds
Total time elapsed: 2.9 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 17.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.8 seconds
Total time elapsed: 26.2 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 37.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.8 seconds
Total time elapsed: 46.0 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 56.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 64.9 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 74.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 83.3 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 91.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.8 seconds
Total time elapsed: 99.7 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 108.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 117.3 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 126.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 135.2 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 144.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 152.8 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 160.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 168.9 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 177.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 186.1 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 195.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 204.1 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 212.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 221.3 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 229.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.8 seconds
Total time elapsed: 238.7 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 245.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 254.6 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 262.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.6 seconds
Total time elapsed: 271.5 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 279.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.5 seconds
Total time elapsed: 288.5 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 297.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.5 seconds
Total time elapsed: 305.5 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 314.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 322.8 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 330.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.6 seconds
Total time elapsed: 338.7 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_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: 347.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.6 seconds
Total time elapsed: 356.0 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1244 multiplied with B
Computing svd
Done
Alignment error: 2.555978
##############################
Time elapsed from last time log: 5.0 seconds
Total time elapsed: 361.1 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_curvedtorus3d_7_41.png
[8]:
array([[ 0.037602  ,  0.51226061],
       [-0.25395747,  0.02482892],
       [ 0.2067306 ,  0.42799681],
       ...,
       [-0.00606774, -0.21903511],
       [-0.58593637, -0.22139301],
       [-0.29931546,  0.05805353]])
[9]:
%matplotlib inline
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_closed_manifolds_curvedtorus3d_8_0.png
[10]:
util_.save(save_dir_root, 'ldle.dat', [X, labelsMat, buml_obj])
[ ]: