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.

FixedPoints: sampling with a single point also resamples y

See original GitHub issue

🐛 Bug

FixedPoints resamples also y if the pos-matrix contains only a single point.

It might be that this is intended behaviour - then don’t worry just close this issue. I can (and probably should) take care of samples with only one point anyways before learning

To Reproduce

import torch
from torch_geometric.data.data import Data
from torch_geometric.transforms.fixed_points import FixedPoints

pointcloud = Data(pos=torch.randn(100, 3), y=torch.tensor([1]))
single_point = Data(pos=torch.randn(1, 3), y=torch.tensor([1]))

random_select_n_points = FixedPoints(num=10)

print(random_select_n_points(pointcloud))
    # Data(pos=[10, 3], y=[1])
print(random_select_n_points(single_point))
    # Data(pos=[10, 3], y=[10])

Expected behavior

The second example should leave y=[1] and should not duplicate the values in y to the amount of fixed points.

print(random_select_n_points(single_point))

>>> Data(pos=[10, 3], y=[1])

Why does this happen and possible solution:

In fixed_points.py @ master, the following loop checks if the item is a tensor and if the item.size() is equal to the number of nodes.

After the number of nodes is in the given scenario equal to one, both conditions hold and y is subset by choice

for key, item in data:
    if bool(re.search('edge', key)):
        continue

    if torch.is_tensor(item) and item.size(0) == num_nodes:
        data[key] = item[choice]

An easy solution could be:

for key, item in data:
    if bool(re.search('edge', key)):
        continue

    if torch.is_tensor(item) and item.size(0) == num_nodes and item.size(0) != 1:
        data[key] = item[choice]

Which solves the described problem, but I do not know if there are any side-effects 😦

Environment

  • OS: Win10
  • Python version: 3.7.0
  • PyTorch version: 1.4.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rusty1scommented, Aug 27, 2020

You can install the latest PyG to test that as follows:

pip install git+https://github.com/rusty1s/pytorch_geometric.git
0reactions
rusty1scommented, Aug 27, 2020

Ok, I see. I do not think adding item.size(0) != 1 does any harm, so I added that functionality into master.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optional FixedPointSampling without Replacement · Issue #642
I think we should change this to a sampling strategy without replacement, and sample as long as we obtain the required number of...
Read more >
Fixed points & Periodicity · DynamicalSystems.jl
The signal sig is a vector of points uniformly sampled at a rate sr . Keyword arguments. w_len : size of the analysis...
Read more >
Performing Fixed-Point Arithmetic - MATLAB & Simulink
When doing arithmetic between a fi and one of the built-in integer data types, [u]int[8, 16, 32] , the word length and signedness...
Read more >
FIXED POINTS EM ALGORITHM AND NONNEGATIVE RANK ...
This mixture model is also known as the naive Bayes model. Its graphical representation is shown in Figure 1. A collection of i.i.d....
Read more >
An algorithm for estimating fixed points of dynamical systems ...
This paper presents an algorithm for estimating fixed points of dynamical systems from time series. In some cases the new procedure can accurately...
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