File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ def interactive_plots(
6767 color_map = hyperparams .get ("color_map" , "jet" )
6868 plot_style = hyperparams .get ("plot_style" , 1 )
6969 point_size = hyperparams .get ("point_size" , 10 )
70+ perplexity = hyperparams .get ("perplexity" , None )
7071
7172 ## set up dirs
7273 data_dir = os .path .join (root_dir ,"data" , run_name )
@@ -114,8 +115,10 @@ def interactive_plots(
114115 ]
115116 return pd .concat ([df , pd .DataFrame (embeddings_train )], axis = 1 )
116117
118+ ## reduce dimensionality
119+ perplexity = perplexity if perplexity else min (100 , len (embeddings_train ) // 2 )
117120 reduced_data , colnames , _ = helpers .embbedings_dimension_reductions (
118- embeddings_train
121+ embeddings_train , perplexity
119122 )
120123 df = pd .DataFrame (reduced_data , columns = colnames )
121124 df ["paths" ] = [ os .path .join (".." , ".." , item ) for item in rel_paths_train ]
Original file line number Diff line number Diff line change @@ -214,7 +214,7 @@ def feature_map_normalization(f):
214214 act_map /= act_map .max ()
215215 return act_map
216216
217- def embbedings_dimension_reductions (data_table ):
217+ def embbedings_dimension_reductions (data_table , perplexity ):
218218 """
219219 Perform dimension reduction on the input data.
220220
@@ -231,7 +231,7 @@ def embbedings_dimension_reductions(data_table):
231231 norm_data = (data_table - mean ) / std
232232 pca_obj = decomposition .PCA (n_components = 2 )
233233 pca = pca_obj .fit_transform (norm_data )
234- tsne = manifold .TSNE (learning_rate = 'auto' , init = 'pca' ).fit_transform (norm_data )
234+ tsne = manifold .TSNE (perplexity = perplexity , learning_rate = 'auto' , init = 'pca' ).fit_transform (norm_data )
235235 names = ['PC1' , 'PC2' , 'tSNE-0' , 'tSNE-1' ]
236236 return np .hstack ((pca , tsne )), names , pca_obj
237237
You can’t perform that action at this time.
0 commit comments