graph4nlp icon indicating copy to clipboard operation
graph4nlp copied to clipboard

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

Open smousav9 opened this issue 2 years ago • 1 comments

❓ 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.

smousav9 avatar Dec 07 '22 22:12 smousav9

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

hugochan avatar Dec 10 '22 08:12 hugochan