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 |
|---|---|---|---|---|---|---|
imagefusion-rfn-nest | imagefusion-rfn-nest-main/test_40pairs.py | # -*- coding:utf-8 -*-
# @Author: Li Hui, Jiangnan University
# @Email: hui_li_jnu@163.com
# @File : test_40pairs.py
# @Time : 2020/8/14 17:11
# test phase
import os
import torch
from torch.autograd import Variable
from net import NestFuse_light2_nodense, Fusion_network, Fusion_strategy
import utils
from args_fusion i... | 4,952 | 30.75 | 152 | py |
imagefusion-rfn-nest | imagefusion-rfn-nest-main/train_fusionnet.py | # Training a NestFuse network
# auto-encoder
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
import sys
import time
from tqdm import tqdm, trange
import scipy.io as scio
import random
import torch
from torch.optim import Adam
from torch.autograd import Variable
import utils
from net import NestFuse_light2_nodense,... | 8,542 | 33.447581 | 181 | py |
imagefusion-rfn-nest | imagefusion-rfn-nest-main/pytorch_msssim/__init__.py | import torch
import torch.nn.functional as F
from math import exp
import numpy as np
def gaussian(window_size, sigma):
gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in range(window_size)])
return gauss/gauss.sum()
def create_window(window_size, channel=1):
_1D_window = gaus... | 4,380 | 31.69403 | 118 | py |
tasksource | tasksource-main/src/tasksource/metadata/popularity.py | dataset_rank = {'glue': 0,
'super_glue': 12,
'tweet_eval': 23,
'blimp': 34,
'imdb': 101,
'wikitext': 102,
'squad': 106,
'trec': 107,
'openwebtext': 108,
'rotten_tomatoes': 109,
'anli': 110,
'adversarial_qa': 111,
'ai2_arc': 115,
'xsum': 117,
'amazon_reviews_multi': 118,
'ag_news': 125,
'yelp_review_full... | 24,310 | 28.290361 | 69 | py |
sm-vit | sm-vit-main/train.py | # coding=utf-8
from __future__ import absolute_import, division, print_function
wnb = False
if wnb:
import wandb
wandb.init(project="sm-vit", entity="xxx")
import logging
import argparse
import os
import random
import numpy as np
from datetime import timedelta
import time
import torch
import torch.distribut... | 17,894 | 39.763098 | 247 | py |
sm-vit | sm-vit-main/models/modeling.py | # coding=utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import copy
import logging
import math
from os.path import join as pjoin
from re import X
from matplotlib.cbook import flatten
import torch
import torch.nn as nn
import numpy as np
from torch.... | 19,835 | 38.12426 | 176 | py |
sm-vit | sm-vit-main/utils/data_utils.py | import logging
import torch
from torchvision import transforms, datasets
from .dataset import *
from torch.utils.data import DataLoader, RandomSampler, DistributedSampler, SequentialSampler
from PIL import Image
from .autoaugment import AutoAugImageNetPolicy
import os
logger = logging.getLogger(__name__)
def get_l... | 12,747 | 46.924812 | 124 | py |
sm-vit | sm-vit-main/utils/dataset.py | import os
import json
from os.path import join
import numpy as np
import scipy
from scipy import io
import scipy.misc
from PIL import Image
import pandas as pd
import matplotlib.pyplot as plt
import torch
from torch.utils.data import Dataset
from torchvision.datasets import VisionDataset
from torchvision.datasets.fol... | 67,209 | 39.659407 | 180 | py |
sm-vit | sm-vit-main/utils/scheduler.py | import logging
import math
from torch.optim.lr_scheduler import LambdaLR
logger = logging.getLogger(__name__)
class ConstantLRSchedule(LambdaLR):
""" Constant learning rate schedule.
"""
def __init__(self, optimizer, last_epoch=-1):
super(ConstantLRSchedule, self).__init__(optimizer, lambda _: 1.... | 2,799 | 42.75 | 117 | py |
sm-vit | sm-vit-main/utils/dist_util.py | import torch.distributed as dist
def get_rank():
if not dist.is_available():
return 0
if not dist.is_initialized():
return 0
return dist.get_rank()
def get_world_size():
if not dist.is_available():
return 1
if not dist.is_initialized():
return 1
return dist.get_... | 711 | 21.967742 | 56 | py |
sm-vit | sm-vit-main/U2Net/data_loader.py | # data loader
from __future__ import print_function, division
import glob
import torch
from skimage import io, transform, color
import numpy as np
import random
import math
import matplotlib.pyplot as plt
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms, utils
from PIL import Image
... | 9,327 | 32.797101 | 159 | py |
sm-vit | sm-vit-main/U2Net/u2net_test.py | import os
from re import X
from skimage import io, transform
import torch
import torchvision
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from torchvision import transforms#, utils
# import torch.optim as optim
import numpy a... | 13,512 | 37.719198 | 139 | py |
sm-vit | sm-vit-main/U2Net/model/u2net.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class REBNCONV(nn.Module):
def __init__(self,in_ch=3,out_ch=3,dirate=1):
super(REBNCONV,self).__init__()
self.conv_s1 = nn.Conv2d(in_ch,out_ch,3,padding=1*dirate,dilation=1*dirate)
self.bn_s1 = nn.BatchNorm2d(out_ch)
... | 14,719 | 26.984791 | 118 | py |
sm-vit | sm-vit-main/U2Net/model/u2net_refactor.py | import torch
import torch.nn as nn
import math
__all__ = ['U2NET_full', 'U2NET_lite']
def _upsample_like(x, size):
return nn.Upsample(size=size, mode='bilinear', align_corners=False)(x)
def _size_map(x, height):
# {height: size} for Upsample
size = list(x.shape[-2:])
sizes = {}
for h in range(... | 6,097 | 35.08284 | 101 | py |
HighOrderAtten | HighOrderAtten-master/image_model/download_model.py | """
Download the VGG and deep residual model to extract image features.
Version: 1.0
Contributor: Jiasen Lu
"""
import os
import argparse
import json
def download_VGG():
print('Downloading VGG model from http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_19_layers.caffemodel')
os.system('wget... | 1,337 | 35.162162 | 169 | py |
HighOrderAtten | HighOrderAtten-master/data/prepro_vqa.py | '''
Preoricess a raw json dataset into hdf5/json files.
Caption: Use NLTK or split function to get tokens.
'''
from random import shuffle, seed
import sys
import os.path
import argparse
import numpy as np
import scipy.io
import pdb
import h5py
from nltk.tokenize import word_tokenize
import json
import re
import math
... | 11,897 | 37.882353 | 153 | py |
MCEdit-Unified | MCEdit-Unified-master/renderer.py | """Copyright (c) 2010-2012 David Rio Vierra
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WA... | 146,617 | 35.572213 | 153 | py |
MCEdit-Unified | MCEdit-Unified-master/resource_packs.py | # -*- coding: utf-8 -*-
#!# If the comman line parameter '--debug-packs' is given, the logging level is set to debug.
#!# Otherwise, it is set to critical.
from PIL import Image
import zipfile
import directories
import os
import shutil
from config import config
from cStringIO import StringIO
import locale
import trace... | 42,430 | 37.963269 | 180 | py |
MCEdit-Unified | MCEdit-Unified-master/pymclevel/indev.py | """
Created on Jul 22, 2011
@author: Rio
Indev levels:
TAG_Compound "MinecraftLevel"
{
TAG_Compound "Environment"
{
TAG_Short "SurroundingGroundHeight"// Height of surrounding ground (in blocks)
TAG_Byte "SurroundingGroundType" // Block ID of surrounding ground
TAG_Short "SurroundingWaterHe... | 11,565 | 34.697531 | 111 | py |
MCEdit-Unified | MCEdit-Unified-master/pymclevel/mclevel.py | # -*- coding: utf-8 -*-
"""
MCLevel interfaces
Sample usage:
import mclevel
# Call mclevel.fromFile to identify and open any of these four file formats:
#
# Classic levels - gzipped serialized java objects. Returns an instance of MCJavalevel
# Indev levels - gzipped NBT data in a single file. Returns an MCIndevLev... | 11,260 | 35.800654 | 125 | py |
MCEdit-Unified | MCEdit-Unified-master/stock-filters/Find.py | # written by texelelf
#-# Adding a result pages, and NBT edit stuff
from pymclevel import TAG_Byte, TAG_Short, TAG_Int, TAG_Compound, TAG_List, TAG_String, TAG_Double, TAG_Float, TAG_Long, \
TAG_Byte_Array, TAG_Int_Array
from pymclevel.box import BoundingBox
from albow import alert, ask
import ast
# Let import the ... | 13,288 | 43.89527 | 383 | py |
MCEdit-Unified | MCEdit-Unified-master/stock-filters/Forester.py | # Version 5
'''This takes a base MineCraft level and adds or edits trees.
Place it in the folder where the save files are (usually .../.minecraft/saves)
Requires mcInterface.py in the same folder.'''
# Here are the variables you can edit.
# This is the name of the map to edit.
# Make a backup if you are experimenting... | 51,634 | 37.163341 | 89 | py |
lale | lale-master/setup.py | # Copyright 2019-2023 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 4,556 | 27.304348 | 90 | py |
lale | lale-master/test/test_custom_schemas.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 27,885 | 40.435364 | 88 | py |
lale | lale-master/test/test_lale_lib_versions.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 22,044 | 30.856936 | 87 | py |
lale | lale-master/test/test_pipeline.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 17,752 | 43.717884 | 318 | py |
lale | lale-master/test/test_core_regressors.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 8,557 | 32.826087 | 100 | py |
lale | lale-master/test/test_core_pipeline.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 48,983 | 42.348673 | 107 | py |
lale | lale-master/test/test_autoai_libs.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 14,626 | 38.005333 | 127 | py |
lale | lale-master/test/test_core_classifiers.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 27,160 | 33.6 | 105 | py |
lale | lale-master/test/test_relational_sklearn.py | # Copyright 2021-2023 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 103,433 | 42.29594 | 162 | py |
lale | lale-master/test/test_json_pretty_viz.py | # Copyright 2019-2023 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 64,209 | 37.106825 | 147 | py |
lale | lale-master/lale/operator_wrapper.py | # Copyright 2019-2022 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 4,203 | 31.589147 | 111 | py |
lale | lale-master/lale/helpers.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 46,947 | 34.459215 | 150 | py |
lale | lale-master/lale/util/pandas_torch_dataset.py | # Copyright 2021 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 2,475 | 28.831325 | 101 | py |
lale | lale-master/lale/util/hdf5_to_torch_dataset.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 2,412 | 30.75 | 89 | py |
lale | lale-master/lale/util/batch_data_dictionary_dataset.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 1,227 | 30.487179 | 99 | py |
lale | lale-master/lale/util/numpy_to_torch_dataset.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 2,557 | 29.452381 | 89 | py |
lale | lale-master/lale/util/numpy_torch_dataset.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 2,557 | 29.452381 | 89 | py |
lale | lale-master/lale/util/pandas_to_torch_dataset.py | # Copyright 2021 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 2,481 | 28.903614 | 101 | py |
lale | lale-master/lale/datasets/data_schemas.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 24,607 | 32.389417 | 205 | py |
lale | lale-master/lale/lib/rasl/batching.py | # Copyright 2019-2022 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 13,230 | 34.953804 | 127 | py |
lale | lale-master/lale/lib/rasl/concat_features.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 10,375 | 35.407018 | 126 | py |
lale | lale-master/lale/lib/xgboost/xgb_regressor.py | # Copyright 2019-2022 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 30,974 | 35.963007 | 284 | py |
lale | lale-master/lale/lib/xgboost/xgb_classifier.py | # Copyright 2019-2022 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | 33,369 | 36.326622 | 284 | py |
lale | lale-master/lale/lib/xgboost/__init__.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 1,325 | 31.341463 | 97 | py |
lale | lale-master/lale/lib/lale/auto_pipeline.py | # Copyright 2020 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 14,599 | 32.87471 | 122 | py |
lale | lale-master/docs/conf.py | # Copyright 2019 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | 7,789 | 30.538462 | 108 | py |
PoolNet | PoolNet-master/main.py | import argparse
import os
from dataset.dataset import get_loader
from solver import Solver
def get_test_info(sal_mode='e'):
if sal_mode == 'e':
image_root = './data/ECSSD/Imgs/'
image_source = './data/ECSSD/test.lst'
elif sal_mode == 'p':
image_root = './data/PASCALS/Imgs/'
imag... | 3,827 | 38.061224 | 95 | py |
PoolNet | PoolNet-master/joint_main.py | import argparse
import os
from dataset.joint_dataset import get_loader
from joint_solver import Solver
def get_test_info(sal_mode='e'):
if sal_mode == 'e':
image_root = './data/ECSSD/Imgs/'
image_source = './data/ECSSD/test.lst'
elif sal_mode == 'p':
image_root = './data/PASCALS/Imgs/'
... | 4,316 | 40.912621 | 95 | py |
PoolNet | PoolNet-master/solver.py | import torch
from collections import OrderedDict
from torch.nn import utils, functional as F
from torch.optim import Adam
from torch.autograd import Variable
from torch.backends import cudnn
from networks.poolnet import build_model, weights_init
import scipy.misc as sm
import numpy as np
import os
import torchvision.ut... | 5,765 | 38.493151 | 129 | py |
PoolNet | PoolNet-master/joint_solver.py | import torch
from collections import OrderedDict
from torch.nn import utils, functional as F
from torch.optim import Adam
from torch.autograd import Variable
from torch.backends import cudnn
from networks.joint_poolnet import build_model, weights_init
import scipy.misc as sm
import numpy as np
import os
import torchvis... | 8,569 | 44.105263 | 163 | py |
PoolNet | PoolNet-master/networks/joint_poolnet.py | import torch
from torch import nn
from torch.nn import init
import torch.nn.functional as F
import math
from torch.autograd import Variable
import numpy as np
from .deeplab_resnet import resnet50_locate
from .vgg import vgg16_locate
config_vgg = {'convert': [[128,256,512,512,512],[64,128,256,512,512]], 'deep_pool': ... | 8,853 | 41.772947 | 344 | py |
PoolNet | PoolNet-master/networks/vgg.py | import torch.nn as nn
import math
import torch
import numpy as np
import torch.nn.functional as F
# vgg16
def vgg(cfg, i, batch_norm=False):
layers = []
in_channels = i
stage = 1
for v in cfg:
if v == 'M':
stage += 1
if stage == 6:
layers += [nn.MaxPool2d... | 3,581 | 35.927835 | 148 | py |
PoolNet | PoolNet-master/networks/poolnet.py | import torch
from torch import nn
from torch.nn import init
import torch.nn.functional as F
import math
from torch.autograd import Variable
import numpy as np
from .deeplab_resnet import resnet50_locate
from .vgg import vgg16_locate
config_vgg = {'convert': [[128,256,512,512,512],[64,128,256,512,512]], 'deep_pool': ... | 4,800 | 37.103175 | 227 | py |
PoolNet | PoolNet-master/networks/deeplab_resnet.py | import torch.nn as nn
import math
import torch
import numpy as np
import torch.nn.functional as F
affine_par = True
def conv3x3(in_planes, out_planes, stride=1):
"3x3 convolution with padding"
return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,
padding=1, bias=False)
cla... | 7,161 | 34.107843 | 148 | py |
PoolNet | PoolNet-master/dataset/dataset.py | import os
from PIL import Image
import cv2
import torch
from torch.utils import data
from torchvision import transforms
from torchvision.transforms import functional as F
import numbers
import numpy as np
import random
class ImageDataTrain(data.Dataset):
def __init__(self, data_root, data_list):
self.sal_r... | 3,469 | 32.047619 | 148 | py |
PoolNet | PoolNet-master/dataset/joint_dataset.py | import os
from PIL import Image
import cv2
import torch
from torch.utils import data
from torchvision import transforms
from torchvision.transforms import functional as F
import numbers
import numpy as np
import random
class ImageDataTrain(data.Dataset):
def __init__(self, sal_data_root, sal_data_list, edge_data_r... | 4,702 | 34.360902 | 148 | py |
GNNDelete | GNNDelete-main/train_node.py | import os
import wandb
import pickle
import torch
from torch_geometric.seed import seed_everything
from torch_geometric.utils import to_undirected, is_undirected
import torch_geometric.transforms as T
from torch_geometric.datasets import CitationFull, Coauthor, Flickr, RelLinkPredDataset, WordNet18, WordNet18RR
from to... | 1,881 | 30.898305 | 129 | py |
GNNDelete | GNNDelete-main/graph_stat.py | import os
from torch_geometric.data import Data
import torch_geometric.transforms as T
from torch_geometric.datasets import CitationFull, Coauthor, Flickr, RelLinkPredDataset, WordNet18RR
from ogb.linkproppred import PygLinkPropPredDataset
data_dir = './data'
datasets = ['Cora', 'PubMed', 'DBLP', 'CS', 'Physics', 'og... | 1,292 | 35.942857 | 150 | py |
GNNDelete | GNNDelete-main/delete_node_feature.py | import os
import copy
import json
import wandb
import pickle
import argparse
import torch
import torch.nn as nn
from torch_geometric.utils import to_undirected, to_networkx, k_hop_subgraph, is_undirected
from torch_geometric.data import Data
import torch_geometric.transforms as T
from torch_geometric.datasets import Ci... | 11,564 | 40.902174 | 156 | py |
GNNDelete | GNNDelete-main/delete_gnn.py | import os
import copy
import json
import wandb
import pickle
import argparse
import torch
import torch.nn as nn
from torch_geometric.utils import to_undirected, to_networkx, k_hop_subgraph, is_undirected
from torch_geometric.data import Data
from torch_geometric.loader import GraphSAINTRandomWalkSampler
from torch_geom... | 11,069 | 37.4375 | 147 | py |
GNNDelete | GNNDelete-main/train_gnn.py | import os
import wandb
import pickle
import torch
from torch_geometric.seed import seed_everything
from torch_geometric.utils import to_undirected, is_undirected
from torch_geometric.datasets import RelLinkPredDataset, WordNet18
from torch_geometric.seed import seed_everything
from framework import get_model, get_trai... | 2,977 | 34.035294 | 129 | py |
GNNDelete | GNNDelete-main/prepare_dataset.py | import os
import math
import pickle
import torch
import pandas as pd
import networkx as nx
from tqdm import tqdm
from torch_geometric.seed import seed_everything
import torch_geometric.transforms as T
from torch_geometric.data import Data
from torch_geometric.datasets import CitationFull, Coauthor, Flickr, RelLinkPredD... | 16,717 | 39.97549 | 134 | py |
GNNDelete | GNNDelete-main/delete_node.py | import os
import copy
import json
import wandb
import pickle
import argparse
import torch
import torch.nn as nn
from torch_geometric.utils import to_undirected, to_networkx, k_hop_subgraph, is_undirected
from torch_geometric.data import Data
import torch_geometric.transforms as T
from torch_geometric.datasets import Ci... | 11,453 | 40.80292 | 156 | py |
GNNDelete | GNNDelete-main/framework/data_loader.py | import os
import torch
from torch_geometric.data import Data, GraphSAINTRandomWalkSampler
def load_dict(filename):
'''Load entity and relation to id mapping'''
mapping = {}
with open(filename, 'r') as f:
for l in f:
l = l.strip().split('\t')
mapping[l[0]] = l[1]
retur... | 3,344 | 32.45 | 125 | py |
GNNDelete | GNNDelete-main/framework/utils.py | import numpy as np
import torch
import networkx as nx
def get_node_edge(graph):
degree_sorted_ascend = sorted(graph.degree, key=lambda x: x[1])
return degree_sorted_ascend[-1][0]
def h_hop_neighbor(G, node, h):
path_lengths = nx.single_source_dijkstra_path_length(G, node)
return [node for node, leng... | 1,852 | 30.40678 | 81 | py |
GNNDelete | GNNDelete-main/framework/evaluation.py | import torch
import torch.nn.functional as F
from sklearn.metrics import roc_auc_score, average_precision_score
from .utils import get_link_labels
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
@torch.no_grad()
def eval_lp(model, stage, data=None, loader=None):
model.eval()
# For ... | 6,151 | 32.254054 | 108 | py |
GNNDelete | GNNDelete-main/framework/trainer/base.py | import os
import time
import json
import wandb
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from tqdm import trange, tqdm
from ogb.graphproppred import Evaluator
from torch_geometric.data import DataLoader
from torch_geometric.utils import negative_sampling
from torch_geometric.... | 41,518 | 41.366327 | 169 | py |
GNNDelete | GNNDelete-main/framework/trainer/member_infer.py | import os
import json
import wandb
import numpy as np
import torch
import torch.nn as nn
from tqdm import trange, tqdm
from torch_geometric.utils import negative_sampling
from sklearn.metrics import accuracy_score, roc_auc_score, average_precision_score, f1_score
from .base import Trainer
from ..evaluation import *
fr... | 8,132 | 37.728571 | 171 | py |
GNNDelete | GNNDelete-main/framework/trainer/gradient_ascent_with_mp.py | import os
import json
from tqdm import tqdm, trange
import torch
import torch.nn.functional as F
from torch_geometric.utils import negative_sampling
from .base import Trainer
from ..evaluation import *
from ..utils import *
class GradientAscentWithMessagePassingTrainer(Trainer):
def __init__(self,):
self... | 3,937 | 36.865385 | 118 | py |
GNNDelete | GNNDelete-main/framework/trainer/retrain.py | import os
import time
import wandb
from tqdm import tqdm, trange
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.utils import negative_sampling
from torch_geometric.loader import GraphSAINTRandomWalkSampler
from .base import Trainer, KGTrainer
from ..evaluatio... | 14,611 | 41.976471 | 127 | py |
GNNDelete | GNNDelete-main/framework/trainer/gnndelete_nodeemb.py | import os
import copy
import time
import wandb
from tqdm import tqdm, trange
import torch
import torch.nn as nn
from torch_geometric.utils import negative_sampling, k_hop_subgraph
from torch_geometric.loader import GraphSAINTRandomWalkSampler
from .base import Trainer, KGTrainer, NodeClassificationTrainer
from ..evalu... | 37,356 | 43.105077 | 159 | py |
GNNDelete | GNNDelete-main/framework/trainer/gnndelete.py | import os
import time
import wandb
from tqdm import tqdm, trange
import torch
import torch.nn as nn
from torch_geometric.utils import negative_sampling, k_hop_subgraph
from torch_geometric.loader import GraphSAINTRandomWalkSampler
from .base import Trainer
from ..evaluation import *
from ..utils import *
def Bounded... | 19,850 | 43.015521 | 154 | py |
GNNDelete | GNNDelete-main/framework/trainer/gradient_ascent.py | import os
import time
import wandb
from tqdm import tqdm, trange
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.utils import negative_sampling
from torch_geometric.loader import GraphSAINTRandomWalkSampler
from .base import Trainer, KGTrainer
from ..evaluation import *
from ..u... | 13,223 | 42.074919 | 128 | py |
GNNDelete | GNNDelete-main/framework/trainer/graph_eraser.py | import os
import json
import copy
import math
from tqdm import tqdm, trange
import numpy as np
import torch
import torch.nn.functional as F
from torch_geometric.utils import negative_sampling, subgraph
from .base import Trainer
from ..evaluation import *
from ..utils import *
class ConstrainedKmeans:
'''This cod... | 14,714 | 38.24 | 120 | py |
GNNDelete | GNNDelete-main/framework/trainer/descent_to_delete.py | import os
import time
import wandb
from tqdm import tqdm, trange
import torch
import torch.nn.functional as F
from torch_geometric.utils import negative_sampling
from .base import Trainer
from ..evaluation import *
from ..utils import *
class DtdTrainer(Trainer):
'''This code is adapte from https://github.com/Ch... | 4,135 | 38.390476 | 153 | py |
GNNDelete | GNNDelete-main/framework/trainer/approx_retrain.py | import os
import wandb
from tqdm import tqdm, trange
import torch
import torch.nn.functional as F
from torch_geometric.utils import negative_sampling
from torch.utils.data import DataLoader, TensorDataset
from .base import Trainer
from ..evaluation import *
from ..utils import *
DTYPE = np.float16
class ApproxTrain... | 5,736 | 33.14881 | 117 | py |
GNNDelete | GNNDelete-main/framework/trainer/gnndelete_embdis.py | import os
import time
import wandb
from tqdm import tqdm, trange
import torch
import torch.nn as nn
from torch_geometric.utils import negative_sampling, k_hop_subgraph
from torch_geometric.loader import GraphSAINTRandomWalkSampler
from .base import Trainer
from ..evaluation import *
from ..utils import *
def Bounded... | 13,600 | 42.453674 | 135 | py |
GNNDelete | GNNDelete-main/framework/models/gin.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GINConv
class GIN(nn.Module):
def __init__(self, args, **kwargs):
super().__init__()
self.conv1 = GINConv(nn.Linear(args.in_dim, args.hidden_dim))
self.conv2= GINConv(nn.Linear(args.h... | 1,373 | 28.869565 | 76 | py |
GNNDelete | GNNDelete-main/framework/models/rgat.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from sklearn.metrics import roc_auc_score, average_precision_score
from typing import Optional
import torch
import torch.nn.functional as F
from torch import Tensor
from torch.nn import Parameter, ReLU
from torch_scatter import scat... | 16,095 | 40.061224 | 97 | py |
GNNDelete | GNNDelete-main/framework/models/deletion.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from . import GCN, GAT, GIN, RGCN, RGAT
class DeletionLayer(nn.Module):
def __init__(self, dim, mask):
super().__init__()
self.dim = dim
self.mask = mask
self.deletion_weight = nn.Parame... | 6,273 | 31.340206 | 102 | py |
GNNDelete | GNNDelete-main/framework/models/rgcn.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import RGCNConv, FastRGCNConv
from sklearn.metrics import roc_auc_score, average_precision_score
class RGCN(nn.Module):
def __init__(self, args, num_nodes, num_edge_type, **kwargs):
super().__init... | 1,689 | 31.5 | 97 | py |
GNNDelete | GNNDelete-main/framework/models/gcn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GCNConv
class GCN(nn.Module):
def __init__(self, args, **kwargs):
super().__init__()
self.conv1 = GCNConv(args.in_dim, args.hidden_dim)
self.conv2 = GCNConv(args.hidden_dim, args.out_dim)
... | 1,039 | 27.888889 | 76 | py |
GNNDelete | GNNDelete-main/framework/models/gat.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.nn import GATConv
class GAT(nn.Module):
def __init__(self, args, **kwargs):
super().__init__()
self.conv1 = GATConv(args.in_dim, args.hidden_dim)
self.conv2 = GATConv(args.hidden_dim, args.out_dim)
... | 1,039 | 27.888889 | 76 | py |
GNNDelete | GNNDelete-main/framework/models/graph_classification/gcn_delete.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ogb.graphproppred.mol_encoder import AtomEncoder
from torch_geometric.nn import GCNConv, MessagePassing, global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set
from ogb.graphproppred.mol_encoder import AtomEncoder, BondEncoder... | 5,857 | 34.719512 | 153 | py |
GNNDelete | GNNDelete-main/framework/models/graph_classification/gcn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ogb.graphproppred.mol_encoder import AtomEncoder
from torch_geometric.nn import GCNConv, MessagePassing, global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set
from ogb.graphproppred.mol_encoder import AtomEncoder, BondEncoder... | 5,019 | 35.642336 | 153 | py |
DeeBERT | DeeBERT-master/setup.py | """
Simple check list from AllenNLP repo: https://github.com/allenai/allennlp/blob/master/setup.py
To create the package for pypi.
1. Change the version in __init__.py, setup.py as well as docs/source/conf.py.
2. Commit these changes with the message: "Release: VERSION"
3. Add a tag in git to mark the release: "git... | 2,923 | 39.054795 | 183 | py |
DeeBERT | DeeBERT-master/hubconf.py | from transformers import (
AutoTokenizer, AutoConfig, AutoModel, AutoModelWithLMHead, AutoModelForSequenceClassification, AutoModelForQuestionAnswering
)
from transformers.file_utils import add_start_docstrings
dependencies = ['torch', 'tqdm', 'boto3', 'requests', 'regex', 'sentencepiece', 'sacremoses']
@add_star... | 6,489 | 56.433628 | 189 | py |
DeeBERT | DeeBERT-master/examples/run_lm_finetuning.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 28,845 | 50.881295 | 165 | py |
DeeBERT | DeeBERT-master/examples/run_squad.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 31,570 | 54.001742 | 151 | py |
DeeBERT | DeeBERT-master/examples/run_highway_glue.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 33,078 | 51.423138 | 158 | py |
DeeBERT | DeeBERT-master/examples/run_glue.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 28,140 | 52.398482 | 158 | py |
DeeBERT | DeeBERT-master/examples/benchmarks.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.a... | 23,631 | 48.439331 | 138 | py |
DeeBERT | DeeBERT-master/examples/run_summarization_finetuning.py | # coding=utf-8
# Copyright 2019 The HuggingFace Inc. team.
# Copyright (c) 2019 The HuggingFace Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.a... | 15,727 | 30.902637 | 120 | py |
DeeBERT | DeeBERT-master/examples/run_bertology.py | #!/usr/bin/env python3
# Copyright 2018 CMU and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | 18,901 | 51.798883 | 177 | py |
DeeBERT | DeeBERT-master/examples/utils_summarization_test.py | # coding=utf-8
# Copyright 2019 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | 5,178 | 36.80292 | 98 | py |
DeeBERT | DeeBERT-master/examples/run_generation.py | #!/usr/bin/env python3
# coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in c... | 13,112 | 49.241379 | 167 | py |
DeeBERT | DeeBERT-master/examples/run_ner.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 28,786 | 53.009381 | 184 | py |
DeeBERT | DeeBERT-master/examples/utils_summarization.py | from collections import deque
import os
import torch
from torch.utils.data import Dataset
# ------------
# Data loading
# ------------
class CNNDailyMailDataset(Dataset):
""" Abstracts the dataset used to train seq2seq models.
CNN/Daily News:
The CNN/Daily News raw datasets are downloaded from [1]. T... | 6,022 | 31.556757 | 88 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.