Exemplo n.º 1
0
 def testDumpLoad(self):
     local_size = 2
     mat_sources = [np.random.rand(local_size), np.random.rand(local_size, 2), np.random.rand(local_size, 2, 3)]
     for mat in mat_sources:
         mpi.dump_matrix(mat, _MPI_DUMP_TEST_FILE)
         if mpi.is_root():
             mat_dumped = np.load(_MPI_DUMP_TEST_FILE)
             self.assertEqual(mat_dumped.shape, (local_size * mpi.SIZE,) + mat.shape[1:])
         mat_read = mpi.load_matrix(_MPI_DUMP_TEST_FILE)
         self.assertEqual(mat.shape, mat_read.shape)
Exemplo n.º 2
0
 def testDumpLoad(self):
     local_size = 2
     mat_sources = [
         np.random.rand(local_size),
         np.random.rand(local_size, 2),
         np.random.rand(local_size, 2, 3)
     ]
     for mat in mat_sources:
         mpi.dump_matrix(mat, _MPI_DUMP_TEST_FILE)
         if mpi.is_root():
             mat_dumped = np.load(_MPI_DUMP_TEST_FILE)
             self.assertEqual(mat_dumped.shape,
                              (local_size * mpi.SIZE, ) + mat.shape[1:])
         mat_read = mpi.load_matrix(_MPI_DUMP_TEST_FILE)
         self.assertEqual(mat.shape, mat_read.shape)
Exemplo n.º 3
0
mpi.root_pickle(conv, 'cvpr_exemplar_centroids_conv.pickle')
mpi.root_pickle((conv[-2].dictionary, ap_result), 'cvpr_exemplar_centroids.pickle')
"""
mpi.root_pickle((eigval, eigval_recon, eigval_random), 'cvpr_exemplar_centroids_covmat_eigvals.pickle')

# perform sampling
# sample post-pooling guys
Xtrain *= std
Xtrain += m
sampler = mathutil.ReservoirSampler(2000)
for i in range(covmat.shape[0]):
    label = ap_result[1][i]
    centroid_id = ap_result[0][label]
    if centroid_id != i:
        sampler.consider(Xtrain[:, [i, centroid_id]])
mpi.dump_matrix(sampler.get(), 'cvpr_exemplar_centroids_distribution_within_cluster_postpooling.npy')
sampler = mathutil.ReservoirSampler(2000)
for i in range(len(ap_result[0])):
    for j in range(i+1, len(ap_result[0])):
        sampler.consider(Xtrain[:,[ap_result[0][i],ap_result[0][j]]])
mpi.dump_matrix(sampler.get(), 'cvpr_exemplar_centroids_distribution_between_cluster_postpooling.npy')

# clean up something for the large sampler
del Xtrain
del Cpred
del Csel
del Crecon
del sampler

sampler = mathutil.ReservoirSampler(2000)
temp = pipeline.ConvLayer(conv[:-1]).sample(cifar, 200000, True)