Flat 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/flattorus4d/'
[5]:
X, labelsMat, ddX = datasets.Datasets().flattorus4d()
X.shape =  (10000, 4)
[6]:
# The supplied options would override the default options
buml_obj = buml_.BUML(local_opts={'algo':'LDLE'},
                      intermed_opts={'eta_min': 15},
                  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": 15,
    "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: 3.7 seconds
Total time elapsed: 3.7 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: 0.9 seconds
Total time elapsed: 4.6 seconds
##############################
Computing LDLE.
local_param: all 10000 points processed...
max distortion is 10.400540
Done.
##############################
Time elapsed from last time log: 1.7 seconds
Total time elapsed: 6.3 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 8742, max distortion: 1.839288
#Param replaced: 1155, max distortion: 1.835473
#Param replaced: 24, max distortion: 1.835473
#Param replaced: 0, max distortion: 1.835473
Max local distortion after postprocessing: 1.8354729404344732
Done.
##############################
Time elapsed from last time log: 6.0 seconds
Total time elapsed: 12.4 seconds
##############################
Max local distortion = 1.8354729404344732
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.0 seconds
Total time elapsed: 8.8 seconds
##############################
ctr=8076, total_len_S=65456, avg_len_S=8.105
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 256.5 seconds
Total time elapsed: 265.3 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 424
#nodes in views with sz < 3 = 848
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 1.9 seconds
Total time elapsed: 267.2 seconds
##############################
ctr=793, total_len_S=15959, avg_len_S=20.125
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 9.4 seconds
Total time elapsed: 276.5 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 267
#nodes in views with sz < 4 = 801
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 2.0 seconds
Total time elapsed: 278.5 seconds
##############################
ctr=723, total_len_S=19814, avg_len_S=27.405
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 9.1 seconds
Total time elapsed: 287.7 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 250
#nodes in views with sz < 5 = 1000
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.7 seconds
Total time elapsed: 289.4 seconds
##############################
ctr=937, total_len_S=31610, avg_len_S=33.735
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 19.4 seconds
Total time elapsed: 308.7 seconds
##############################
eta = 6.
#non-empty views with sz < 6 = 177
#nodes in views with sz < 6 = 885
Costs computed when eta = 6.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 310.3 seconds
##############################
ctr=762, total_len_S=29060, avg_len_S=38.136
Remaining #nodes in views with sz < 6 = 0
Done with eta = 6.
##############################
Time elapsed from last time log: 12.2 seconds
Total time elapsed: 322.5 seconds
##############################
eta = 7.
#non-empty views with sz < 7 = 136
#nodes in views with sz < 7 = 816
Costs computed when eta = 7.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 324.0 seconds
##############################
ctr=777, total_len_S=32956, avg_len_S=42.414
Remaining #nodes in views with sz < 7 = 0
Done with eta = 7.
##############################
Time elapsed from last time log: 12.9 seconds
Total time elapsed: 336.9 seconds
##############################
eta = 8.
#non-empty views with sz < 8 = 72
#nodes in views with sz < 8 = 504
Costs computed when eta = 8.
##############################
Time elapsed from last time log: 1.4 seconds
Total time elapsed: 338.3 seconds
##############################
ctr=490, total_len_S=22832, avg_len_S=46.596
Remaining #nodes in views with sz < 8 = 0
Done with eta = 8.
##############################
Time elapsed from last time log: 9.4 seconds
Total time elapsed: 347.6 seconds
##############################
eta = 9.
#non-empty views with sz < 9 = 71
#nodes in views with sz < 9 = 568
Costs computed when eta = 9.
##############################
Time elapsed from last time log: 1.4 seconds
Total time elapsed: 349.0 seconds
##############################
ctr=544, total_len_S=27658, avg_len_S=50.842
Remaining #nodes in views with sz < 9 = 0
Done with eta = 9.
##############################
Time elapsed from last time log: 12.0 seconds
Total time elapsed: 361.0 seconds
##############################
eta = 10.
#non-empty views with sz < 10 = 69
#nodes in views with sz < 10 = 621
Costs computed when eta = 10.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 362.6 seconds
##############################
ctr=587, total_len_S=33421, avg_len_S=56.935
Remaining #nodes in views with sz < 10 = 1
Done with eta = 10.
##############################
Time elapsed from last time log: 16.1 seconds
Total time elapsed: 378.7 seconds
##############################
eta = 11.
#non-empty views with sz < 11 = 34
#nodes in views with sz < 11 = 331
Costs computed when eta = 11.
##############################
Time elapsed from last time log: 1.3 seconds
Total time elapsed: 380.0 seconds
##############################
ctr=289, total_len_S=16864, avg_len_S=58.353
Remaining #nodes in views with sz < 11 = 3
Done with eta = 11.
##############################
Time elapsed from last time log: 6.6 seconds
Total time elapsed: 386.6 seconds
##############################
eta = 12.
#non-empty views with sz < 12 = 56
#nodes in views with sz < 12 = 597
Costs computed when eta = 12.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 388.1 seconds
##############################
ctr=535, total_len_S=32503, avg_len_S=60.753
Remaining #nodes in views with sz < 12 = 3
Done with eta = 12.
##############################
Time elapsed from last time log: 11.2 seconds
Total time elapsed: 399.3 seconds
##############################
eta = 13.
#non-empty views with sz < 13 = 37
#nodes in views with sz < 13 = 423
Costs computed when eta = 13.
##############################
Time elapsed from last time log: 1.4 seconds
Total time elapsed: 400.7 seconds
##############################
ctr=377, total_len_S=24213, avg_len_S=64.225
Remaining #nodes in views with sz < 13 = 5
Done with eta = 13.
##############################
Time elapsed from last time log: 7.9 seconds
Total time elapsed: 408.6 seconds
##############################
eta = 14.
#non-empty views with sz < 14 = 18
#nodes in views with sz < 14 = 187
Costs computed when eta = 14.
##############################
Time elapsed from last time log: 1.3 seconds
Total time elapsed: 409.9 seconds
##############################
ctr=182, total_len_S=12092, avg_len_S=66.440
Remaining #nodes in views with sz < 14 = 5
Done with eta = 14.
##############################
Time elapsed from last time log: 4.0 seconds
Total time elapsed: 413.9 seconds
##############################
eta = 15.
#non-empty views with sz < 15 = 23
#nodes in views with sz < 15 = 271
Costs computed when eta = 15.
##############################
Time elapsed from last time log: 1.3 seconds
Total time elapsed: 415.2 seconds
##############################
ctr=222, total_len_S=16286, avg_len_S=73.360
Remaining #nodes in views with sz < 15 = 35
Done with eta = 15.
##############################
Time elapsed from last time log: 3.5 seconds
Total time elapsed: 418.7 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 0.4 seconds
Total time elapsed: 419.2 seconds
##############################
After clustering, max distortion is 239.489804
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 1.3 seconds
Total time elapsed: 1.3 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.4 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 1.4 seconds
##############################
Initial alignment of 114 views completed
Initial alignment of 228 views completed
Initial alignment of 342 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 0.6 seconds
Total time elapsed: 1.9 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 8.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.8 seconds
Total time elapsed: 11.7 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 16.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.7 seconds
Total time elapsed: 20.4 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 25.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.9 seconds
Total time elapsed: 29.1 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 34.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.8 seconds
Total time elapsed: 37.8 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 42.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.0 seconds
Total time elapsed: 46.8 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 52.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.0 seconds
Total time elapsed: 56.4 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 62.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.1 seconds
Total time elapsed: 66.1 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 70.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.8 seconds
Total time elapsed: 74.8 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 79.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.0 seconds
Total time elapsed: 83.7 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 88.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.9 seconds
Total time elapsed: 92.7 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 97.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.9 seconds
Total time elapsed: 101.4 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 106.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.2 seconds
Total time elapsed: 111.0 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 116.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.0 seconds
Total time elapsed: 120.6 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 125.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.6 seconds
Total time elapsed: 129.9 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 135.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.7 seconds
Total time elapsed: 138.9 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 143.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.8 seconds
Total time elapsed: 147.6 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 153.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.4 seconds
Total time elapsed: 157.6 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 163.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.2 seconds
Total time elapsed: 167.7 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 173.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.9 seconds
Total time elapsed: 176.9 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_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: 181.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 3.9 seconds
Total time elapsed: 185.7 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 456 multiplied with B
Computing svd
Done
Alignment error: 0.382385
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 187.2 seconds
##############################
../../_images/ldle_nbks_closed_manifolds_flattorus4d_7_41.png
[7]:
array([[-0.91465702, -0.12897511],
       [ 0.93311116,  0.21098714],
       [ 0.93237203,  0.2225935 ],
       ...,
       [-0.92271408, -0.15932988],
       [-0.92412335, -0.14976265],
       [-0.92548621, -0.14051058]])
[8]:
%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_flattorus4d_8_0.png
[9]:
util_.save(save_dir_root, 'ldle.dat', [X, labelsMat, buml_obj])
[ ]: