def save_weights_object(savedir, weights): if not os.path.isdir(savedir): os.makedirs(savedir) for m_type in weights: if weights[m_type] is not None: save_numpy_matrix(os.path.join(savedir, m_type), weights[m_type])
with open(os.path.join(rep_save_path, 'timing'), 'w') as f: f.write(json.dumps(time_dict)) else: with open(os.path.join(rep_save_path, 'timing')) as f: time_dict = json.loads(f.read().strip()) # Get metadata importances monet0_importances = numpy.matmul(embeddings['monet0']['H1'], numpy.transpose(embeddings['monet0']['H2'])) monet_importances = numpy.matmul(embeddings['monet']['H1'], numpy.transpose(embeddings['monet']['H2'])) print('saving monet0_importances to %s' % (os.path.join(rep_save_path, 'monet0_importances'))) print('monet0 importances:') print(monet0_importances) save_numpy_matrix( os.path.join(rep_save_path, 'monet0_importances'), monet0_importances) print('saving monet_importances to %s' % (os.path.join(rep_save_path, 'monet_importances'))) print('monet importances:') print(monet_importances) save_numpy_matrix( os.path.join(rep_save_path, 'monet_importances'), monet_importances) # Get leakages print('computing leakages') for method in embeddings: if embeddings[method] is not None: if 'monet' in method: leakage_dict[method] = float( compute_leakage(embeddings[method]['Z'], embeddings[method]['W'])) else: