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

Could you please provide a simple example to use the NodeEmbeddingBasedRefinedGraphConstruction class? #587

Open
smousav9 opened this issue Dec 7, 2022 · 1 comment

Comments

@smousav9
Copy link

smousav9 commented Dec 7, 2022

❓ Questions and Help

I am trying to come up with a simple example of how to use the NodeEmbeddingBasedRefinedGraphConstruction class, but I am getting the following error. could you please let me know how to congif the class to make it work?

from graph4nlp.pytorch.modules.graph_construction.node_embedding_based_refined_graph_construction import NodeEmbeddingBasedRefinedGraphConstruction
raw_data = "James went to the corner-shop. And bought some eggs."
gl = NodeEmbeddingBasedRefinedGraphConstruction(alpha_fusion= 0.2, input_size=(len(raw_data)))
graphdata = gl.init_topology(raw_data, lower_case=True)
graph = gl.dynamic_topology(graphdata)

But here is the error that I get.

    152 def __repr__(self):
--> 153     return self._graph._get_batch_node_features()

File ~/.conda/envs/graph4nlp/lib/python3.10/site-packages/graph4nlp-0.5.5-py3.10.egg/graph4nlp/pytorch/data/data.py:930, in GraphData._get_batch_node_features(self, item)
    915 """
    916 Get the batched view of node feature tensors, i.e., tensors in (B, N, D) view
    917 
   (...)
    927     batch-view tensors, or just the specified tensor.
    928 """
    929 if not self._is_batch:
--> 930     raise Exception("Calling batch_node_features() method on a non-batch graph.")
    931 if item is None:
    932     batch_node_features = dict()

Exception: Calling batch_node_features() method on a non-batch graph.

Any working simple example is highly appreciated.

@hugochan
Copy link
Contributor

Hi @smousav9, thanks for your interest to the library! You can find one such example here.

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

2 participants