Skip to content

Commit

Permalink
removed all count_nonzero from sparse matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusMNoack committed Oct 4, 2023
1 parent ab8ccf1 commit 940ea1b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fvgp/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ def _compute_GPpriorV(self, x_data, y_data, hyperparameters, calc_inv = False):
self.gp2Scale_obj.compute_covariance(hyperparameters, self.gp2Scale_dask_client)
if self.info: print("Computing the covariance matrix done after ",time.time()-st," seconds.", flush = True)
K = self.gp2Scale_obj.SparsePriorCovariance.get_result().result()
if self.info: print("Transferring the covariance matrix to host done after ",time.time()-st," seconds. sparsity = ", float(K.count_nonzero())/float(len(x_data)**2) , flush = True)
if self.info: print("Transferring the covariance matrix to host done after ",time.time()-st," seconds. sparsity = ", float(K.nnz)/float(len(x_data)**2) , flush = True)
self.gp2Scale_obj.SparsePriorCovariance.reset_prior().result()
if self.info: print("Reset the prior done.", flush = True)
else: K = self._compute_K(hyperparameters)
Expand Down
12 changes: 6 additions & 6 deletions fvgp/gp2Scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def compute_covariance(self, hyperparameters,client):

#########
if self.info:
print("total prior covariance compute time: ", time.time() - start_time, "Non-zero count: ", self.SparsePriorCovariance.get_result().result().count_nonzero(),flush = True)
print("Sparsity: ",self.SparsePriorCovariance.get_result().result().count_nonzero()/float(self.point_number)**2,flush = True)
print("total prior covariance compute time: ", time.time() - start_time, "Non-zero count: ", self.SparsePriorCovariance.get_result().result().nzz,flush = True)
print("Sparsity: ",self.SparsePriorCovariance.get_result().result().nnz/float(self.point_number)**2,flush = True)


def free_workers(self, futures, finished_futures):
Expand Down Expand Up @@ -276,9 +276,9 @@ def __init__(self,input_space_dim,
if self.info:
sp = self.SparsePriorCovariance.get_result().result()
print("gp2Scale successfully initiated, here is some info about the prior covariance matrix:")
print("non zero elements: ", sp.count_nonzero())
print("non zero elements: ", sp.nnz))
print("Size in GBits: ", sp.data.nbytes/1e9)
print("Sparsity: ",sp.count_nonzero()/float(self.point_number)**2)
print("Sparsity: ",sp.nnz/float(self.point_number)**2)
if self.point_number <= 5000:
print("Here is an image:")
plt.imshow(sp.toarray())
Expand Down Expand Up @@ -357,8 +357,8 @@ def compute_covariance(self, hyperparameters, variances,client):

#########
if self.info:
print("total prior covariance compute time: ", time.time() - start_time, "Non-zero count: ", self.SparsePriorCovariance.get_result().result().count_nonzero())
print("Sparsity: ",self.SparsePriorCovariance.get_result().result().count_nonzero()/float(self.point_number)**2)
print("total prior covariance compute time: ", time.time() - start_time, "Non-zero count: ", self.SparsePriorCovariance.get_result().result().nnz)
print("Sparsity: ",self.SparsePriorCovariance.get_result().result().nnz/float(self.point_number)**2)


def free_workers(self, futures, finished_futures):
Expand Down

0 comments on commit 940ea1b

Please sign in to comment.