Coder Social home page Coder Social logo

pytorchgeometrictutorial's People

Contributors

antoniolonga avatar gabrielesantin avatar giannipele avatar htlee6 avatar tigerneil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytorchgeometrictutorial's Issues

Some questions I found in this tutorial

Hi, this is a nice tutorial. However, I find that there are some minor problems with the materials.

  1. I fond that they are same links so I think you can delete one.
    image
  2. In the node2vec practice colab notebook, the current installation requirement will lead the colab environment to break down. I tried this combination and it works:
    image
    Could you please figure out why? Thanks a lot!

Question about Tutorial16.ipynb

Hello, Thank you for the nice tutorial, it helps a lot to get started! I have a few questions concerning Tutorial16.ipynb: 1/ what is the effect of the parameter lin=True? 2/ what's the effect of changing the number of hidden and output channels? 3/ what is the purpose of l1, e1, l2, e2? Best, Claire

Some tutorials no longer work with Google Colab

Tutorial 14 and 15 both no longer work with colab and give this error after the second cell


OSError Traceback (most recent call last)
in ()
2 import os
3 import pandas as pd
----> 4 from torch_geometric.data import InMemoryDataset, Data, download_url, extract_zip
5 from torch_geometric.utils.convert import to_networkx
6 import networkx as nx

6 frames
/usr/lib/python3.7/ctypes/init.py in init(self, name, mode, handle, use_errno, use_last_error)
362
363 if handle is None:
--> 364 self._handle = _dlopen(self._name, mode)
365 else:
366 self._handle = handle

OSError: /usr/local/lib/python3.7/dist-packages/torch_sparse/_convert_cpu.so: undefined symbol: _ZNK2at6Tensor5zero_Ev

Tutorial 1 - Methods in class Net are missing arguments

Hi,

My background is in Knowledge Representation and Reasoning and I'm just a beginner in Deep Learning on Graphs, so apologies in advance if I say something against the (coding) conventions in this domain.

I started to go through the tutorials, converting each into a torch/geometric script (to get familiar with the engineering aspect), as well as a torch/geometric/lightning script.

I've noticed that the methods from the class "Net" of Tutorial 1 are missing all the parameters required to function.
Specifically, they are missing "dataset" (in __init__()) and "data" (in forward()).

The notebook works fine because "dataset" and "data" are defined in a cell above Net, therefore they are hardcoded.
I'm not sure sure if this was intended, since it might mislead learners.

As a result, I've changed your code as follows (including the changes discussed above and some cosmetic changes for readability):

import torch.nn as nn
import torch_geometric.nn as gnn


class Net(nn.Module):
    
    def __init__(self, num_features: int, num_classes: int):
        super(Net, self).__init__()
        
        assert num_features > 0, f"At least 1 feature required, {num_features} were given" 
        assert num_classes > 0, f"At least 1 class required, {num_classes} were given" 
        
        self.conv = gnn.SAGEConv(
            num_features,
            num_classes,
            aggr="max",  # max, mean, add ...
        )

    def forward(self, x, edge_index):
        x = self.conv(x, edge_index)
        x = F.log_softmax(x, dim=1)
        
        return x

Consequently, the model is instantiated as follows:

device = torch.device('cuda' if torch.cuda.is_available() and use_cuda_if_available else 'cpu')

model, data = Net(
    num_features=dataset.num_features, 
    num_classes=dataset.num_classes,
).to(device), data.to(device)

optimizer = torch.optim.Adam(model.parameters(), lr=0.01, weight_decay=5e-4)

And the train() and test() methods become as follows:

def train():
    model.train()
    optimizer.zero_grad()
    logits = model(data.x, data.edge_index)
    F.nll_loss(logits[data.train_mask], data.y[data.train_mask]).backward()
    optimizer.step()

def test():
    model.eval()
    logits, accs = model(data.x, data.edge_index), []
    for _, mask in data('train_mask', 'val_mask', 'test_mask'):
        pred = logits[mask].max(1)[1]
        acc = pred.eq(data.y[mask]).sum().item() / mask.sum().item()
        accs.append(acc)
    
    return accs

Let me know if I stand correct in my thoughts, or if I'm missing some crucial point because I'm not familiar with this domain.
Also please let me know if you find this feedback helpful, and I'll keep reporting other things that I notice in the tutorials.
Also please let me know if you'd be interested in the Torch Lightning examples as well (so far I've managed to do it, at least!).

Last but not least, please send my greetings to Trento and Val di Non that I miss deeply! 🥹 Ciao!

Tutorial 3 - redundant dropout

Hi

In the final GAT implementation:
We use two imported GATConv layers.
In the constructor, we initialize each one of them with a dropout of 0.6.
In the forward method, we apply additional dropout before each one of them.
What's the point in doing additional dropout?

DiffPool tutorial does not work

Thank you for making the videos and notebooks available! They are very nice and helpful.
I saw that the DiffPool model still does not work for the version that is uploaded here.
I was wondering if you already have the working model available?

Thank you in advance!

Adding Colab support for the tutorials

Thanks for your effort and great work!

I think, In order to make the tutorials more convenient for a wide audience it would be helpful to add a colab version of the notebooks with the special button, that redirects to the http://colab.research.google.com/.

All tutorials can be run in colab via adding the notebook from GitHub and adding the cell with the installation of the pytorch-geometric and all dependencies. But the version with native support would make it more convenient.

If train_test_split_edges is replaced by randomlinksplit

In tutorial 6 if we use the randomlinksplit how does train_pos_edge_index get handled later in the code?

Does this line become:
train_pos_edge_index = train_data.edge_index.to(device) ?

And how is the test function redefined? If we don't have pos edges nor neg edges, then can you describe what happens to the test function?

Turtorial 1 - Cora dataset: unable to understand the masks, and how their counts add up

Hi Antonio or anyone else,

I am trying to see what do the counts 140, 500, 1000 mean for train, val and test masks respectively.
torch.sum(data.train_mask), torch.sum(data.val_mask), torch.sum(data.test_mask), data

Gives me this result:

(tensor(140, device='cuda:0'),
 tensor(500, device='cuda:0'),
 tensor(1000, device='cuda:0'),
 Data(x=[2708, 1433], edge_index=[2, 10556], y=[2708], train_mask=[2708], val_mask=[2708], test_mask=[2708]))

Question 1: Does this imply, for train only 140 nodes are available whereas for val and test a lot more as per the split in this data? I am coming from non-GNN background therefore this caught my eye.
Question 2: The addition of 140+500+1000 = 1640, does not add upto 2708, should it not?

Tutorial 3 code

Hi,

Thanks for this great tutorials and videos. Really nice work.

I was wondering about the GATLayer class in the code of tutorial 3. Once the class is made, it is no longer used after the 'Use it' heading in the notebook. Instead, the GATConv from torch geometric is used directly. Then why was the GATLayer class made?

Thanks,
VR

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.