Skip to content

Commit

Permalink
Include benchmark in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nyLiao committed Jun 13, 2024
1 parent 243f541 commit 3c92769
Show file tree
Hide file tree
Showing 19 changed files with 375 additions and 121 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Benchmarking Spectral Graph Neural Networks

[![Docs](https://github.com/gdmnl/Spectral-GNN-Benchmark/workflows/Docs/badge.svg)](https://pages.github.com/gdmnl/Spectral-GNN-Benchmark/)
[![Docs](https://github.com/gdmnl/Spectral-GNN-Benchmark/actions/workflows/docs.yaml/badge.svg)](https://gdmnl.github.io/Spectral-GNN-Benchmark/)
[![LICENSE](https://img.shields.io/github/license/gdmnl/Spectral-GNN-Benchmark)](LICENSE)
[![Release](https://img.shields.io/github/v/release/gdmnl/Spectral-GNN-Benchmark?include_prereleases)](https://github.com/gdmnl/Spectral-GNN-Benchmark/releases)
[![Python](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fgdmnl%2FSpectral-GNN-Benchmark%2Fmain%2Fpyproject.toml)]()

`pyg_spectral` is a [PyTorch Geometric](https://pyg.org)-based framework for analyzing, implementing, and benchmarking spectral GNNs with effectiveness and efficiency evaluations.

Expand All @@ -13,6 +16,8 @@
---

[**Documentation**](https://gdmnl.github.io/Spectral-GNN-Benchmark/) | [**GitHub**](https://github.com/gdmnl/Spectral-GNN-Benchmark/)

- [Installation](#installation)
- [Reproduce Experiments](#reproduce-experiments)
- [Main Experiments](#main-experiments)
Expand Down
8 changes: 7 additions & 1 deletion benchmark/dataset_process/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
split_random,
even_quantile_labels,
get_iso_nodes_mapping
)
)

__all__ = [
'Yandex', 'LINKX', 'FB100',
'Filter',
'idx2mask', 'split_random', 'even_quantile_labels', 'get_iso_nodes_mapping'
]
14 changes: 7 additions & 7 deletions benchmark/dataset_process/linkx.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LINKX(InMemoryDataset):
paper: Large Scale Learning on Non-Homophilous Graphs: New Benchmarks and Strong Simple Methods
ref: https://github.com/CUAI/Non-Homophily-Large-Scale/
"""
dataset_drive_url = {
_dataset_drive_url = {
'snap-patents.mat' : '1ldh23TSY1PwXia6dU0MYcpyEgX-w3Hia',
'pokec.mat' : '1dNs5E7BrWJbgcHeQ_zuy5Ozp2tRCWG0y',
'yelp-chi.mat': '1fAXtTVQS4CfEk4asqrFw9EPmlUPGbGtJ',
Expand All @@ -32,7 +32,7 @@ class LINKX(InMemoryDataset):
'wiki_edges.pt': '14X7FlkjrlUgmnsYtPwdh-gGuFla4yb5u', # Wiki 1.9M
'wiki_features.pt': '1ySNspxbK-snNoAZM7oxiWGvOnTRdSyEK' # Wiki 1.9M
}
splits_drive_url = {
_splits_drive_url = {
'snap-patents_splits.npy' : '12xbBRqd8mtG_XkNLH8dRRNZJvVM4Pw-N',
'pokec_splits.npy' : '1ZhpAiyTNc0cE_hhgyiqxnkKREHK7MK-_',
}
Expand Down Expand Up @@ -76,12 +76,12 @@ def download(self) -> None:
download_url(f'{url}/{self.name}.mat', self.raw_dir)
return

for fname in self.dataset_drive_url:
for fname in self._dataset_drive_url:
if fname.startswith(self.name):
download_google_url(self.dataset_drive_url[fname], self.raw_dir, filename=fname)
for fname in self.splits_drive_url:
download_google_url(self._dataset_drive_url[fname], self.raw_dir, filename=fname)
for fname in self._splits_drive_url:
if fname.startswith(self.name):
download_google_url(self.splits_drive_url[fname], self.raw_dir, filename=fname)
download_google_url(self._splits_drive_url[fname], self.raw_dir, filename=fname)

def process(self) -> None:
if self.name in ['twitch-gamer']:
Expand Down Expand Up @@ -118,7 +118,7 @@ def process(self) -> None:
edge_index = coalesce(edge_index, num_nodes=n)
kwargs = {'x': x, 'edge_index': edge_index, 'y': y}

splits_keys = [k.split('_')[0] for k in self.splits_drive_url]
splits_keys = [k.split('_')[0] for k in self._splits_drive_url]
if self.name in splits_keys:
# 50/25/25 train/valid/test split
splits_lst = np.load(osp.join(self.raw_dir, f'{self.name}_splits.npy'), allow_pickle=True)
Expand Down
8 changes: 8 additions & 0 deletions benchmark/trainer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@
from .base import TrnBase_Trial
from .fullbatch import TrnFullbatch
from .minibatch import TrnMinibatch, TrnMinibatch_Trial

__all__ = [
'SingleGraphLoader', 'SingleGraphLoader_Trial',
'ModelLoader', 'ModelLoader_Trial',
'TrnBase_Trial',
'TrnFullbatch',
'TrnMinibatch', 'TrnMinibatch_Trial',
]
6 changes: 6 additions & 0 deletions benchmark/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@
force_list_str, force_list_int, list_str, list_int, list_float,)
from .logger import setup_logger, clear_logger, setup_logpath, ResLogger
from .checkpoint import CkptLogger

__all__ = [
'setup_seed', 'setup_argparse', 'setup_args', 'save_args', 'dict_to_json',
'setup_logger', 'clear_logger', 'setup_logpath', 'ResLogger',
'CkptLogger',
]
8 changes: 8 additions & 0 deletions docs/source/_include/benchmark.dataset_process.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
benchmark.dataset\_process
========================

Check warning on line 2 in docs/source/_include/benchmark.dataset_process.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

.. automodule:: benchmark.dataset_process
:members:
:undoc-members:
:show-inheritance:
:private-members:
53 changes: 53 additions & 0 deletions docs/source/_include/benchmark.trainer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
benchmark.trainer
===============

Check warning on line 2 in docs/source/_include/benchmark.trainer.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

.. automodule:: benchmark.trainer
:members:
:undoc-members:
:show-inheritance:
:private-members:

benchmark.trainer.base
-------------------

Check warning on line 11 in docs/source/_include/benchmark.trainer.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

.. automodule:: benchmark.trainer.base
:members:
:undoc-members:
:show-inheritance:
:private-members:

benchmark.trainer.filter
---------------------

Check warning on line 20 in docs/source/_include/benchmark.trainer.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

Check warning on line 20 in docs/source/_include/benchmark.trainer.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

.. automodule:: benchmark.trainer.filter
:members:
:undoc-members:
:show-inheritance:
:private-members:

benchmark.trainer.load\_data
-------------------------

Check warning on line 29 in docs/source/_include/benchmark.trainer.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

Check warning on line 29 in docs/source/_include/benchmark.trainer.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

.. automodule:: benchmark.trainer.load_data
:members:
:undoc-members:
:show-inheritance:
:private-members:

benchmark.trainer.load\_metric
---------------------------

Check warning on line 38 in docs/source/_include/benchmark.trainer.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

Check warning on line 38 in docs/source/_include/benchmark.trainer.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

.. automodule:: benchmark.trainer.load_metric
:members:
:undoc-members:
:show-inheritance:
:private-members:

benchmark.trainer.load\_model
--------------------------

Check warning on line 47 in docs/source/_include/benchmark.trainer.rst

View workflow job for this annotation

GitHub Actions / Docs

Title underline too short.

.. automodule:: benchmark.trainer.load_model
:members:
:undoc-members:
:show-inheritance:
:private-members:
21 changes: 21 additions & 0 deletions docs/source/_include/benchmark.utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
benchmark.utils
=============

.. automodule:: benchmark.utils
:members:
:undoc-members:
:show-inheritance:
:private-members:


benchmark.utils.config
-------------------

.. autosummary::
:recursive:

config.force_list_str
config.force_list_int
config.list_str
config.list_int
config.list_float
8 changes: 8 additions & 0 deletions docs/source/_templates/apidoc/module.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{%- if show_headings %}
{{- [basename] | join(' ') | e | heading }}

{% endif -%}
.. automodule:: {{ qualname }}
{%- for option in automodule_options %}
:{{ option }}:
{%- endfor %}
52 changes: 52 additions & 0 deletions docs/source/_templates/apidoc/package.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{%- macro automodule(modname, options) -%}
.. automodule:: {{ modname }}
{%- for option in options %}
:{{ option }}:
{%- endfor %}
{%- endmacro %}

{%- macro toctree(docnames) -%}
.. toctree::
{% for docname in docnames %}
{{ docname }}
{%- endfor %}
{%- endmacro %}

{%- if is_namespace %}
{{- [pkgname, "namespace"] | join(" ") | e | heading }}
{% else %}
{{- [pkgname] | join(" ") | e | heading }}
{% endif %}

{%- if modulefirst and not is_namespace %}
{{ automodule(pkgname, automodule_options) }}
{% endif %}

{%- if subpackages %}
Subpackages
-----------

{{ toctree(subpackages) }}
{% endif %}

{%- if submodules %}
Submodules
----------
{% if separatemodules %}
{{ toctree(submodules) }}
{%- else %}
{%- for submodule in submodules %}
{% if show_headings %}
{{- [submodule] | join(" ") | e | heading(2) }}
{% endif %}
{{ automodule(submodule, automodule_options) }}
{% endfor %}
{%- endif %}
{% endif %}

{%- if not modulefirst and not is_namespace %}
Module contents
---------------

{{ automodule(pkgname, automodule_options) }}
{% endif %}
7 changes: 7 additions & 0 deletions docs/source/_templates/apidoc/toc.rst_t
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ header | heading }}

.. toctree::
:maxdepth: {{ maxdepth }}
{% for docname in docnames %}
{{ docname }}
{%- endfor %}
36 changes: 17 additions & 19 deletions docs/source/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,25 @@
.. autoclass:: {{ objname }}

{% block methods %}
{% block attributes %}
{% if attributes %}
.. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
.. autosummary::
:toctree:
{% for item in all_attributes %}
{%- if not item.startswith('_') %}
{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
.. automethod:: __init__

{% if methods %}
.. rubric:: Methods

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% if methods %}
.. HACK -- the point here is that we don't want this to appear in the output, but the autosummary should still generate the pages.
.. autosummary::
:toctree:
{% for item in all_methods %}
{%- if not item.startswith('_') or item in ['__call__'] %}
{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% block attributes %}
{% if attributes %}
.. rubric:: Attributes

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
59 changes: 33 additions & 26 deletions docs/source/_templates/autosummary/module.rst
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
{{ fullname | escape | underline }}

.. rubric:: Description
{{ fullname | escape | underline}}

.. automodule:: {{ fullname }}

.. currentmodule:: {{ fullname }}

{% if classes %}
.. rubric:: Classes

.. autosummary::
:toctree: .
{% for class in classes %}
{{ class }}
{% endfor %}

{% endif %}

{% if functions %}
.. rubric:: Functions

.. autosummary::
:toctree: .
{% for function in functions %}
{{ function }}
{% endfor %}

{% endif %}
{% block functions %}
{% if functions %}
.. rubric:: Functions

.. autosummary::
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: Classes

.. autosummary::
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: Exceptions

.. autosummary::
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
4 changes: 4 additions & 0 deletions docs/source/arrangement.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Covered Models

Refer to {py:class}`benchmark.trainer.ModelLoader`.

| **Category** | **Model** |
|:------------:|:----------|
| Fixed Filter | [GCN](https://arxiv.org/abs/1609.02907), [SGC](https://arxiv.org/pdf/1902.07153), [gfNN](https://arxiv.org/pdf/1905.09550), [GZoom](https://arxiv.org/pdf/1910.02370), [S$^2$GC](https://openreview.net/pdf?id=CYO5T-YjWZV),[GLP](https://arxiv.org/pdf/1901.09993), [APPNP](https://arxiv.org/pdf/1810.05997), [GCNII](https://arxiv.org/pdf/2007.02133), [GDC](https://proceedings.neurips.cc/paper_files/paper/2019/file/23c894276a2c5a16470e6a31f4618d73-Paper.pdf), [DGC](https://arxiv.org/pdf/2102.10739), [AGP](https://arxiv.org/pdf/2106.03058), [GRAND+](https://arxiv.org/pdf/2203.06389)|
Expand All @@ -11,6 +13,8 @@

## Covered Datasets

Refer to {py:class}`benchmark.trainer.SingleGraphLoader`.

| **Source** | **Graph** |
|:------------:|:----------|
| [PyG](https://pytorch-geometric.readthedocs.io/en/stable/modules/datasets.html) | cora, citeseer, pubmed, flickr, actor |
Expand Down
Loading

0 comments on commit 3c92769

Please sign in to comment.