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 |
|---|---|---|---|---|---|---|
GammaGL | GammaGL-main/docs/source/conf.py | import datetime
import doctest
import sphinx_rtd_theme
import gammagl
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
]
autosum... | 1,948 | 24.311688 | 74 | py |
GammaGL | GammaGL-main/profiler/pyg/pyg_gcn.py | import argparse
import os.path as osp
import time
import torch
import torch.nn.functional as F
import numpy as np
import torch_geometric.transforms as T
from torch_geometric.datasets import Planetoid
# from torch_geometric.logging import init_wandb, log
from torch_geometric.nn import GCNConv
import numpy as np
parser ... | 3,604 | 33.009434 | 78 | py |
GammaGL | GammaGL-main/profiler/pyg/pyg_reddit_sage.py | import copy
import os.path as osp
from time import time
import torch
import torch.nn.functional as F
from tqdm import tqdm
from torch_geometric.datasets import Reddit
from torch_geometric.loader import NeighborLoader
from torch_geometric.nn import SAGEConv
device = torch.device('cuda' if torch.cuda.is_available() el... | 4,506 | 30.739437 | 96 | py |
GammaGL | GammaGL-main/profiler/pyg/pyg_gat.py | import argparse
import os.path as osp
import torch
import torch.nn.functional as F
import numpy as np
import torch_geometric.transforms as T
from torch_geometric.datasets import Planetoid
# from torch_geometric.logging import init_wandb, log
from torch_geometric.nn import GATConv
import numpy as np
import time
parser... | 3,109 | 32.44086 | 78 | py |
GammaGL | GammaGL-main/profiler/sampler/quiver_neighbor_sample_gpu.py | import os.path as osp
from time import time
import torch
from torch_geometric.datasets import Reddit
import quiver
path = osp.join(osp.dirname(osp.realpath(__file__)), '..', 'data', 'Reddit')
dataset = Reddit(path)
data = dataset[0]
train_idx = data.train_mask.nonzero(as_tuple=False).view(-1)
########################... | 1,366 | 32.341463 | 129 | py |
GammaGL | GammaGL-main/profiler/sampler/pyg_neighbor_sample_new.py | import copy
import os.path as osp
from time import time
import numpy as np
import torch
from torch_geometric.datasets import Reddit
from torch_geometric.loader import NeighborLoader
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
path = osp.join(osp.dirname(osp.realpath(__file__)), '..', 'reddi... | 1,475 | 24.894737 | 77 | py |
GammaGL | GammaGL-main/profiler/sampler/dgl_neighbor_sample.py | import dgl
import numpy as np
import torch as th
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import time
import argparse
from dgl.data import RedditDataset
def load_reddit():
# load reddit data
data = RedditDataset(self_loop=True)
g = data[0]
g.ndata['features'... | 5,704 | 32.958333 | 100 | py |
GammaGL | GammaGL-main/profiler/sampler/pyg_neighbor_sample_old.py | import os.path as osp
from time import time
import numpy as np
from torch_geometric.datasets import Reddit
from torch_geometric.loader import NeighborSampler
path = osp.join(osp.dirname(osp.realpath(__file__)), '..', 'reddit')
dataset = Reddit(path)
data = dataset[0]
train_loader = NeighborSampler(data.edge_index, n... | 1,236 | 29.170732 | 77 | py |
GammaGL | GammaGL-main/profiler/dgl/dgl_sage.py | import dgl
import numpy as np
import torch as th
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import time
import argparse
from dgl.data import RedditDataset
import dgl.nn as dglnn
import tqdm
class SAGE(nn.Module):
def __init__(self, in_feats, n_hidden, n_classes, n_layers, ac... | 9,131 | 36.735537 | 103 | py |
GammaGL | GammaGL-main/profiler/ggl/test.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/05/22 23:59
# @Author : clear
# @FileName: test.py.py
from subprocess import run
import os
logfile = 'log.txt'
gpu = 8
iter = 5
dataset = 'pubmed'
if os.path.exists('log.txt'):
os.remove('log.txt')
# GCN
for i in range(iter):
run("TL_BACKEND... | 2,037 | 30.84375 | 96 | py |
GammaGL | GammaGL-main/profiler/ggl/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
import time
import numpy as np
sys.path.insert(0, os.path.abspath('../../')) # a... | 5,270 | 34.857143 | 109 | py |
GammaGL | GammaGL-main/profiler/ggl/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'] = 'paddle'
import sys
import time
import numpy as np
sys.path.insert(0, os.path.abspath('../../')) # a... | 5,231 | 34.591837 | 104 | py |
GammaGL | GammaGL-main/profiler/mpops/torch_ext_.py | import time
import torch
import numpy as np
from pyinstrument import Profiler
pf = Profiler()
# copied from gammagl/mpops/torch.py
def unsorted_segment_max(x, segment_ids, num_segments=None):
if num_segments is None:
num_segments = int(segment_ids.max().item()) + 1
assert x.shape[0] == segment_ids.... | 3,155 | 28.495327 | 108 | py |
GammaGL | GammaGL-main/profiler/mpops/deprecated/pyg_gpu.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/04/17 09:59
# @Author : clear
# @FileName: pyg_gpu.py
import torch
import time
import numpy as np
from torch_scatter import scatter_sum, scatter_mean, scatter_max
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
edge_index = np... | 987 | 20.955556 | 71 | py |
GammaGL | GammaGL-main/profiler/mpops/deprecated/th_gpu.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/04/14 08:35
# @Author : clear
# @FileName: th_gpu.py
import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
import sys
sys.path.insert(0, os.path.abspath('../../'))
import torch
# from pyinstrument import Profiler
import ... | 1,512 | 24.216667 | 89 | py |
GammaGL | GammaGL-main/profiler/mpops/deprecated/torch_ext_.py | import time
import torch
import numpy as np
from pyinstrument import Profiler
pf = Profiler()
# copied from gammagl/mpops/torch.py
def unsorted_segment_max(x, segment_ids, num_segments=None):
if num_segments is None:
num_segments = int(segment_ids.max().item()) + 1
assert x.shape[0] == segment_ids.sh... | 3,139 | 29.192308 | 108 | py |
GammaGL | GammaGL-main/profiler/mpops/deprecated/th_cpu.py | # !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2022/04/14 08:36
# @Author : clear
# @FileName: th_cpu.py
import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = ""
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
from gammagl.mpops import *
edge... | 1,107 | 22.574468 | 107 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_gpu/spmm_sum_gpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "4"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
from gammagl.mpops import *
import time
try:
tlx.set_device(device='GPU', id=4)
except:
print("GPU is not available")
try:
import torch_ope... | 1,587 | 26.859649 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_gpu/th_ext_max_gpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "4"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
# from gammagl.mpops import *
import time
try:
tlx.set_device(device='GPU', id=4)
except:
print("GPU is not available")
try:
import torch_o... | 1,519 | 27.148148 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_gpu/dgl_mp_gpu.py | import torch
import dgl.ops as F
import dgl
import numpy as np
import time
device = torch.device("cuda:4" if torch.cuda.is_available() else "cpu")
# device = torch.device("cpu")
relative_path = 'profiler/mpops/edge_index/'
file_name = ['cora.npy', 'pubmed.npy', 'ogbn-arxiv.npy']
embedding = [16, 64, 256]
iter = 10
f... | 1,401 | 24.962963 | 75 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_gpu/th_mp_gpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "4"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
from gammagl.mpops import *
import time
try:
tlx.set_device(device='GPU', id=4)
except:
print("GPU is not available")
relative_path = 'profiler... | 3,611 | 34.411765 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_gpu/pyg_mp_gpu.py | import torch
import time
import numpy as np
from torch_scatter import scatter_sum, scatter_mean, scatter_max
device = torch.device("cuda:4" if torch.cuda.is_available() else "cpu")
# device = torch.device("cpu")
relative_path = 'profiler/mpops/edge_index/'
file_name = ['cora.npy', 'pubmed.npy', 'ogbn-arxiv.npy']
embe... | 1,665 | 27.237288 | 75 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/ops_gpu/pyg_scatter_ops_gpu.py | import torch
import time
import numpy as np
from torch_scatter import scatter_sum, scatter_mean, scatter_max
device = torch.device("cuda:4" if torch.cuda.is_available() else "cpu")
# device = torch.device("cpu")
relative_path = 'profiler/mpops/edge_index/'
file_name = ['cora.npy', 'pubmed.npy', 'ogbn-arxiv.npy']
embe... | 1,588 | 27.375 | 75 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/ops_gpu/th_segment_ops_gpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "4"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
from gammagl.mpops import *
import time
try:
tlx.set_device(device='GPU', id=0)
except:
print("GPU is not available")
# use_ext = False
relati... | 2,381 | 28.407407 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/ops_gpu/th_ext_segment_max_gpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "4"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
# from gammagl.mpops import *
import time
try:
tlx.set_device(device='GPU', id=4)
except:
print("GPU is not available")
try:
import torch_... | 1,479 | 26.407407 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_cpu/pyg_mp_cpu.py | import torch
import time
import numpy as np
from torch_scatter import scatter_sum, scatter_mean, scatter_max
# device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
device = torch.device("cpu")
relative_path = 'profiler/mpops/edge_index/'
file_name = ['cora.npy', 'pubmed.npy', 'ogbn-arxiv.npy']
embe... | 1,869 | 27.769231 | 75 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_cpu/th_ext_max_cpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
# from gammagl.mpops import *
import time
try:
import torch_operator
except ImportError:
exit(0)
relative_path = 'profiler/mpops/edge_index/'
... | 1,595 | 29.113208 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_cpu/dgl_mp_cpu.py | import torch
import dgl.ops as F
import dgl
import numpy as np
import time
# device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
device = torch.device("cpu")
relative_path = 'profiler/mpops/edge_index/'
file_name = ['cora.npy', 'pubmed.npy', 'ogbn-arxiv.npy']
embedding = [16, 64, 256]
iter = 10
f... | 1,380 | 25.056604 | 75 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_cpu/th_mp_cpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
from gammagl.mpops import *
import time
relative_path = 'profiler/mpops/edge_index/'
file_name = ['cora.npy', 'pubmed.npy', 'ogbn-arxiv.npy']
embedding... | 3,525 | 35.350515 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/mp_cpu/spmm_sum_cpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
from gammagl.mpops import *
import time
try:
import torch_operator
except ImportError:
exit(0)
relative_path = 'profiler/mpops/edge_index/'
fi... | 1,481 | 28.058824 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/ops_cpu/th_ext_segment_mean_cpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
# from gammagl.mpops import *
import time
try:
import torch_operator
except ImportError:
exit(0)
relative_path = 'profiler/mpops/edge_index/'
... | 1,393 | 27.44898 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/ops_cpu/pyg_scatter_ops_cpu.py | import torch
import time
import numpy as np
from torch_scatter import scatter_sum, scatter_mean, scatter_max
# device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
device = torch.device("cpu")
relative_path = 'profiler/mpops/edge_index/'
file_name = ['cora.npy', 'pubmed.npy', 'ogbn-arxiv.npy']
embe... | 1,594 | 27.482143 | 75 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/ops_cpu/th_ext_segment_sum_cpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
# from gammagl.mpops import *
import time
try:
import torch_operator
except ImportError:
exit(0)
relative_path = 'profiler/mpops/edge_index/'
... | 1,391 | 27.408163 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/ops_cpu/th_ext_segment_max_cpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
# from gammagl.mpops import *
import time
try:
import torch_operator
except ImportError:
exit(0)
relative_path = 'profiler/mpops/edge_index/'
... | 1,391 | 27.408163 | 95 | py |
GammaGL | GammaGL-main/profiler/mpops/complete_test/ops_cpu/th_segment_ops_cpu.py | import os
os.environ['TL_BACKEND'] = 'torch'
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
from pyinstrument import Profiler
import numpy as np
import tensorlayerx as tlx
from gammagl.mpops import *
import time
relative_path = 'profiler/mpops/edge_index/'
file_name = ['cora.npy', 'pubmed.npy', 'ogbn-arxiv.npy']
embedding... | 2,293 | 29.586667 | 95 | py |
tgb-gan | tgb-gan-main/age_cls_fake.py | import sys
import glob
import argparse
import numpy as np
import tensorflow as tf
import scipy.io as sio
sys.path.append('git/_framework')
from utils import util as U
from core.data_provider import DataProvider
from core.trainer_tf import Trainer
from core.data_processor import SimpleImageProcessor
from core.learnin... | 5,363 | 38.441176 | 173 | py |
tgb-gan | tgb-gan-main/gan_reg_train.py | import os
import sys
import shutil
import argparse
import numpy as np
import tensorflow as tf
import scipy.io as sio
sys.path.append('git/_framework')
from utils import util as U
from core.data_provider import DataProvider
from core.trainer_tf import Trainer
from core.data_processor import SimpleImageProcessor
from ... | 4,601 | 33.601504 | 137 | py |
tgb-gan | tgb-gan-main/nets/gan_reg.py | import numpy as np
import tensorflow as tf
from tensorflow.keras import Model, layers, initializers
from model.vgg3d import VGG3D
class GEN_REG(Model):
def __init__(self, gen, reg):
super().__init__()
self.gen = gen
self.reg = reg
def __call__(self, x_in, drop_rate, training=False):
... | 7,291 | 40.431818 | 122 | py |
tgb-gan | tgb-gan-main/nets/vgg3d.py | import numpy as np
import tensorflow as tf
from tensorflow.keras import Model, layers, initializers
class VGG3D(Model):
def __init__(self, n_layer, root_filters, kernal_size=3, pool_size=2, use_bn=True, use_res=True, padding='SAME'):
super().__init__()
self.dw_layers = dict()
self.max_pools... | 3,675 | 34.346154 | 117 | py |
l3embedding | l3embedding-master/classifier/train.py | import datetime
import getpass
import json
import os
import pickle as pk
import random
import git
from itertools import product
import time
import keras
import keras.regularizers as regularizers
from tensorflow import set_random_seed
import numpy as np
from keras.layers import Input, Dense
from keras.models import Mod... | 28,203 | 38.723944 | 110 | py |
l3embedding | l3embedding-master/l3embedding/vision_model.py | from keras.models import Model
from keras.layers import Input, Conv2D, BatchNormalization, MaxPooling2D, \
Flatten, Activation
import keras.regularizers as regularizers
def construct_cnn_L3_orig_vision_model():
"""
Constructs a model that replicates the vision subnetwork used in Look,
Listen and Lear... | 9,519 | 34.129151 | 82 | py |
l3embedding | l3embedding-master/l3embedding/audio_model.py | from keras.models import Model
from keras.layers import Input, Conv2D, BatchNormalization, MaxPooling2D, \
Flatten, Activation, Lambda
from kapre.time_frequency import Spectrogram, Melspectrogram
import tensorflow as tf
import keras.regularizers as regularizers
def construct_cnn_L3_orig_audio_model():
"""
... | 18,670 | 33.448339 | 92 | py |
l3embedding | l3embedding-master/l3embedding/model.py | from keras.layers import concatenate, Dense
from .vision_model import *
from .audio_model import *
from .training_utils import multi_gpu_model
def L3_merge_audio_vision_models(vision_model, x_i, audio_model, x_a, model_name, layer_size=128):
"""
Merges the audio and vision subnetworks and adds additional full... | 10,268 | 31.703822 | 114 | py |
l3embedding | l3embedding-master/l3embedding/training_utils.py | # Copy of https://github.com/fchollet/keras/blob/master/keras/utils/training_utils.py
# Move import tensorflow as tf to the top to address the pickle issue
# https://github.com/fchollet/keras/issues/8123
from keras import backend as K
from keras.engine.training import Model
from keras.layers.core import Lambda
from ke... | 6,454 | 36.748538 | 85 | py |
l3embedding | l3embedding-master/l3embedding/train.py | import getpass
import git
import json
import datetime
import os
import pickle
import random
import csv
import numpy as np
import keras
from keras.optimizers import Adam
import pescador
from skimage import img_as_float
from gsheets import get_credentials, append_row, update_experiment, get_row
from .model import MODEL... | 15,397 | 35.488152 | 117 | py |
l3embedding | l3embedding-master/data/usc/features.py | import logging
import os
import librosa
import numpy as np
import scipy as sp
import soundfile as sf
import resampy
import tensorflow as tf
from sklearn.preprocessing import StandardScaler, MinMaxScaler
from .vggish import vggish_input
from .vggish import vggish_postprocess
from .vggish import vggish_slim
LOGGER = log... | 12,949 | 34.382514 | 91 | py |
l3embedding | l3embedding-master/data/usc/us8k.py | import csv
import logging
import os
import glob
import random
import numpy as np
import data.usc.features as cls_features
from log import LogTimer
LOGGER = logging.getLogger('cls-data-generation')
LOGGER.setLevel(logging.DEBUG)
NUM_FOLDS = 10
def load_us8k_metadata(path):
"""
Load UrbanSound8K metadata
... | 5,707 | 33.179641 | 117 | py |
DA-Object-Detection | DA-Object-Detection-main/setup.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
#!/usr/bin/env python
import glob
import os
import torch
from setuptools import find_packages
from setuptools import setup
from torch.utils.cpp_extension import CUDA_HOME
from torch.utils.cpp_extension import CppExtension
from torch.utils.cpp_ext... | 2,043 | 28.2 | 73 | py |
DA-Object-Detection | DA-Object-Detection-main/tools/test_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:skip
import argparse
import os
import torch... | 3,792 | 36.186275 | 115 | py |
DA-Object-Detection | DA-Object-Detection-main/tools/test_net_batch.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:skip
import argparse
import os
import torch... | 3,785 | 35.403846 | 117 | py |
DA-Object-Detection | DA-Object-Detection-main/tools/train_net.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
r"""
Basic training script for PyTorch
"""
# Set up custom environment before nearly anything else is imported
# NOTE: this should be the first import (no not reorder)
from maskrcnn_benchmark.utils.env import setup_environment # noqa F401 isort:s... | 7,161 | 29.87069 | 109 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/solver/lr_scheduler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from bisect import bisect_right
import torch
# FIXME ideally this would be achieved with a CombinedLRScheduler,
# separating MultiStepLR with WarmupLR
# but the current LRScheduler design doesn't allow it
class WarmupMultiStepLR(torch.optim.lr_s... | 1,817 | 33.301887 | 80 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/solver/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .lr_scheduler import WarmupMultiStepLR
def make_optimizer(cfg, model):
params = []
for key, value in model.named_parameters():
if not value.requires_grad:
continue
lr = cfg.SOLVER.BASE_LR
... | 2,356 | 33.661765 | 105 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/batch_norm.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
class FrozenBatchNorm2d(nn.Module):
"""
BatchNorm2d where the batch statistics and the affine parameters
are fixed
"""
def __init__(self, n):
super(FrozenBatchNorm2d, self).__init__()... | 799 | 31 | 71 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/roi_pool.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
class _ROIPool(Function):
@staticmethod
... | 1,855 | 28 | 74 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/roi_align.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
class _ROIAlign(Function):
@staticmethod... | 2,110 | 29.594203 | 85 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/se_module.py | from torch import nn
import torch.nn.functional as F
class SELayer(nn.Module):
def __init__(self, channel, reduction=16, with_sigmoid=True):
super(SELayer, self).__init__()
self.with_sigmoid = with_sigmoid
self.avg_pool = nn.AdaptiveAvgPool2d(1)
if with_sigmoid:
self.fc ... | 936 | 33.703704 | 65 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/smooth_l1_loss.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
# TODO maybe push this to nn?
def smooth_l1_loss(input, target, beta=1. / 9, size_average=True):
"""
very similar to the smooth_l1_loss from pytorch, but with
the extra beta parameter
"""
n = torch.abs(input - tar... | 481 | 27.352941 | 71 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/sigmoid_focal_loss.py | import torch
from torch import nn
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from maskrcnn_benchmark import _C
# TODO: Use JIT to replace CUDA implementation in the future.
class _SigmoidFocalLoss(Function):
@staticmethod
def forward(ctx, logits, targets, gamma... | 2,342 | 29.428571 | 118 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/_utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import glob
import os.path
import torch
try:
from torch.utils.cpp_extension import load as load_ext
from torch.utils.cpp_extension import CUDA_HOME
except ImportError:
raise ImportError("The cpp layer extensions requires PyTorch 0.4 o... | 1,165 | 28.15 | 80 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/misc.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
helper class that supports empty tensors on some nn functions.
Ideally, add support directly in PyTorch to empty tensors in
those functions.
This can be removed once https://github.com/pytorch/pytorch/issues/12013
is implemented
"""
import m... | 3,241 | 30.475728 | 88 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/consistency_loss.py | import torch
def consistency_loss(img_feas, ins_fea, ins_labels, size_average=True):
"""
Consistency regularization as stated in the paper
`Domain Adaptive Faster R-CNN for Object Detection in the Wild`
L_cst = \sum_{i,j}||\frac{1}{|I|}\sum_{u,v}p_i^{(u,v)}-p_{i,j}||_2
"""
loss = []
len_ins... | 1,187 | 41.428571 | 104 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/domain_attention_module.py | import torch
import numpy as np
from torch import nn
import torch.nn.functional as F
import torch
from .se_module import SELayer
class DomainAttention(nn.Module):
def __init__(self, in_channels, config, reduction=16):
super(DomainAttention, self).__init__()
self.in_channels = in_channels
... | 2,433 | 39.566667 | 134 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/__init__.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
from .batch_norm import FrozenBatchNorm2d
from .misc import Conv2d
from .misc import ConvTranspose2d
from .misc import interpolate
from .nms import nms
from .roi_align import ROIAlign
from .roi_align import roi_align
from .roi_pool im... | 930 | 34.807692 | 74 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/gradient_scalar_layer.py | import torch
class _GradientScalarLayer(torch.autograd.Function):
@staticmethod
def forward(ctx, input, weight):
ctx.weight = weight
return input.view_as(input)
@staticmethod
def backward(ctx, grad_output):
grad_input = grad_output.clone()
return ctx.weight*grad_input,... | 775 | 24.866667 | 52 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/dcn/deform_conv_func.py | import torch
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from torch.nn.modules.utils import _pair
from maskrcnn_benchmark import _C
class DeformConvFunction(Function):
@staticmethod
def forward(
ctx,
input,
offset,
weight,
... | 8,309 | 30.596958 | 83 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/dcn/deform_pool_func.py | import torch
from torch.autograd import Function
from torch.autograd.function import once_differentiable
from maskrcnn_benchmark import _C
class DeformRoIPoolingFunction(Function):
@staticmethod
def forward(
ctx,
data,
rois,
offset,
spatial_scale,
out_size,
... | 2,595 | 26.041667 | 99 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/dcn/deform_pool_module.py | from torch import nn
from .deform_pool_func import deform_roi_pooling
class DeformRoIPooling(nn.Module):
def __init__(self,
spatial_scale,
out_size,
out_channels,
no_trans,
group_size=1,
part_size=None,
... | 6,307 | 40.774834 | 79 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/layers/dcn/deform_conv_module.py | import math
import torch
import torch.nn as nn
from torch.nn.modules.utils import _pair
from .deform_conv_func import deform_conv, modulated_deform_conv
class DeformConv(nn.Module):
def __init__(
self,
in_channels,
out_channels,
kernel_size,
stride=1,
padding=0,
... | 5,802 | 31.601124 | 78 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/engine/inference.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import datetime
import logging
import time
import os
import torch
from tqdm import tqdm
from maskrcnn_benchmark.data.datasets.evaluation import evaluate
from ..utils.comm import is_main_process
from ..utils.comm import all_gather
from ..utils.com... | 3,372 | 31.12381 | 96 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/engine/bbox_aug.py | import torch
import torchvision.transforms as TT
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.data import transforms as T
from maskrcnn_benchmark.structures.image_list import to_image_list
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.modeling.roi_heads.box... | 4,440 | 36.319328 | 98 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/engine/trainer.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import datetime
import logging
import time
import torch
import torch.distributed as dist
from maskrcnn_benchmark.utils.comm import get_world_size
#from maskrcnn_benchmark.utils.metric_logger import MetricLogger
def reduce_loss_dict(loss_dict):
... | 7,311 | 33.328638 | 168 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/utils/c2_model_loading.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import pickle
from collections import OrderedDict
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.registry import Registry
def _rename_basic_resnet_weights(layer... | 7,054 | 39.314286 | 129 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/utils/metric_logger.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import time
from collections import defaultdict
from collections import deque
from datetime import datetime
import torch
from .comm import is_main_process
class SmoothedValue(object):
"""Track a series of values and provide access to smooth... | 3,209 | 28.449541 | 84 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/utils/checkpoint.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging
import os
import torch
from maskrcnn_benchmark.utils.model_serialization import load_state_dict
from maskrcnn_benchmark.utils.c2_model_loading import load_c2_format
from maskrcnn_benchmark.utils.imports import import_file
from mask... | 5,507 | 35.72 | 87 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/utils/comm.py | """
This file contains primitives for multi-gpu communication.
This is useful when doing distributed training.
"""
import pickle
import time
import torch
import torch.distributed as dist
def get_world_size():
if not dist.is_available():
return 1
if not dist.is_initialized():
return 1
ret... | 3,370 | 27.567797 | 84 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/utils/model_zoo.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import sys
try:
from torch.hub import _download_url_to_file
from torch.hub import urlparse
from torch.hub import HASH_REGEX
except ImportError:
from torch.utils.model_zoo import _download_url_to_file
from torch.utils... | 3,046 | 47.365079 | 135 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/utils/collect_env.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import PIL
from torch.utils.collect_env import get_pretty_env_info
def get_pil_version():
return "\n Pillow ({})".format(PIL.__version__)
def collect_env_info():
env_str = get_pretty_env_info()
env_str += get_pil_version()
... | 338 | 21.6 | 71 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/utils/model_serialization.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from collections import OrderedDict
import logging
import torch
from maskrcnn_benchmark.utils.imports import import_file
def align_and_update_state_dicts(model_state_dict, loaded_state_dict):
"""
Strategy: suppose that the models that w... | 3,668 | 40.693182 | 91 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/utils/imports.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
if torch._six.PY3:
import importlib
import importlib.util
import sys
# from https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path?utm_medium=organic&utm_source=google_rich_qa&utm_campai... | 843 | 34.166667 | 168 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/build.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
import copy
import logging
import torch.utils.data
from maskrcnn_benchmark.utils.comm import get_world_size
from maskrcnn_benchmark.utils.imports import import_file
from . import datasets as D
from . import samplers
from .collate_b... | 7,264 | 37.036649 | 143 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/datasets/voc.py | import os
import torch
import torch.utils.data
from PIL import Image
import sys
if sys.version_info[0] == 2:
import xml.etree.cElementTree as ET
else:
import xml.etree.ElementTree as ET
from maskrcnn_benchmark.structures.bounding_box import BoxList
class PascalVOCDataset(torch.utils.data.Dataset):
CL... | 4,121 | 29.533333 | 118 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/datasets/concat_dataset.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import bisect
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset
class ConcatDataset(_ConcatDataset):
"""
Same as torch.utils.data.dataset.ConcatDataset, but exposes an extra
method for querying the sizes of the ima... | 766 | 30.958333 | 72 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/datasets/abstract.py | import torch
class AbstractDataset(torch.utils.data.Dataset):
"""
Serves as a common interface to reduce boilerplate and help dataset
customization
A generic Dataset for the maskrcnn_benchmark must have the following
non-trivial fields / methods implemented:
CLASSES - list/tuple:
... | 2,309 | 32.478261 | 80 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/datasets/coco.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torchvision
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.segmentation_mask import SegmentationMask
from maskrcnn_benchmark.structures.keypoint import PersonKeypoints
min_ke... | 3,864 | 35.462264 | 133 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/datasets/evaluation/coco/coco_eval.py | import logging
import tempfile
import os
import torch
from collections import OrderedDict
from tqdm import tqdm
from maskrcnn_benchmark.modeling.roi_heads.mask_head.inference import Masker
from maskrcnn_benchmark.structures.bounding_box import BoxList
from maskrcnn_benchmark.structures.boxlist_ops import boxlist_iou
... | 13,904 | 34.202532 | 95 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/samplers/grouped_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import torch
from torch.utils.data.sampler import BatchSampler
from torch.utils.data.sampler import Sampler
class GroupedBatchSampler(BatchSampler):
"""
Wraps another sampler to yield a mini-batch of indices.
It enfo... | 4,845 | 40.775862 | 88 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/samplers/iteration_based_batch_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from torch.utils.data.sampler import BatchSampler
class IterationBasedBatchSampler(BatchSampler):
"""
Wraps a BatchSampler, resampling from it until
a specified number of iterations have been sampled
"""
def __init__(self, ba... | 1,164 | 35.40625 | 71 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/samplers/distributed.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# Code is copy-pasted exactly as in torch.utils.data.distributed.
# FIXME remove this once c10d fixes the bug it has
import math
import torch
import torch.distributed as dist
from torch.utils.data.sampler import Sampler
class DistributedSampler(S... | 2,569 | 37.358209 | 86 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/data/transforms/transforms.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import random
import torch
import torchvision
from torchvision.transforms import functional as F
class Compose(object):
def __init__(self, transforms):
self.transforms = transforms
def __call__(self, image, target):
for ... | 2,589 | 27.461538 | 83 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/matcher.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
class Matcher(object):
"""
This class assigns to each predicted "element" (e.g., a box) a ground-truth
element. Each predicted element will have exactly zero or one matches; each
ground-truth element may be assigned t... | 5,129 | 44.39823 | 88 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/make_layers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Miscellaneous utility functions
"""
import torch
from torch import nn
from torch.nn import functional as F
from maskrcnn_benchmark.config import cfg
from maskrcnn_benchmark.layers import Conv2d
from maskrcnn_benchmark.modeling.poolers import P... | 3,576 | 28.081301 | 78 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/utils.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Miscellaneous utility functions
"""
import torch
def cat(tensors, dim=0):
"""
Efficient version of torch.cat that avoids a copy if there is only a single element in a list
"""
assert isinstance(tensors, (list, tuple))
if ... | 400 | 22.588235 | 97 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/poolers.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
import torch.nn.functional as F
from torch import nn
from maskrcnn_benchmark.layers import ROIAlign
from .utils import cat
class LevelMapper(object):
"""Determine which FPN level each RoI in a set of RoIs should map to based
... | 4,195 | 33.393443 | 90 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/balanced_positive_negative_sampler.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import torch
class BalancedPositiveNegativeSampler(object):
"""
This class samples batches, ensuring that they contain a fixed proportion of positives
"""
def __init__(self, batch_size_per_image, positive_fraction):
"""
... | 2,716 | 38.376812 | 90 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/box_coder.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import math
import torch
class BoxCoder(object):
"""
This class encodes and decodes a set of bounding boxes into
the representation used for training the regressors.
"""
def __init__(self, weights, bbox_xform_clip=math.log(1... | 3,367 | 34.083333 | 86 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/backbone/domain_attention_resnet.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Variant of the resnet module that takes cfg as an argument.
Example usage. Strings may be specified in the config file.
model = ResNet(
"StemWithFixedBatchNorm",
"BottleneckWithFixedBatchNorm",
"ResNet50StagesTo4",
... | 14,937 | 30.987152 | 108 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/backbone/resnet.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Variant of the resnet module that takes cfg as an argument.
Example usage. Strings may be specified in the config file.
model = ResNet(
"StemWithFixedBatchNorm",
"BottleneckWithFixedBatchNorm",
"ResNet50StagesTo4",
... | 12,772 | 29.557416 | 85 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/backbone/fbnet_builder.py | """
FBNet model builder
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import copy
import logging
import math
from collections import OrderedDict
import torch
import torch.nn as nn
from maskrcnn_benchmark.layers import (
BatchNorm2d,
Conv2d,
FrozenBatchNorm2d,
... | 24,964 | 29.078313 | 88 | py |
DA-Object-Detection | DA-Object-Detection-main/maskrcnn_benchmark/modeling/backbone/seresnet.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
Variant of the resnet module that takes cfg as an argument.
Example usage. Strings may be specified in the config file.
model = ResNet(
"StemWithFixedBatchNorm",
"BottleneckWithFixedBatchNorm",
"ResNet50StagesTo4",
... | 13,962 | 30.519187 | 93 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.