repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
glide-text2im | glide-text2im-main/glide_text2im/clip/attention.py | import math
from abc import ABC, abstractmethod
from itertools import product
from typing import Any, Optional
import attr
import numpy as np
import torch
@attr.s
class AttentionMask(ABC):
query_context_size: int = attr.ib(validator=lambda i, a, x: x >= 1) # type: ignore
key_context_size: int = attr.ib(vali... | 6,981 | 37.788889 | 120 | py |
glide-text2im | glide-text2im-main/glide_text2im/clip/encoders.py | import math
from collections import OrderedDict
from typing import List, Optional, Tuple, cast
import attr
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from .attention import (
AttentionInfo,
DenseAttentionMask,
DenseCausalAttentionMask,
make_full_layout,
t... | 16,282 | 31.696787 | 100 | py |
GammaGL | GammaGL-main/setup.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import os.path as osp
import platform
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext as _build_ext
# from pybind11.setup_helpers import Pybind11Extension, build_ext
from gammagl.utils.ggl_build_extension i... | 4,723 | 32.503546 | 108 | py |
GammaGL | GammaGL-main/examples/sign/sign_trainer.py | # import os
# os.environ['TL_BACKEND'] = 'torch'
# # os.environ['CUDA_VISIBLE_DEVICES'] = '0'
import argparse
import tensorlayerx as tlx
from tensorlayerx.model import TrainOneStep, WithLoss
from gammagl.datasets.flickr import Flickr
from gammagl.models.sign import SignModel
import gammagl.transforms as T
class Sem... | 3,416 | 38.732558 | 102 | py |
GammaGL | GammaGL-main/examples/dgi/dgi_trainer.py | import math
import os
# os.environ['TL_BACKEND'] = 'torch'
# os.environ['CUDA_VISIBLE_DEVICES'] = '5'
from gammagl.utils import add_self_loops, calc_gcn_norm, mask_to_index, remove_self_loops
import argparse
from tqdm import tqdm
from gammagl.datasets import Planetoid
import tensorlayerx as tlx
from tensorlayerx.mod... | 6,536 | 35.316667 | 107 | py |
GammaGL | GammaGL-main/examples/sgc/sgc_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : sgc_trainer.py
@Time : 2021/12/16 20:31:03
@Author : Han Hui
"""
import os
# os.environ['CUDA_VISIBLE_DEVICES']='0'
os.environ['TL_BACKEND'] = 'paddle'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in c... | 4,855 | 35.238806 | 109 | py |
GammaGL | GammaGL-main/examples/sampler/neighbor_sampler_gpu.py | from gammagl.utils import mask_to_index
from gammagl.datasets import Reddit
import argparse
from pyinstrument import Profiler
import scipy.sparse as sp
import numpy as np
from gammagl.gglspeedup.gpusample import GPUSampler
from gammagl.gglspeedup.gpufeature import CGPUFeature
import tensorflow as tf
dataset = Reddit('... | 2,400 | 32.816901 | 116 | py |
GammaGL | GammaGL-main/examples/compgcn/compgcn_trainer.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/11/8 23:47
# @Author : yijian
# @FileName: compgcn_trainer.py
import os
# os.environ['TL_BACKEND'] = 'mindspore' # set your backend here, default `torch`
# os.environ["CUDA_VISIBLE_DEVICES"] = ""
import sys
sys.path.insert(0, os.path.abspath('../../')... | 6,441 | 35.602273 | 107 | py |
GammaGL | GammaGL-main/examples/grace/grace_trainer.py | import os
# os.environ['TL_BACKEND'] = 'paddle'
# os.environ['CUDA_VISIBLE_DEVICES']=' '
# set your backend here, default 'tensorflow', you can choose 'paddle'、'tensorflow'、'torch'
from gammagl.utils import add_self_loops, calc_gcn_norm, mask_to_index
import argparse
from tqdm import tqdm
from gammagl.data import ... | 4,707 | 44.269231 | 119 | py |
GammaGL | GammaGL-main/examples/chebnet/chebnet_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : chebnet_trainer.py
@Time : 2022/5/14 11:05:55
@Author : Zhang Zhongjian
"""
import os
# os.environ['CUDA_VISIBLE_DEVICES']='0'
# os.environ['TL_BACKEND'] = 'paddle'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl ... | 5,229 | 35.573427 | 109 | py |
GammaGL | GammaGL-main/examples/deepwalk/deepwalk_trainer.py | import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
# os.environ['TL_BACKEND'] = 'tensorflow'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import argparse
import tensorlayerx as tlx
from gammagl.datasets import Planetoid
from gammagl.models import DeepWal... | 4,912 | 38.304 | 114 | py |
GammaGL | GammaGL-main/examples/mgnni/mgnni_trainner.py | import os
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
# os.environ['TL_BACKEND'] = 'torch'
# os.environ['TL_BACKEND'] = 'mindspore'
# os.environ['TL_BACKEND'] = 'paddle'
# os.environ['TL_BACKEND'] = 'tensorflow' # set your backend here, default `tensorflow`
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
import sys
sys.pat... | 7,998 | 37.090476 | 116 | py |
GammaGL | GammaGL-main/examples/mixhop/mixhop_trainer.py | import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
# os.environ['TL_BACKEND'] = 'tensorflow'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import argparse
import tensorlayerx as tlx
from gammagl.datasets import Planetoid
from gammagl.models import MIXHOPM... | 5,304 | 37.722628 | 109 | py |
GammaGL | GammaGL-main/examples/hardgat/hardgat_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : hardgat_trainer.py
@Time : 2022/10/26 11:05:55
@Author : Yue Dashuai
"""
import os
# os.environ['CUDA_VISIBLE_DEVICES']=''
# os.environ['TL_BACKEND'] = 'torch'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to ex... | 5,271 | 36.390071 | 104 | py |
GammaGL | GammaGL-main/examples/node2vec/node2vec_trainer.py | import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
# os.environ['TL_BACKEND'] = 'tensorflow'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import argparse
import tensorlayerx as tlx
from gammagl.datasets import Planetoid
from gammagl.models import Node2ve... | 5,096 | 38.511628 | 114 | py |
GammaGL | GammaGL-main/examples/hetero_rgcn/rgcn_trainer.py | import os
# os.environ['TL_BACKEND'] = 'torch' # set your backend here, default `tensorflow`
# os.environ["CUDA_VISIBLE_DEVICES"] = "1"
from gammagl.datasets.alircd import AliRCD
import argparse
import tensorlayerx as tlx
from gammagl.layers.conv import RGCNConv
from tensorlayerx.model import TrainOneStep, WithLoss
... | 12,117 | 41.819788 | 119 | py |
GammaGL | GammaGL-main/examples/iehgcn/iehgcn_trainer.py | import os
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
# os.environ['TL_BACKEND'] = 'torch'
# os.environ['TL_BACKEND'] = 'paddle'
# os.environ['TL_BACKEND'] = 'mindspore' # unsupported
import argparse
import tensorlayerx as tlx
from gammagl.utils import ad... | 8,932 | 40.548837 | 120 | py |
GammaGL | GammaGL-main/examples/vgae/vgae_trainer.py | import os
#os.environ['CUDA_VISIBLE_DEVICES']='1'
#os.environ['TL_BACKEND'] = 'paddle'
#os.environ['TL_BACKEND'] = 'torch'
import sys
import numpy as np
import scipy.sparse as sp
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import argparse
import tensorlayerx as tlx
... | 8,995 | 37.943723 | 134 | py |
GammaGL | GammaGL-main/examples/gatv2/gatv2_trainer.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/03/14 10:23
# @Author : hanhui
# @FileName: gatv2_trainer.py
import os
# os.environ['CUDA_VISIBLE_DEVICES']='1'
# os.environ['TL_BACKEND'] = 'paddle'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command li... | 4,927 | 35.776119 | 104 | py |
GammaGL | GammaGL-main/examples/gcnii/gcnii_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : gcnii_trainer.py
@Time : 2021/12/22 16:12:02
@Author : Han Hui
'''
import os
# os.environ['CUDA_VISIBLE_DEVICES']='0'
# os.environ['TL_BACKEND'] = 'paddle'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute ... | 5,720 | 38.455172 | 124 | py |
GammaGL | GammaGL-main/examples/jknet/jknet_trainer.py | # -*- coding: utf-8 -*-
"""
@File : jknet_trainer.py
@Time : 2022/4/10 11:16 A.M.
@Author : Jia Yiming
"""
import os
# os.environ['CUDA_VISIBLE_DEVICES']='0'
# os.environ['TL_BACKEND'] = 'torch'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import argpa... | 6,241 | 36.377246 | 125 | py |
GammaGL | GammaGL-main/examples/hcha/hcha_trainer.py | import os
# os.environ['CUDA_VISIBLE_DEVICES']='1'
# os.environ['TL_BACKEND'] = 'tensorflow'
import sys
# sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import argparse
import tensorlayerx as tlx
import numpy as np
from gammagl.datasets import Planetoid
from gammagl.utils ... | 6,241 | 39.270968 | 109 | py |
GammaGL | GammaGL-main/examples/dgcnn/dgcnn_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : dgcnn_trainer.py
@Time : 2022/8/16 0:32:45
@Author : Wang Xianglong
"""
import copy
import os
# os.environ['CUDA_VISIBLE_DEVICES']='0'
# os.environ['TL_BACKEND'] = 'paddle'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2... | 7,603 | 42.204545 | 130 | py |
GammaGL | GammaGL-main/examples/hgt/hgt_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : hgt_trainer.py
@Time : 2022/7/1 8:05:55
@Author : Zhang Zhongjian
"""
import os
# os.environ['CUDA_VISIBLE_DEVICES'] = ''
# os.environ['TL_BACKEND'] = 'tensorflow' # set your backend here, default `tensorflow`
import sys
sys.path.insert(0, os... | 6,624 | 39.895062 | 106 | py |
GammaGL | GammaGL-main/examples/fagcn/fagcn_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : fagcn_trainer.py
@Time : 2022/5/10 10:55
@Author : Ma Zeyao
"""
import os
# os.environ['TL_BACKEND'] = 'torch'
# os.environ["CUDA_VISIBLE_DEVICES"] = "5"
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute i... | 5,118 | 36.094203 | 109 | py |
GammaGL | GammaGL-main/examples/simplehgn/simplehgn_trainer.py | import argparse
import os
import sys
os.environ['TL_BACKEND'] = 'tensorflow'
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
sys.path.insert(0, os.path.abspath('./')) # adds path2gammagl to execute in command line.
import tensorlayerx as tlx
from sklearn.metrics import f1_s... | 7,733 | 43.965116 | 123 | py |
GammaGL | GammaGL-main/examples/grade/aug.py | import tensorlayerx as tlx
from gammagl.utils.corrupt_graph import drop_feature, add_self_loops, mask_edge
from gammagl.data import Graph
import numpy as np
def get_sim(z1, z2):
'''
Compute the similarity matix
'''
z1 = tlx.ops.l2_normalize(z1, axis=1)
z2 = tlx.ops.l2_normalize(z2, axis=1)
ret... | 6,003 | 42.194245 | 116 | py |
GammaGL | GammaGL-main/examples/grade/grade_trainer.py | import os
# os.environ['TL_BACKEND'] = 'torch'
# os.environ['CUDA_VISIBLE_DEVICES']=' '
# set your backend here, default 'tensorflow', you can choose 'paddle'、'tensorflow'、'torch'
import tensorlayerx as tlx
import argparse
from gammagl.models.grade import GRADE
from aug import degree_aug
from utils import load, linear... | 4,738 | 45.460784 | 121 | py |
GammaGL | GammaGL-main/examples/tadw/tadw_trainer.py | import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
# os.environ['TL_BACKEND'] = 'tensorflow'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import argparse
import tensorlayerx as tlx
from gammagl.datasets import Planetoid
from gammagl.models import TADWModel... | 3,379 | 36.977528 | 111 | py |
GammaGL | GammaGL-main/examples/graphgan/graphgan_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
# os.environ['TL_BACKEND'] = 'paddle'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
from gammagl.models import GraphGAN
from gammagl.utils import read_embed... | 17,974 | 39.122768 | 107 | py |
GammaGL | GammaGL-main/examples/gaan/GaAN_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : GaAN_trainer.py
@Time : 2023/02/26 11:28:45
@Author : yunhe
"""
from tensorlayerx.model import TrainOneStep, WithLoss
from gammagl.utils import add_self_loops, mask_to_index
from gammagl.models import GaANModel
from gammagl.datasets import Plane... | 5,470 | 34.296774 | 104 | py |
GammaGL | GammaGL-main/examples/infograph/infograph_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : infograph_trainer.py
@Time : 2022/05/24 22:05:55
@Author : Yang Yuxiang
"""
import os
# os.environ['TL_BACKEND'] = 'paddle'
# os.environ['CUDA_VISIBLE_DEVICES'] = ' '
# set your backend here, default `tensorflow`, you can choose 'paddle'、'tensor... | 3,976 | 39.171717 | 114 | py |
GammaGL | GammaGL-main/examples/merit/merit_trainer.py | from cProfile import label
import numpy as np
import scipy.sparse as sp
import argparse
import os
# os.environ['TL_BACKEND'] = 'tensorflow
# os.environ["CUDA_VISIBLE_DEVICES"] = " "
# set your backend here, default `tensorflow`, you can choose 'paddle'、'tensorflow'、'torch'
import sys
sys.path.append(os.getcwd())
imp... | 6,343 | 42.751724 | 121 | py |
GammaGL | GammaGL-main/examples/seal/test.py | import os
import math
import warnings
warnings.filterwarnings('ignore')
os.environ['TL_BACKEND']='torch'
import tensorlayerx as tlx
from sklearn.metrics import roc_auc_score
import numpy as np
from gammagl.datasets import Planetoid
from gammagl.loader import DataLoader
from gammagl.layers.conv import GCNConv
from gam... | 4,231 | 31.806202 | 92 | py |
GammaGL | GammaGL-main/examples/agnn/agnn_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : agnn_trainer.py
@Time :
@Author : shanyuxuan
"""
import os
# os.environ['CUDA_VISIBLE_DEVICES']='1'
# os.environ['TL_BACKEND'] = 'torch'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
sy... | 5,169 | 34.655172 | 170 | py |
GammaGL | GammaGL-main/examples/gmm/gmm_trainer.py | import os
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
# os.environ['TL_BACKEND'] = 'torch'
# os.environ['TL_BACKEND'] = 'paddle'
# os.environ['TL_BACKEND'] = 'mindspore'
import argparse
import tensorlayerx as tlx
from gammagl.datasets import Planetoid
from g... | 5,421 | 38.007194 | 108 | py |
GammaGL | GammaGL-main/examples/gpu_sage/bug_file/pd_bug.py | import cupy as cp
def test1():
print("using paddle")
from paddle.utils.dlpack import from_dlpack
for i in range(100):
a = cp.random.random((1024*128, 1024), dtype=cp.float32)
b = from_dlpack(a.toDlpack())
print(i)
def test0():
for i in range(100):
a = cp.random.random((1... | 561 | 28.578947 | 64 | py |
GammaGL | GammaGL-main/examples/gat/gat_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : gat_trainer.py
@Time : 2021/11/11 15:57:45
@Author : hanhui
"""
import os
# os.environ['CUDA_VISIBLE_DEVICES']='1'
# os.environ['TL_BACKEND'] = 'torch'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in c... | 5,092 | 36.175182 | 104 | py |
GammaGL | GammaGL-main/examples/metapath2vec/metapath2vec_trainer_aminer.py | import argparse
import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '4'
# os.environ['TL_BACKEND'] = 'tensorflow'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import os.path as osp
import tensorlayerx as tlx
from gammagl.datasets import AMiner
from gammagl.m... | 7,248 | 42.407186 | 119 | py |
GammaGL | GammaGL-main/examples/metapath2vec/metapath2vec_trainer_imdb_dblp.py | import argparse
import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
# os.environ['TL_BACKEND'] = 'tensorflow'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import os.path as osp
import tensorlayerx as tlx
from gammagl.datasets import IMDB, DBLP
from gamma... | 6,973 | 40.023529 | 115 | py |
GammaGL | GammaGL-main/examples/magcl/magcl_trainer.py | import os
# os.environ['TL_BACKEND'] = 'tensorflow'
# os.environ['CUDA_VISIBLE_DEVICES'] = '1'
# set your backend here, default 'tensorflow', you can choose 'paddle'、'tensorflow'、'torch'
import argparse
from sklearn.metrics import accuracy_score
import tensorlayerx as tlx
from tensorlayerx.model import TrainOneStep, W... | 5,056 | 44.972727 | 110 | py |
GammaGL | GammaGL-main/examples/graphsage/train_full.py | import os
# os.environ['TL_BACKEND'] = 'paddle'
# os.environ['CUDA_VISIBLE_DEVICES'] = ' '
from gammagl.models.graphsage import GraphSAGE_Full_Model
import argparse
import tensorlayerx as tlx
from gammagl.datasets import Planetoid
from tensorlayerx.model import TrainOneStep, WithLoss
from gammagl.utils import mask_t... | 4,671 | 35.217054 | 113 | py |
GammaGL | GammaGL-main/examples/graphsage/reddit_sage.py | # -*- coding: utf-8 -*-
# @author WuJing
# @created 2023/4/18
from gammagl.utils import mask_to_index
from tensorlayerx.model import WithLoss, TrainOneStep
from tqdm import tqdm
from gammagl.datasets import Reddit
import tensorlayerx as tlx
import argparse
from gammagl.loader.neighbor_sampler import NeighborSampler
f... | 4,980 | 39.169355 | 106 | py |
GammaGL | GammaGL-main/examples/herec/herec_trainer_aminer.py | import argparse
import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '0'
# os.environ['TL_BACKEND'] = 'tensorflow'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import os.path as osp
import tensorlayerx as tlx
from gammagl.datasets import AMiner
from gammagl.m... | 7,232 | 42.053571 | 119 | py |
GammaGL | GammaGL-main/examples/herec/herec_trainer_imdb_dblp.py | import argparse
import os
# os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
# os.environ['TL_BACKEND'] = 'tensorflow'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import os.path as osp
import tensorlayerx as tlx
from gammagl.datasets import IMDB, DBLP
from gamm... | 6,953 | 39.430233 | 115 | py |
GammaGL | GammaGL-main/examples/appnp/appnp_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : appnp_trainer.py
@Time : 2022/03/17 10:57:58
@Author : Han Hui
'''
import os
# os.environ['CUDA_VISIBLE_DEVICES']='0'
# os.environ['TL_BACKEND'] = 'paddle'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute ... | 5,279 | 36.446809 | 109 | py |
GammaGL | GammaGL-main/examples/dropedge/dropedge_trainer.py |
import os
#os.environ['CUDA_VISIBLE_DEVICES']='5'
#os.environ['TL_BACKEND'] = 'tensorflow'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in command line.
import argparse
import tensorlayerx as tlx
from gammagl.datasets import Planetoid
from gammagl.models import GCNModel
from... | 5,806 | 38.236486 | 109 | py |
GammaGL | GammaGL-main/examples/gcn/gcn_trainer.py | # !/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : gcn_trainer.py
@Time : 2021/11/02 22:05:55
@Author : hanhui
"""
import os
# os.environ['CUDA_VISIBLE_DEVICES']='1'
# os.environ['TL_BACKEND'] = 'paddle'
import sys
sys.path.insert(0, os.path.abspath('../../')) # adds path2gammagl to execute in ... | 5,235 | 36.4 | 104 | py |
GammaGL | GammaGL-main/examples/mvgrl/node/mvgrl_trainer.py | import os
# os.environ['TL_BACKEND'] = 'paddle'
# os.environ['CUDA_VISIBLE_DEVICES'] = ' '
# # set your backend here, default `tensorflow`
import argparse
import tensorlayerx as tlx
import numpy as np
from tensorlayerx.model import TrainOneStep, WithLoss
from preprocess import process_dataset
from gammagl.models.mvg... | 4,922 | 36.015038 | 110 | py |
GammaGL | GammaGL-main/examples/rgcn/rgcn_trainer.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/04/20 13:47
# @Author : hanhui
# @FileName: trainer.py.py
import os
os.environ['TL_BACKEND'] = 'tensorflow' # set your backend here, default `tensorflow`
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
import sys
sys.path.insert(0, os.path.abspath('../../'... | 9,520 | 35.903101 | 115 | py |
GammaGL | GammaGL-main/gammagl/typing.py |
from typing import List, Optional, Tuple, Union
# from torch import Tensor
# from torch_sparse import SparseTensor
# Types for accessing data ####################################################
# Node-types are denoted by a single string, e.g.: `data['paper']`:
NodeType = str
# Edge-types are denotes by a triplet... | 1,232 | 33.25 | 79 | py |
GammaGL | GammaGL-main/gammagl/sparse/saint.py | # -*- coding: utf-8 -*-
# @author WuJing
# @created 2023/4/4
from typing import Tuple
import tensorlayerx as tlx
import gammagl
from gammagl.sparse import SparseGraph
def saint_subgraph(src: SparseGraph, node_idx) -> Tuple:
row, col, value = src.coo()
rowptr = src.storage.rowptr()
# data = torch.ops.torc... | 803 | 27.714286 | 78 | py |
GammaGL | GammaGL-main/gammagl/sparse/rw.py | # -*- coding: utf-8 -*-
# @author WuJing
# @created 2023/4/5
import gammagl
from gammagl.sparse import SparseGraph
def random_walk(src: SparseGraph, start,
walk_length: int):
rowptr, col, _ = src.csr()
# return torch.ops.torch_sparse.random_walk(rowptr, col, start, walk_length)
return gam... | 421 | 23.823529 | 80 | py |
GammaGL | GammaGL-main/gammagl/io/tu.py | import glob
import os
import os.path as osp
import numpy as np
import tensorlayerx as tlx
from gammagl.io import read_txt_array
from gammagl.data import Graph
from gammagl.utils import coalesce, remove_self_loops
names = [
'A', 'graph_indicator', 'node_labels', 'node_attributes'
'edge_labels', 'edge_attributes', 'g... | 4,247 | 34.107438 | 88 | py |
GammaGL | GammaGL-main/gammagl/models/mvgrl.py | import math
import tensorlayerx as tlx
from gammagl.layers.conv import GCNConv
from gammagl.utils import add_self_loops, calc_gcn_norm
from gammagl.utils.tu_utils import local_global_loss_
# ======================= Graph Model================================
class MLP(tlx.nn.Module):
def __init__(self, in_dim, ... | 8,039 | 35.053812 | 116 | py |
GammaGL | GammaGL-main/gammagl/models/graphsage.py | import tensorlayerx as tlx
from typing import Tuple, List
from gammagl.layers.conv import SAGEConv
class GraphSAGE_Full_Model(tlx.nn.Module):
def __init__(self, in_feats,
n_hidden,
n_classes,
n_layers,
activation,
dropout,
... | 3,847 | 36.72549 | 111 | py |
GammaGL | GammaGL-main/gammagl/models/gen.py | import numpy as np
import tensorlayerx as tlx
from collections import Counter
from scipy.sparse import coo_matrix
from gammagl.utils import homophily, mask_to_index
class GEstimationN():
"""
Provide adjacency matrix estimation implementation based on the Expectation-Maximization(EM) algorithm.
Parameters
--------... | 4,242 | 27.286667 | 113 | py |
GammaGL | GammaGL-main/gammagl/models/graphgan_generator.py | import tensorlayerx as tlx
class Generator(tlx.nn.Module):
r"""The generator of GraphGAN Model operator from the `"GraphGAN: Graph Representation Learning with Generative Adversarial Nets"
<https://arxiv.org/pdf/1711.08267.pdf>`_ paper
Compute the gradient of :math:`V(G,D)` with respect to :math:`\Theta _... | 3,620 | 42.107143 | 152 | py |
GammaGL | GammaGL-main/gammagl/models/gat.py | import os
os.environ['TL_BACKEND'] = 'torch'
import tensorlayerx as tlx
from gammagl.layers.conv import GATConv
from tensorlayerx.nn import ModuleList
class GATModel(tlx.nn.Module):
r"""The graph attentional operator from the `"Graph Attention Networks"
<https://arxiv.org/abs/1710.10903>`_ paper
Parameter... | 2,293 | 31.771429 | 75 | py |
GammaGL | GammaGL-main/gammagl/datasets/shapenet.py | import json
import os
import os.path as osp
import shutil
import tensorlayerx as tlx
from gammagl.data import (
Graph,
InMemoryDataset,
download_url,
extract_zip,
)
from gammagl.io import read_txt_array
class ShapeNet(InMemoryDataset):
r"""The ShapeNet part level segmentation dataset from the `"... | 7,581 | 37.48731 | 79 | py |
GammaGL | GammaGL-main/gammagl/layers/conv/gin_conv.py | import tensorlayerx as tlx
from gammagl.layers.conv import MessagePassing
class GINConv(MessagePassing):
r"""The graph isomorphism operator from the `"How Powerful are
Graph Neural Networks?" <https://arxiv.org/abs/1810.00826>`_ paper
.. math::
\mathbf{x}^{\prime}_i = h_{\mathbf{\Theta}} \left( (... | 2,506 | 35.867647 | 86 | py |
GammaGL | GammaGL-main/gammagl/layers/conv/film_conv.py | import tensorlayerx as tlx
from tensorlayerx.nn import Linear
from gammagl.layers.conv.message_passing import MessagePassing
class FILMConv(MessagePassing):
r"""The FiLM graph convolutional operator from the
`"GNN-FiLM: Graph Neural Networks with Feature-wise Linear Modulation"
<https://arxiv.org/abs/1906... | 3,221 | 36.905882 | 119 | py |
GammaGL | GammaGL-main/gammagl/layers/conv/rgcn_conv.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/04/10 11:57
# @Author : clear
# @FileName: rgcn_conv.py.py
import tensorlayerx as tlx
from gammagl.layers.conv import MessagePassing
def masked_edge_index(edge_index, edge_mask):
if tlx.BACKEND == 'mindspore':
idx = tlx.convert_to_tensor(... | 7,384 | 41.687861 | 101 | py |
GammaGL | GammaGL-main/gammagl/layers/conv/gmm_conv.py | import os
import tensorlayerx as tlx
from gammagl.layers.conv import MessagePassing
from gammagl.utils import add_self_loops
class GMMConv(MessagePassing):
r"""The Gaussian Mixture Model Convolution or MoNet operator from the `"Geometric deep learning on graphs
and manifolds using mixture model CNNs" <htt... | 4,695 | 39.136752 | 117 | py |
GammaGL | GammaGL-main/gammagl/layers/conv/message_passing.py | import tensorlayerx as tlx
from gammagl.mpops import *
from gammagl.utils import Inspector
class MessagePassing(tlx.nn.Module):
r"""Base class for creating message passing layers of the form
.. math::
\mathbf{x}_i^{\prime} = \gamma_{\mathbf{\Theta}} \left( \mathbf{x}_i,
\square_{j \in \mathca... | 4,505 | 32.879699 | 90 | py |
GammaGL | GammaGL-main/gammagl/loader/link_neighbor_loader.py | # -*- coding: utf-8 -*-
# @author WuJing
# @created 2023/3/2
from typing import List
from gammagl.loader.link_loader import LinkLoader
from gammagl.sampler.neighbor_sampler import NeighborSampler
class LinkNeighborLoader(LinkLoader):
r"""A link-based graph loader derived as an extension of the node-based
:cl... | 7,351 | 47.688742 | 115 | py |
GammaGL | GammaGL-main/gammagl/loader/graph_saint.py | # -*- coding: utf-8 -*-
# @author WuJing
# @created 2023/4/3
import tensorlayerx as tlx
from tensorlayerx.dataflow import DataLoader
from gammagl.data import Graph
from gammagl.loader.utils import get_input_nodes_index
from gammagl.sparse.graph import SparseGraph
from gammagl.ops import unique
import numpy as np
cl... | 2,921 | 32.976744 | 115 | py |
GammaGL | GammaGL-main/gammagl/loader/hetero_sampler.py | from collections.abc import Sequence
import copy
from typing import Any, Callable, Dict, Iterator, List, Optional, Union
from gammagl.data import HeteroGraph
from gammagl.data.storage import EdgeStorage, NodeStorage
import tensorlayerx as tlx
import numpy as np
from gammagl.typing import EdgeType
from gammagl.sample i... | 14,797 | 38.251989 | 115 | py |
GammaGL | GammaGL-main/gammagl/loader/dataloader.py | from collections.abc import Mapping, Sequence
from typing import List, Optional, Union
# import torch.utils.data
# from torch.utils.data.dataloader import default_collate
from gammagl.data import BatchGraph, Graph, Dataset
import tensorlayerx as tlx
class Collater:
def __init__(self, follow_batch, exclude_keys)... | 3,100 | 33.076923 | 77 | py |
GammaGL | GammaGL-main/gammagl/utils/ggl_build_extension.py | # -*- coding: utf-8 -*-
# @author WuJing
# @created 2023/5/22
import copy
import glob
import os
import os.path as osp
import re
import subprocess
import sys
from typing import Optional, List
import setuptools
from pybind11.setup_helpers import Pybind11Extension
from setuptools.command.build_ext import build_ext
IS_WI... | 15,476 | 36.933824 | 119 | py |
GammaGL | GammaGL-main/gammagl/utils/norm.py | import tensorlayerx as tlx
from gammagl.mpops import *
def calc_gcn_norm(edge_index, num_nodes, edge_weight=None):
"""
calculate GCN Normalization.
Parameters
----------
edge_index:
edge index
num_nodes:
number of nodes of graph
edge_weight:
edge weights of ... | 825 | 27.482759 | 117 | py |
GammaGL | GammaGL-main/gammagl/utils/loop.py | from typing import Optional, Tuple, Union
import tensorlayerx as tlx
import numpy as np
from gammagl.utils.check import check_is_numpy
from .num_nodes import maybe_num_nodes
def contains_self_loops(edge_index) -> bool:
r"""Returns :obj:`True` if the graph given by :attr:`edge_index` contains
self-loops.
... | 5,073 | 38.030769 | 104 | py |
GammaGL | GammaGL-main/gammagl/utils/typing.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/05/18 21:26
# @Author : clear
# @FileName: typing.py
import inspect
import re
from collections import OrderedDict
from itertools import product
from typing import Callable, Dict, List, Tuple
import pyparsing as pp
def split_types_repr(types_repr: st... | 3,864 | 32.318966 | 79 | py |
GammaGL | GammaGL-main/gammagl/utils/tu_utils.py | import math
import numpy as np
import tensorlayerx as tlx
from sklearn.svm import LinearSVC
from sklearn.metrics import accuracy_score
from sklearn.model_selection import GridSearchCV, StratifiedKFold
"=========== loss cal fnc =================="
def linearsvc(embeds, labels):
x = embeds.numpy()
y = labels.n... | 2,982 | 29.438776 | 106 | py |
GammaGL | GammaGL-main/gammagl/utils/data_utils.py | # coding=utf-8
import tensorflow as tf
import pickle
def download_file(path, url_or_urls):
if not isinstance(url_or_urls, list):
urls = [url_or_urls]
else:
urls = url_or_urls
last_except = None
for url in urls:
try:
return tf.keras.utils.get_file(path, origin=url)... | 668 | 18.676471 | 60 | py |
GammaGL | GammaGL-main/gammagl/utils/get_laplacian.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/05/15 15:03
# @Author : clear
# @FileName: get_laplacian.py
import tensorlayerx as tlx
from gammagl.mpops import *
from gammagl.utils.loop import add_self_loops
def get_laplacian(edge_index, num_nodes, edge_weight=None, normalization=None):
"""
... | 2,255 | 34.25 | 104 | py |
GammaGL | GammaGL-main/gammagl/utils/degree.py | from typing import Optional
import tensorlayerx as tlx
from .num_nodes import maybe_num_nodes
def degree(index, num_nodes: Optional[int] = None, dtype=None):
r"""Computes the (unweighted) degree of a given one-dimensional index
tensor.
Args:
index (LongTensor): Index tensor.
num_nodes (int, optional): The ... | 755 | 26 | 70 | py |
GammaGL | GammaGL-main/gammagl/data/in_memory_dataset.py | import copy
from collections.abc import Mapping,Sequence
from typing import Callable, Dict, Iterable, List, Optional, Tuple, Union
from gammagl.data import Graph
from gammagl.data.collate import collate
from gammagl.data.dataset import Dataset, IndexType
from gammagl.data.separate import separate
import tensorlayerx a... | 5,257 | 35.013699 | 144 | py |
GammaGL | GammaGL-main/gammagl/data/storage.py | import copy
import warnings
import weakref
from collections import namedtuple
from collections.abc import Mapping, MutableMapping, Sequence
from typing import (Any, Callable, Dict, Iterable, List, NamedTuple, Optional,
Tuple, Union)
import numpy as np
import tensorlayerx as tlx
from gammagl.data.view import Items... | 17,010 | 32.48622 | 91 | py |
GammaGL | GammaGL-main/gammagl/data/batch.py | import inspect
from collections.abc import Sequence
from typing import Any, List, Optional, Union
import numpy as np
import tensorlayerx as tlx
from gammagl.data import Graph
from gammagl.data.collate import collate
from gammagl.data.dataset import IndexType
from gammagl.data.separate import separate
class DynamicIn... | 7,122 | 39.242938 | 114 | py |
GammaGL | GammaGL-main/gammagl/data/dataset.py | import copy
import json
import os
import os.path as osp
import re
import shutil
import sys
import warnings
from collections.abc import Sequence
from typing import Any, Callable, List, Optional, Tuple, Union
import numpy as np
import tensorlayerx as tlx
from tensorlayerx.dataflow import Dataset
from gammagl.data import... | 16,823 | 37.764977 | 129 | py |
GammaGL | GammaGL-main/gammagl/data/graph.py | import warnings
import copy
import numpy as np
import tensorlayerx as tlx
from collections.abc import Mapping, Sequence
from typing import (
Any,
Callable,
Dict,
Iterable,
List,
NamedTuple,
Optional,
Tuple,
Union
)
from gammagl.data.storage import (
BaseStorage,
EdgeStorage,... | 37,465 | 35.623656 | 134 | py |
GammaGL | GammaGL-main/gammagl/data/collate.py | from collections import defaultdict
from collections.abc import Mapping, Sequence
from typing import Any, List, Optional, Tuple, Union
import numpy as np
import tensorlayerx as tlx
from gammagl.data import BaseGraph
from gammagl.data.storage import BaseStorage, NodeStorage
from gammagl.utils.check import check_is_numpy... | 9,803 | 39.180328 | 124 | py |
GammaGL | GammaGL-main/gammagl/data/heterograph.py | import copy
import re
from collections import defaultdict, namedtuple
from collections.abc import Mapping
from itertools import chain
from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Union
import numpy as np
import scipy
import tensorlayerx as tlx
from gammagl.data.graph import BaseGraph, Graph, size_r... | 24,884 | 39.008039 | 110 | py |
GammaGL | GammaGL-main/gammagl/mpops/torch.py | import torch
use_ext = False
try:
import torch_operator
use_ext = True
except:
pass
def unsorted_segment_sum(x, segment_ids, num_segments=None):
assert x.shape[0] == segment_ids.shape[0], "the length of segment_ids should be equal to data.shape[0]."
if num_segments is None:
num_segments ... | 3,378 | 35.333333 | 108 | py |
GammaGL | GammaGL-main/gammagl/mpops/__init__.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/04/16 08:31
# @Author : clear
# @FileName: __init__.py
import os
if 'TL_BACKEND' in os.environ:
if os.environ['TL_BACKEND'] == 'tensorflow':
from .tensorflow import *
elif os.environ['TL_BACKEND'] == 'mindspore':
from .mindspo... | 600 | 21.259259 | 66 | py |
GammaGL | GammaGL-main/gammagl/mpops/torch_ext/setup.py | from numpy import source
import torch
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CppExtension
cuda_macro = ('COMPILE_WITH_CUDA', None)
# omp_macro = ('COMPILE_WITH_OMP', None) # Note: OpenMP needs gcc>4.2.0
# compile_args = {
# 'cxx':['-fopenmp']
# }
def ge... | 1,944 | 28.923077 | 81 | py |
GammaGL | GammaGL-main/gammagl/gglspeedup/gpusample.py | import CURandRTC as rndrtc
import cupy as cp
import ThrustRTC as trtc
from .cupy_and_thrust_code.kernels import *
class GPUSampler:
def __init__(self,
device: int, csr):
self.csr = csr
self.device = device
with cp.cuda.Device(device):
self.indptr = cp.array... | 4,659 | 44.686275 | 118 | py |
GammaGL | GammaGL-main/gammagl/gglspeedup/multifeat.py | import cupy as cp
from typing import List
import numpy as np
from .sharedfeat import CGPU_feat
from .utils import parse_size, reindex_feature
class Multi_CGPUFeature(object):
def __init__(self,
rank: int,
device_list: List[int],
device_cache_size, csr=None
... | 4,370 | 32.883721 | 159 | py |
GammaGL | GammaGL-main/gammagl/gglspeedup/sharedfeat.py |
from numba import cuda
import cupy as cp
import numpy as np
# 获取feat的kernel,不能直接切片,直接切片速度会非常感人
@cuda.jit(device=True)
def get_single_feat(out_feat, feat, dim):
for i in range(dim):
out_feat[i] = feat[i]
@cuda.jit()
def get_feat(map_feat, torch_feat, all_nodes, out_feat, ind, ed):
tx = cuda.blockDim... | 4,436 | 34.782258 | 123 | py |
GammaGL | GammaGL-main/gammagl/gglspeedup/multigpusample.py | from typing import List
import cupy as cp
import scipy.sparse as sp
import numpy as np
import time
import ThrustRTC as trtc
import CURandRTC as rndrtc
from dataclasses import dataclass
import cupy as cp
from .cupy_and_thrust_code.kernels import *
@dataclass(frozen=True)
class _FakeDevice(object):
pass
class ... | 5,494 | 38.818841 | 118 | py |
GammaGL | GammaGL-main/gammagl/gglspeedup/cupy_and_thrust_code/kernels.py | import ThrustRTC as trtc
import cupy as cp
perprocess0 = trtc.For(['dst_th', 'indptr_th', 'out_th', 'outdegs_th', 'sample_number'], 'idx',
'''
outdegs_th[idx] = indptr_th[dst_th[idx] + 1] - indptr_th[dst_th[idx]];
if (indptr_th[dst_th[idx] +... | 6,505 | 29.401869 | 123 | py |
GammaGL | GammaGL-main/gammagl/transforms/random_link_split.py | import warnings
from copy import copy
from typing import List, Optional, Union
import tensorlayerx as tlx
import numpy as np
from gammagl.data import Graph, HeteroGraph
from gammagl.transforms import BaseTransform
from gammagl.typing import EdgeType
from gammagl.utils import negative_sampling
class RandomLinkSplit(... | 13,775 | 43.29582 | 120 | py |
GammaGL | GammaGL-main/tests/layers/conv/test_han_conv.py | import tensorlayerx as tlx
import numpy as np
import pytest
from gammagl.layers.conv import HANConv
def test_han_conv():
x_dict = {
'author': tlx.random_normal((6, 16), dtype = tlx.float32),
'paper': tlx.random_normal((5, 12), dtype = tlx.float32)
}
edge1 = tlx.convert_to_tensor([[2, 0, 2... | 2,777 | 38.126761 | 81 | py |
GammaGL | GammaGL-main/tests/layers/conv/test_gcn_conv.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/05/12 16:18
# @Author : clear
# @FileName: test_gcn_conv.py
import numpy as np
import tensorlayerx as tlx
import scipy.sparse as sp
from gammagl.layers.conv import GCNConv
def AXWb(A, X, W, b):
X = tlx.matmul(X, W)
Y = tlx.matmul(A, X)
re... | 1,613 | 29.45283 | 80 | py |
GammaGL | GammaGL-main/tests/layers/conv/test_sage_conv.py | import tensorlayerx as tlx
import numpy as np
from gammagl.layers.conv import SAGEConv
def test_sage_conv():
x1 = np.random.uniform(low = 0, high = 1, size = (4, 8))
x1 = tlx.convert_to_tensor(x1, dtype = tlx.float32)
edge_index = tlx.convert_to_tensor([[0, 1, 2, 3], [0, 0, 1, 1]], dtype=tlx.int64)
co... | 2,025 | 42.106383 | 85 | py |
GammaGL | GammaGL-main/tests/utils/test_to_dense_batch.py | import tensorlayerx as tlx
import pytest
from gammagl.utils import to_dense_batch
def test_to_dense_batch():
x = tlx.convert_to_tensor([[1,2], [3,4], [5,6], [6,7]])
batch = tlx.convert_to_tensor([0, 1, 1, 1])
a, b = to_dense_batch(x, batch)
assert tlx.convert_to_numpy(a).tolist() == [[[1,2],[0,0],[0,0]... | 2,075 | 37.444444 | 89 | py |
GammaGL | GammaGL-main/tests/utils/test_loop.py | import tensorlayerx as tlx
from gammagl.utils import (
# add_remaining_self_loops,
add_self_loops,
contains_self_loops,
# get_self_loop_attr,
remove_self_loops,
# segregate_self_loops,
)
def test_contains_self_loops():
edge_index = tlx.convert_to_tensor([[0, 1, 0], [1, 0, 0]])
assert ... | 5,183 | 38.876923 | 103 | py |
GammaGL | GammaGL-main/tests/data/test_batch.py | import numpy as np
import tensorlayerx as tlx
from gammagl.data import BatchGraph, Graph, HeteroGraph
def get_edge_index(num_src_nodes, num_dst_nodes, num_edges):
row = tlx.ops.convert_to_tensor(np.random.randint(num_src_nodes, size=(num_edges,), dtype=np.int64))
col = tlx.ops.convert_to_tensor(np.random.ran... | 17,651 | 48.445378 | 153 | py |
GammaGL | GammaGL-main/tests/data/test_graph.py | import numpy as np
import tensorlayerx as tlx
from gammagl.data import Graph
def test_data():
# torch_geometric.set_debug(True)
x = tlx.convert_to_tensor([[1, 3], [2, 4], [1, 2]], dtype=tlx.float32)
edge_index = tlx.convert_to_tensor([[0, 0, 1, 1, 2], [1, 1, 0, 2, 1]], dtype=tlx.int64)
data = Graph(x=x, edge_in... | 6,742 | 32.381188 | 106 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.