Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: inconsistent shapes on sparse matrix generating process #21

Open
garyhsu29 opened this issue Nov 19, 2022 · 1 comment
Open

Comments

@garyhsu29
Copy link

Thanks for the great work on nodevectors & CSR graph!
I encounter an issue while using nodevectors, but it turns out it's a problem on sparse matrix generating process.
Error message:

ValueError Traceback (most recent call last)
Input In [34], in <cell line: 2>()
1 g2v = ProNE()
----> 2 g2v.fit(G)

File ~/miniforge3/envs/alphaA/lib/python3.8/site-packages/nodevectors/prone.py:82, in ProNE.fit(self, graph)
78 G = cg.csrgraph(graph)
79 features_matrix = self.pre_factorization(G.mat,
80 self.n_components,
81 self.exponent)
---> 82 vectors = ProNE.chebyshev_gaussian(
83 G.mat, features_matrix, self.n_components,
84 step=self.step, mu=self.mu, theta=self.theta)
85 self.model = dict(zip(G.nodes(), vectors))

File ~/miniforge3/envs/alphaA/lib/python3.8/site-packages/nodevectors/prone.py:154, in ProNE.chebyshev_gaussian(G, a, n_components, step, mu, theta)
151 return a
152 print(G.shape)
--> 154 A = sparse.eye(nnodes) + G
155 DA = preprocessing.normalize(A, norm='l1')
156 # L is graph laplacian

File ~/miniforge3/envs/alphaA/lib/python3.8/site-packages/scipy/sparse/base.py:414, in spmatrix.add(self, other)
412 elif isspmatrix(other):
413 if other.shape != self.shape:
--> 414 raise ValueError("inconsistent shapes")
415 return self._add_sparse(other)
416 elif isdense(other):

ValueError: inconsistent shapes
@garyhsu29
Copy link
Author

garyhsu29 commented Nov 19, 2022

I think the symmetrical problem could be solved by
editing

sparse.csr_matrix((weights, dst, new_src)),
to
sparse.csr_matrix((weights, dst, new_src), shape = (new_src.shape[0] - 1, new_src.shape[0] - 1))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant