question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Data transformation

See original GitHub issue

From now on, we recommend using our discussion forum (https://github.com/rusty1s/pytorch_geometric/discussions) for general questions.

❓ Questions & Help

I have the measured data saved in txt format and I want to use it to train the model. After processing, my Data object looks like following: Data(edge_attr=[1325], edge_index=[2, 1325], test_mask=[0], train_mask=[0], val_mask=[0], x=[919, 20], y=[919]) and this is directed graph:

print(graph_raw.is_undirected())
tensor(False)

But I want to make it undirected, so I apply transformation:

import torch_geometric.transforms as T
transf_to_und = T.ToUndirected()
transf_to_und(graph_raw)

out: Data(edge_attr=[1325], edge_index=[2, 2650], test_mask=[0], train_mask=[0], val_mask=[0], x=[919, 20], y=[919])

but when I check

print(graph_raw.is_undirected())

I receive an assertion error

AssertionError                            Traceback (most recent call last)
<ipython-input-131-0aa7e60ed235> in <module>
      2 transf_to_und = T.ToUndirected()
      3 transf_to_und(graph_raw)
----> 4 print(graph_raw.is_undirected())

~\anaconda3\lib\site-packages\torch_geometric\data\data.py in is_undirected(self)
    295     def is_undirected(self):
    296         r"""Returns :obj:`True`, if graph edges are undirected."""
--> 297         return is_undirected(self.edge_index, self.edge_attr, self.num_nodes)
    298 
    299     def is_directed(self):

~\anaconda3\lib\site-packages\torch_geometric\utils\undirected.py in is_undirected(edge_index, edge_attr, num_nodes)
     19     """
     20     num_nodes = maybe_num_nodes(edge_index, num_nodes)
---> 21     edge_index, edge_attr = coalesce(edge_index, edge_attr, num_nodes,
     22                                      num_nodes)
     23 

~\anaconda3\lib\site-packages\torch_sparse\coalesce.py in coalesce(index, value, m, n, op)
     20     """
     21 
---> 22     storage = SparseStorage(row=index[0], col=index[1], value=value,
     23                             sparse_sizes=(m, n), is_sorted=False)
     24     storage = storage.coalesce(reduce=op)

~\anaconda3\lib\site-packages\torch_sparse\storage.py in __init__(self, row, rowptr, col, value, sparse_sizes, rowcount, colptr, colcount, csr2csc, csc2csr, is_sorted)
     77         if value is not None:
     78             assert value.device == col.device
---> 79             assert value.size(0) == col.size(0)
     80             value = value.contiguous()
     81 

AssertionError: 

How could I solve this?

Thank you!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RostyslavUAcommented, May 29, 2021

It works, thank you!

0reactions
rusty1scommented, May 29, 2021

Can you install from master again? I pushed some changes that should resolve your issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is data transformation: definition, benefits, and uses | Stitch
Data transformation is the process of changing the format, structure, or values of data. For data analytics projects, data may be transformed at...
Read more >
What is Data Transformation? Definition, Types and Benefits
Data transformation is the process of converting data from one format, such as a database file, XML document or Excel spreadsheet, into another....
Read more >
What is Data Transformation? | TIBCO Software
Data transformation is the process of converting, cleansing, and structuring data into a usable format that can be analyzed to support decision making ......
Read more >
Data transformation (statistics) - Wikipedia
In statistics, data transformation is the application of a deterministic mathematical function to each point in a data set—that is, each data point...
Read more >
Data Transformation Explained: Definition, Types, & Benefits
Data transformation is the mutation of data characteristics to improve access or storage. Transformation may occur on the format, structure, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found