Puppets Data

[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/s1_puppets/'
[5]:
X, labelsMat, img, img_shape = datasets.Datasets().puppets_data(dirpath='/data2/dhruv/PuppetsData', prefix='s1', n_pca=100)
Applying PCA
sum(explained_variance_ratio): 0.9815712482774274
X.shape =  (8100, 100)
[6]:
# The supplied options would override the default options
buml_obj = buml_.BUML(local_opts={'algo':'LDLE'},
                      intermed_opts={'eta_min': 5},
                      vis_opts={'c': X[:,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)
Computing local views using LDLE
Constructing unnorm graph Laplacian + its eigendecomposition.
Done.
##############################
Time elapsed from last time log: 2.5 seconds
Total time elapsed: 2.5 seconds
##############################
Computing Atilde: Inner Prod of Grad of EigFuncs.
FEM for Atilde.
Atilde: 0 points processed...
Atilde: 2025 points processed...
Atilde: 4050 points processed...
Atilde: 6075 points processed...
Atilde: all points processed...
Done.
##############################
Time elapsed from last time log: 0.6 seconds
Total time elapsed: 3.1 seconds
##############################
Computing LDLE.
local_param: all 8100 points processed...
max distortion is 980.250576
Done.
##############################
Time elapsed from last time log: 1.9 seconds
Total time elapsed: 5.0 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 7716, max distortion: 64.308463
#Param replaced: 2664, max distortion: 48.939619
#Param replaced: 578, max distortion: 45.840150
#Param replaced: 127, max distortion: 39.122621
#Param replaced: 37, max distortion: 39.122621
#Param replaced: 4, max distortion: 39.122621
#Param replaced: 0, max distortion: 39.122621
Max local distortion after postprocessing: 39.12262098886481
Done.
##############################
Time elapsed from last time log: 4.1 seconds
Total time elapsed: 9.1 seconds
##############################
Max local distortion = 39.12262098886481
Constructing intermediate views.
eta = 2.
#non-empty views with sz < 2 = 8100
#nodes in views with sz < 2 = 8100
Costs computed when eta = 2.
##############################
Time elapsed from last time log: 7.2 seconds
Total time elapsed: 7.7 seconds
##############################
ctr=5551, total_len_S=23084, avg_len_S=4.159
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 57.4 seconds
Total time elapsed: 65.1 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 916
#nodes in views with sz < 3 = 1832
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 2.0 seconds
Total time elapsed: 67.1 seconds
##############################
ctr=1512, total_len_S=26111, avg_len_S=17.269
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 17.5 seconds
Total time elapsed: 84.5 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 558
#nodes in views with sz < 4 = 1674
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 1.9 seconds
Total time elapsed: 86.5 seconds
##############################
ctr=1392, total_len_S=34380, avg_len_S=24.698
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 22.2 seconds
Total time elapsed: 108.6 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 325
#nodes in views with sz < 5 = 1300
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.8 seconds
Total time elapsed: 110.4 seconds
##############################
ctr=1117, total_len_S=34130, avg_len_S=30.555
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 17.4 seconds
Total time elapsed: 127.9 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 0.7 seconds
Total time elapsed: 128.6 seconds
##############################
After clustering, max distortion is 74.712312
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 1.8 seconds
Total time elapsed: 1.8 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.8 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 1.8 seconds
##############################
Initial alignment of 269 views completed
Initial alignment of 538 views completed
Initial alignment of 807 views completed
Initial alignment of 1076 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 1.1 seconds
Total time elapsed: 2.9 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 16.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.9 seconds
Total time elapsed: 23.3 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 32.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.7 seconds
Total time elapsed: 39.1 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 48.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.9 seconds
Total time elapsed: 55.3 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 62.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.0 seconds
Total time elapsed: 69.7 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 77.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.9 seconds
Total time elapsed: 84.0 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 92.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.0 seconds
Total time elapsed: 99.2 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 106.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.1 seconds
Total time elapsed: 113.6 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 121.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.9 seconds
Total time elapsed: 127.9 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 135.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.2 seconds
Total time elapsed: 142.5 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 149.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.1 seconds
Total time elapsed: 156.9 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 164.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.1 seconds
Total time elapsed: 171.4 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 179.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.0 seconds
Total time elapsed: 186.6 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 194.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.0 seconds
Total time elapsed: 201.8 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 209.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.9 seconds
Total time elapsed: 216.2 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 223.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.9 seconds
Total time elapsed: 230.5 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 237.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.8 seconds
Total time elapsed: 244.6 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 252.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.1 seconds
Total time elapsed: 259.2 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 267.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.2 seconds
Total time elapsed: 274.5 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 281.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.0 seconds
Total time elapsed: 288.9 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_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: 296.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.2 seconds
Total time elapsed: 304.1 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 8100 + 1078 multiplied with B
Computing svd
Done
Alignment error: 9370.137340
##############################
Time elapsed from last time log: 3.2 seconds
Total time elapsed: 307.3 seconds
##############################
../../_images/ldle_nbks_real_world_examples_s1_puppets_7_41.png
[7]:
array([[ 6.39834892,  5.98968155],
       [ 5.60624409,  4.14948788],
       [ 4.3295582 ,  2.5715501 ],
       ...,
       [ 6.65621218,  0.93813169],
       [ 5.92825544, -0.58460022],
       [ 4.3127534 , -1.31881197]])
[8]:
%matplotlib notebook
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])
[ ]: