Search is not available for this dataset
repo
stringlengths
2
152
⌀
file
stringlengths
15
239
code
stringlengths
0
58.4M
file_length
int64
0
58.4M
avg_line_length
float64
0
1.81M
max_line_length
int64
0
12.7M
extension_type
stringclasses
364 values
null
ParlAI-main/website/postprocess_docs.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os NEEDLE3 = '&mdash; ParlAI documentation</title>' REPLACEMENT3 = """ &mdash; ParlAI Documentation</title> <li...
1,132
38.068966
95
py
null
ParlAI-main/website/static/css/home-theme.css
/*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */ /* * Copyright (c) Facebook, Inc. and its affiliates. * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ html { font-family: sans-serif; line-height: 1.15...
16,470
19.46087
130
css
null
ParlAI-main/website/static/css/parlai.css
/* * Copyright (c) Facebook, Inc. and its affiliates. * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ .navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:focus, .navbar-inverse .navbar-nav>.active>a:hover { b...
18,972
19.205538
130
css
null
ParlAI-main/website/templates/about.html
<section class="about wrap" style="margin-bottom: -20px"> <hr style="margin-top: 0px"> <article class="markdown-body"> {{{CONTENT}}} </article> <hr> </section>
184
22.125
57
html
null
ParlAI-main/website/templates/base.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> ...
4,191
52.063291
213
html
null
ParlAI-main/website/templates/error.html
<section class="about wrap"> <hr style="margin-top: 0px"> <div class="container"> <div style="margin-top: 30px"> Page not found. </div> </div> </section>
194
20.666667
38
html
null
ParlAI-main/website/templates/home.html
<div style="padding: 0 0; background-color: #000;"> <div style=" font-weight: bold; font-size: 20px; padding: 20px; max-width: 768px; margin: 0 auto; text-align: center; color: white;"> Support Ukraine 🇺🇦 <a href="https://opensource.fb.com/support-ukraine"> Help Provide Humanitarian Aid to...
8,782
52.883436
460
html
null
ParlAI-main/website/templates/project.html
<section class="project wrap" style="margin-bottom: -20px"> <hr style="margin-top: 0px"> <article class="markdown-body"> {{{CONTENT}}} </article> <hr> </section>
186
22.375
59
html
panopticapi
panopticapi-master/CONVERTERS.md
# Converters for COCO panoptic segmentation format Different COCO formats are described [here](http://cocodataset.org/#format-data). ## From COCO detection format to COCO panoptic format COCO detection format is used to store both COCO instance segmentation and COCO stuff annotations. The script `converters/detectio...
4,400
60.985915
490
md
panopticapi
panopticapi-master/README.md
# COCO 2018 Panoptic Segmentation Task API (Beta version) This API is an experimental version of [COCO 2018 Panoptic Segmentation Task API](http://cocodataset.org/#panoptic-2018). To install panopticapi, run: ``` pip install git+https://github.com/cocodataset/panopticapi.git ``` ## Summary **Evaluation script** [pan...
2,235
53.536585
345
md
panopticapi
panopticapi-master/setup.py
#-*- coding: utf-8 -*- from setuptools import setup, Extension setup( name='panopticapi', packages=['panopticapi'], package_dir = {'panopticapi': 'panopticapi'}, install_requires=[ 'numpy', 'Pillow', ], version='0.1', )
263
15.5
49
py
panopticapi
panopticapi-master/visualization.py
#!/usr/bin/env python2 ''' Visualization demo for panoptic COCO sample_data The code shows an example of color generation for panoptic data (with "generate_new_colors" set to True). For each segment distinct color is used in a way that it close to the color of corresponding semantic class. ''' from __future__ import a...
2,478
28.164706
78
py
panopticapi
panopticapi-master/cityscapes_gt_converter/__init__.py
0
0
0
py
panopticapi
panopticapi-master/cityscapes_gt_converter/cityscapes_panoptic_converter.py
#!/usr/bin/env python from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os, sys import json import glob import numpy as np import PIL.Image as Image from panopticapi.utils import IdGenerator, save_json try: #...
4,146
33.848739
103
py
panopticapi
panopticapi-master/converters/2channels2panoptic_coco_format.py
#!/usr/bin/env python ''' This script converts panoptic segmentation predictions stored in 2 channels panoptic format to COCO panoptic format. 2 channels format is described in the panoptic segmentation paper (https://arxiv.org/pdf/1801.00868.pdf). Two labels are assigned to each pixel of a segment: - semantic class l...
6,285
39.818182
108
py
panopticapi
panopticapi-master/converters/__init__.py
0
0
0
py
panopticapi
panopticapi-master/converters/detection2panoptic_coco_format.py
#!/usr/bin/env python ''' This script converts detection COCO format to panoptic COCO format. More information about the formats can be found here: http://cocodataset.org/#format-data. ''' from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import...
6,231
40
101
py
panopticapi
panopticapi-master/converters/panoptic2detection_coco_format.py
#!/usr/bin/env python ''' This script converts panoptic COCO format to detection COCO format. More information about the formats can be found here: http://cocodataset.org/#format-data. All segments will be stored in RLE format. Additional option: - using option '--things_only' the script can discard all stuff segments...
6,416
40.668831
106
py
panopticapi
panopticapi-master/converters/panoptic2semantic_segmentation.py
#!/usr/bin/env python ''' This script converts data in panoptic COCO format to semantic segmentation. All segments with the same semantic class in one image are combined together. Additional option: - using option '--things_others' the script combine all segments of thing classes into one segment with semantic class '...
9,338
42.640187
102
py
panopticapi
panopticapi-master/panopticapi/__init__.py
0
0
0
py
panopticapi
panopticapi-master/panopticapi/combine_semantic_and_instance_predictions.py
#!/usr/bin/env python ''' The script uses a simple procedure to combine semantic segmentation and instance segmentation predictions. The procedure is described in section 7 of the panoptic segmentation paper https://arxiv.org/pdf/1801.00868.pdf. On top of the procedure described in the paper. This script remove from p...
9,610
39.724576
111
py
panopticapi
panopticapi-master/panopticapi/evaluation.py
#!/usr/bin/env python from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import os, sys import numpy as np import json import time from datetime import timedelta from collections import defaultdict import argparse import m...
10,692
40.285714
180
py
panopticapi
panopticapi-master/panopticapi/utils.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import functools import traceback import json import numpy as np # The decorator is used to prints an error trhown inside process def get_traceback(f): @functools.wr...
3,301
32.02
83
py
Meta-GNN
Meta-GNN-master/README.md
### Meta-GNN: On Few-shot Node Classification in Graph Meta-learning #### Authors: * [Fan Zhou] * [Chengtai Cao](https://github.com/ChengtaiCao) * [Kunpeng Zhang] * [Goce Trajcevski] * [Ting Zhong] * [Ji Geng] #### Desccription of Meta-GNN source_code for Meta-GNN (implement of Meta-GNN): [Meta-GNN: On Few-shot Node...
1,148
19.890909
164
md
Meta-GNN
Meta-GNN-master/gcn_fewshot/args.py
import torch import argparse def get_citation_args(): parser = argparse.ArgumentParser() parser.add_argument('--train_shot', type=int, default=20, help='How many shot during meta-train') parser.add_argument('--test_shot', type=int, default=1, help='How many shot during meta-test') parser.add_argument(...
1,881
66.214286
132
py
Meta-GNN
Meta-GNN-master/gcn_fewshot/citation.py
import torch import torch.nn.functional as F import torch.optim as optim from itertools import combinations import random from args import get_citation_args from utils import load_citation, set_seed from models import get_model from metrics import accuracy def train_regression(model, train_features, train_labels, id...
6,884
39.739645
150
py
Meta-GNN
Meta-GNN-master/gcn_fewshot/metrics.py
def accuracy(output, labels): preds = output.max(1)[1].type_as(labels) correct = preds.eq(labels).double() correct = correct.sum() return correct / len(labels)
175
34.2
44
py
Meta-GNN
Meta-GNN-master/gcn_fewshot/models.py
import torch import torch.nn as nn from torch.nn import Module import torch.nn.functional as F from torch.nn.parameter import Parameter import math class GraphConvolution(Module): def __init__(self, in_features, out_features, bias=True): super(GraphConvolution, self).__init__() self.in_features = ...
2,014
30
83
py
Meta-GNN
Meta-GNN-master/gcn_fewshot/normalization.py
import numpy as np import scipy.sparse as sp def normalized_laplacian(adj): adj = sp.coo_matrix(adj) row_sum = np.array(adj.sum(1)) d_inv_sqrt = np.power(row_sum, -0.5).flatten() d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0. d_mat_inv_sqrt = sp.diags(d_inv_sqrt) return (sp.eye(adj.shape[0]) - d_mat_inv_sqrt...
3,025
28.666667
94
py
Meta-GNN
Meta-GNN-master/gcn_fewshot/utils.py
import numpy as np import scipy.sparse as sp import torch import sys import pickle as pkl import networkx as nx from normalization import fetch_normalization, row_normalize from sklearn.metrics import f1_score def accuracy(output, labels): preds = output.max(1)[1].type_as(labels) correct = preds.eq(labels).do...
3,272
32.397959
85
py
Meta-GNN
Meta-GNN-master/graph_embedding_fewshot/deepwalk.py
import numpy as np import networkx as nx import os from gensim.models import Word2Vec from sklearn.linear_model.logistic import LogisticRegression from sklearn.externals import joblib from itertools import combinations import random import torch directed = True p = 1.0 q = 1.0 num_walks = 1000 walk_length = 100 emb_si...
10,016
33.6609
158
py
Meta-GNN
Meta-GNN-master/graph_embedding_fewshot/node2vec.py
import numpy as np import networkx as nx import os from gensim.models import Word2Vec from sklearn.linear_model.logistic import LogisticRegression from sklearn.externals import joblib from itertools import combinations import random import torch directed = True p = 5.0 q = 1.0 num_walks = 1000 walk_length = 100 emb_si...
10,016
33.6609
158
py
Meta-GNN
Meta-GNN-master/graphsage_fewshot/graphsage.py
import argparse import random import abc import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from dgl import DGLGraph from dgl.data import register_data_args, load_data import dgl.function as fn from itertools import combinations class Aggregator(nn.Module): def __init__(self, g,...
13,359
39
147
py
Meta-GNN
Meta-GNN-master/meta_gnn/learner.py
import torch from torch import nn from torch.nn import functional as F class Learner(nn.Module): def __init__(self, config): super(Learner, self).__init__() self.config = config self.vars = nn.ParameterList() self.vars_bn = nn.ParameterList() for i, (name, param) in enumer...
5,558
41.113636
128
py
Meta-GNN
Meta-GNN-master/meta_gnn/meta.py
import torch import numpy as np from torch import nn from torch.nn import functional as F from torch import optim from learner import Learner from utils import f1 class Meta(nn.Module): def __init__(self, args, config): super(Meta, self).__init__() self.update_lr = args.update_lr self.me...
5,817
40.262411
110
py
Meta-GNN
Meta-GNN-master/meta_gnn/normalization.py
import numpy as np import scipy.sparse as sp def normalized_laplacian(adj): adj = sp.coo_matrix(adj) row_sum = np.array(adj.sum(1)) d_inv_sqrt = np.power(row_sum, -0.5).flatten() d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0. d_mat_inv_sqrt = sp.diags(d_inv_sqrt) return (sp.eye(adj.shape[0]) - d_mat_inv_sqrt...
3,025
28.666667
94
py
Meta-GNN
Meta-GNN-master/meta_gnn/sgc.py
import torch import numpy as np import argparse from itertools import combinations from utils import load_citation, sgc_precompute, set_seed from meta import Meta from sgc_data_generator import sgc_data_generator def main(args): step = args.step set_seed(args.seed) adj, features, labels = load_citation(...
4,468
47.053763
160
py
Meta-GNN
Meta-GNN-master/meta_gnn/sgc_data_generator.py
import random def sgc_data_generator(features, labels, node_num, select_array, task_num, n_way, k_spt, k_qry): x_spt = [] y_spt = [] x_qry = [] y_qry = [] class1_idx = [] class2_idx = [] labels_local = labels.clone().detach() select_class = random.sample(select_array, n_way) for ...
1,347
33.564103
96
py
Meta-GNN
Meta-GNN-master/meta_gnn/utils.py
import numpy as np import scipy.sparse as sp import torch import sys import pickle as pkl import networkx as nx from normalization import fetch_normalization, row_normalize from sklearn.metrics import f1_score def f1(output, labels): output = output.max(1)[1] output = output.cpu().detach().numpy() labels ...
3,234
31.35
85
py
Meta-GNN
Meta-GNN-master/sgc_fewshot/args.py
import torch import argparse def get_citation_args(): parser = argparse.ArgumentParser() parser.add_argument('--train_shot', type=int, default=20, help='How many shot during meta-train') parser.add_argument('--test_shot', type=int, default=1, help='How many shot during meta-test') parser.add_argument(...
1,679
63.615385
128
py
Meta-GNN
Meta-GNN-master/sgc_fewshot/citation.py
import torch import torch.nn.functional as F import torch.optim as optim from itertools import combinations import random from args import get_citation_args from utils import load_citation, sgc_precompute, set_seed from models import get_model from metrics import accuracy def train_regression(model, train_features, ...
6,616
39.347561
156
py
Meta-GNN
Meta-GNN-master/sgc_fewshot/metrics.py
def accuracy(output, labels): preds = output.max(1)[1].type_as(labels) correct = preds.eq(labels).double() correct = correct.sum() return correct / len(labels)
178
21.375
44
py
Meta-GNN
Meta-GNN-master/sgc_fewshot/models.py
import torch.nn as nn class SGC(nn.Module): def __init__(self, nfeat, nclass): super(SGC, self).__init__() self.W = nn.Linear(nfeat, nclass) def forward(self, x): return self.W(x) def get_model(model_opt, nfeat, nclass, cuda=True): if model_opt == 'SGC': model = SGC(nfea...
489
22.333333
83
py
Meta-GNN
Meta-GNN-master/sgc_fewshot/normalization.py
import numpy as np import scipy.sparse as sp def normalized_laplacian(adj): adj = sp.coo_matrix(adj) row_sum = np.array(adj.sum(1)) d_inv_sqrt = np.power(row_sum, -0.5).flatten() d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0. d_mat_inv_sqrt = sp.diags(d_inv_sqrt) return (sp.eye(adj.shape[0]) - d_mat_inv_sqrt...
3,025
28.666667
94
py
Meta-GNN
Meta-GNN-master/sgc_fewshot/utils.py
import numpy as np import scipy.sparse as sp import torch import sys import pickle as pkl import networkx as nx from normalization import fetch_normalization, row_normalize from sklearn.metrics import f1_score def accuracy(output, labels): preds = output.max(1)[1].type_as(labels) correct = preds.eq(labels).do...
3,404
31.740385
85
py
null
Tamanduatei_Vulnerability-main/README.md
# Tamanduatei Vulnerability This code calculates the point-wise vulnerability to the Tamanduatei basin. To execute this task we only need the <i>edgelist.dat</i> and <i>vulnerability.py</i>. The calculation will result in two results, one of them being the time it took in the <i>screen.out</i> file and the vulnerabili...
2,977
61.041667
379
md
null
Tamanduatei_Vulnerability-main/vulnerability.py
import igraph as ig import numpy as np import time import multiprocessing as mp f2 = open("screen.out", 'w') f = open("result.dat", "w") # Calculating the efficiency of a given network def eff_global(g, weights): N = g.vcount() eff = 0.0 sp = g.shortest_paths(weights=weights) for l i...
2,290
27.283951
108
py
null
FastDifferentiableMatSqrt-main/README.md
# Fast Differentiable Matrix Sqrt Root and Its Inverse <div align=center><center><b>Geometric Interpretation of Matrix Square Root and Inverse Square Root</b></center></div> <div align=center><img src="MatSqrt_Cover.jpg" width="60%"/></div> This repository constains the official Pytorch implementation of ICLR 22 pape...
2,749
40.666667
297
md
null
FastDifferentiableMatSqrt-main/torch_utils.py
from mpmath import * import numpy as np import torch mp.dps = 32 one = mpf(1) mp.pretty = True def f(x): return sqrt(one-x) # Derive the taylor and pade' coefficients for MTP, MPA a = taylor(f, 0, 10) pade_p, pade_q = pade(a, 5, 5) a = torch.from_numpy(np.array(a).astype(float)) pade_p = torch.from_numpy(np.arra...
4,447
36.066667
123
py
null
FastDifferentiableMatSqrt-main/Decorrelated BN/README.md
## Introduction The directory contains the experiment of our method on Decorrelated Batch Normalization. We use ResNet-18 and ResNet-50 models and validate on CIFAR10 and CIFAR100. ## Model Architecture <div align=center><img src="DBN.png" width="60%"/></div>
265
25.6
89
md
null
FastDifferentiableMatSqrt-main/Decorrelated BN/ZCANorm.py
from torch.nn.parameter import Parameter import torch import torch.nn as nn from torch_utils import * eps=1e-10 class BatchNorm(nn.Module): def __init__(self, num_features, groups=1, eps=1e-2, momentum=0.1, affine=True): super(BatchNorm, self).__init__() print('BatchNorm Group Num {}'.format(grou...
6,668
40.166667
130
py
null
FastDifferentiableMatSqrt-main/Decorrelated BN/main_cifar10.py
'''Train CIFAR10 with PyTorch.''' from __future__ import print_function import os os.environ['CUDA_LAUNCH_BLOCKING'] = "1" import time import torch import torch.nn as nn import torch.optim as optim import torch.backends.cudnn as cudnn import torchvision import torchvision.transforms as transforms import os import argpa...
5,988
31.906593
110
py
null
FastDifferentiableMatSqrt-main/Decorrelated BN/main_cifar100.py
'''Train CIFAR100 with PyTorch.''' from __future__ import print_function import os os.environ['CUDA_LAUNCH_BLOCKING'] = "1" import time import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import torch.backends.cudnn as cudnn import torchvision import torchvision.transforms as ...
6,065
33.271186
111
py
null
FastDifferentiableMatSqrt-main/Decorrelated BN/run.sh
#!/usr/bin/env bash CUDA_VISIBLE_DEVICES=0 python main_cifar100.py --norm='zcanormbatch' --batch_size=128 CUDA_VISIBLE_DEVICES=1 python main_cifar10.py --norm='zcanormbatch' --batch_size=128
191
47
85
sh
null
FastDifferentiableMatSqrt-main/Decorrelated BN/torch_utils.py
from mpmath import * import numpy as np import torch mp.dps = 32 one = mpf(1) mp.pretty = True def f(x): return sqrt(one-x) # Derive the taylor and pade' coefficients for MTP, MPA a = taylor(f, 0, 10) pade_p, pade_q = pade(a, 5, 5) a = torch.from_numpy(np.array(a).astype(float)) pade_p = torch.from_numpy(np.arra...
4,410
36.067227
123
py
null
FastDifferentiableMatSqrt-main/Decorrelated BN/utils.py
'''Some helper functions for PyTorch, including: - get_mean_and_std: calculate the mean and std value of dataset. - msr_init: net parameter initialization. - progress_bar: progress bar mimic xlua.progress. ''' import os import sys import time import math import torch.nn as nn import torch.nn.init as init ...
3,446
26.576
96
py
null
FastDifferentiableMatSqrt-main/Decorrelated BN/models/__init__.py
from resnet import *
21
10
20
py
null
FastDifferentiableMatSqrt-main/Decorrelated BN/models/resnet.py
import torch.nn as nn import torch.utils.model_zoo as model_zoo import torch __all__ = ['ResNet', 'resnet18', 'resnet18nips', 'resnet34', 'resnet50', 'resnet101', 'resnet152', 'resnext50_32x4d', 'resnext101_32x8d'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',...
13,640
35.279255
106
py
null
FastDifferentiableMatSqrt-main/Neural Style Transfer/README.md
## Introduction This directory contains the codes for the experiment of WCT-based neural style transfer. Our implementation is modified on the basis of the architecture used in [GD-WCT](https://github.com/WonwoongCho/GDWCT). ## Model Architecure <div align=center><img src="StyleTransfer.png" width="70%"/></div>
319
28.090909
119
md
null
FastDifferentiableMatSqrt-main/Neural Style Transfer/data_loader.py
from torch.utils import data from torchvision import transforms as T from torchvision.datasets import ImageFolder from PIL import Image import torch import os import random class UnalignedDataset(data.Dataset): def __init__(self, dataset, image_dir, transform, mode): self.transform = transform sel...
3,054
34.523256
144
py
null
FastDifferentiableMatSqrt-main/Neural Style Transfer/download.sh
FILE=$1 if [ $FILE == "celeba" ]; then # CelebA images and attribute labels URL=https://www.dropbox.com/s/d1kjpkqklf0uw77/celeba.zip?dl=0 ZIP_FILE=./datasets/celeba.zip mkdir -p ./datasets/ wget -N $URL -O $ZIP_FILE unzip $ZIP_FILE -d ./datasets/ rm $ZIP_FILE elif [ $FILE == 'pretrained'...
1,020
29.029412
97
sh
null
FastDifferentiableMatSqrt-main/Neural Style Transfer/model.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from utils.torch_utils import * class Content_Encoder(nn.Module): def __init__(self, conv_dim=64, repeat_num=4, norm='in', activation='relu'): super(Content_Encoder, self).__init__() layers = [] layers += ...
13,473
37.497143
155
py
null
FastDifferentiableMatSqrt-main/Neural Style Transfer/run.py
import torch import torch.nn as nn import torch.optim as optim from torch import cuda from data_loader import * from model import * import time import datetime import os from utils.util import * from torch.backends import cudnn from scipy.linalg import block_diag import lpips loss_fn = lpips.LPIPS(net='alex') class R...
15,403
39.324607
198
py
null
FastDifferentiableMatSqrt-main/Neural Style Transfer/configs/config.yaml
# GPU SETTINGS GPU1: 0 GPU2: 1 # Not used if DATA_PARALLEL is False. DATA_PARALLEL: False N_GROUP: 1 # The number of groups # DATA OPTIONS INPUT_DIM: 3 DATA_PATH: /home/ysong/ DATASET: vangogh2photo # The name of a dataset located in DATA_PATH, RESIZE: 216 CROP_SIZE: 216 # TRAINING SETTINGS NUM_ITERS: 200001 # Artwor...
1,678
26.52459
189
yaml
null
FastDifferentiableMatSqrt-main/Neural Style Transfer/utils/torch_utils.py
from mpmath import * import numpy as np import torch mp.dps = 32 one = mpf(1) mp.pretty = True def f(x): return sqrt(one-x) # Derive the taylor and pade' coefficients for MTP, MPA a = taylor(f, 0, 10) pade_p, pade_q = pade(a, 5, 5) a = torch.from_numpy(np.array(a).astype(float)) pade_p = torch.from_numpy(np.arra...
4,410
36.067227
123
py
null
FastDifferentiableMatSqrt-main/Neural Style Transfer/utils/util.py
import torch import torch.nn as nn from torch.autograd import Variable from torch.backends import cudnn from random import * import numpy as np import torch.nn.functional as F import yaml from torch.optim import lr_scheduler import torch.nn.init as init import random from torchvision.utils import save_image, make_grid ...
2,700
34.539474
110
py
null
FastDifferentiableMatSqrt-main/So-ViT/README.md
## Introduction This directory is the code of Second-order Vision Transformer (So-ViT). Our implementation is modified based on the official implementation in [So-ViT](https://github.com/jiangtaoxie/SoT.) ## Model Architecture <div align=center><img src="So_ViT.png" width="60%"/></div>
292
28.3
116
md
null
FastDifferentiableMatSqrt-main/So-ViT/So_ViT_10.sh
model=So_vit_10 ./distributed_train.sh 8 \ /imagenetpytorch \ --model $model \ -b 64 \ --lr 1e-3 \ --weight-decay .03 \ --img-size 224 \ --amp
143
15
26
sh
null
FastDifferentiableMatSqrt-main/So-ViT/So_ViT_14.sh
model=So_vit_14 ./distributed_train.sh 8 \ /imagenetpytorch \ --model $model \ -b 64 \ --lr 1e-3 \ --weight-decay .05 \ --img-size 224 \ --amp
143
15
26
sh
null
FastDifferentiableMatSqrt-main/So-ViT/So_ViT_19.sh
model=So_vit_19 ./distributed_train.sh 8 \ /data/datasets/ImageNet/images \ --model $model \ -b 64 \ --lr 1e-3 \ --weight-decay .05 \ --img-size 224 \ --amp
157
16.555556
32
sh
null
FastDifferentiableMatSqrt-main/So-ViT/So_ViT_7.sh
model=So_vit_7 ./distributed_train.sh 8 \ /imagenetpytorch \ --model $model \ -b 64 \ --lr 1e-3 \ --weight-decay .03 \ --img-size 224 \ --amp \ --resume
152
14.3
26
sh
null
FastDifferentiableMatSqrt-main/So-ViT/distributed_train.sh
#!/bin/bash NUM_PROC=$1 shift python3 -m torch.distributed.launch --nproc_per_node=$NUM_PROC main.py "$@"
107
17
75
sh
null
FastDifferentiableMatSqrt-main/So-ViT/main.py
""" This script is modified from pytorch-image-models by Ross Wightman (https://github.com/rwightman/pytorch-image-models/) It was started from an early version of the PyTorch ImageNet example (https://github.com/pytorch/examples/tree/master/imagenet) """ import argparse import time import yaml import os import logging...
40,629
46.134571
189
py
null
FastDifferentiableMatSqrt-main/So-ViT/src/__init__.py
from .so_vit import *
22
10.5
21
py
null
FastDifferentiableMatSqrt-main/So-ViT/src/so_vit.py
import torch import torch.nn as nn from timm.models.helpers import load_pretrained from timm.models.registry import register_model from timm.models.layers import trunc_normal_ from timm.models.senet import SEModule from timm.models.inception_resnet_v2 import BasicConv2d from timm.models.densenet import DenseBlock from...
6,641
36.314607
142
py
null
FastDifferentiableMatSqrt-main/So-ViT/src/model/classifier.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Function import numpy as np from ..normalization.MPN import MPN from ..normalization.svPN import svPN from ..normalization.PadeSqt import PadeSqt from ..normalization.SVDS import SVDS from ..representation.covariance import Co...
2,421
41.491228
106
py
null
FastDifferentiableMatSqrt-main/So-ViT/src/model/visualTokens.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Function import numpy as np from timm.models.densenet import DenseBlock from timm.models.densenet import DenseTransition class Bottleneck(nn.Module): """ Bottleneck block from ResNet """ def __init__(self, inp...
11,898
38.92953
145
py
null
FastDifferentiableMatSqrt-main/So-ViT/src/model/vitBlock.py
import torch import torch.nn as nn import numpy as np from timm.models.layers import DropPath class Mlp(nn.Module): def __init__(self, in_features, hidden_features=None, out_features=None, act_layer=nn.GELU, drop=0.): super().__init__() out_features = out_features or in_features hidden_feat...
3,050
36.666667
118
py
null
FastDifferentiableMatSqrt-main/So-ViT/src/normalization/MPN.py
''' @file: MPNCOV.py @author: Jiangtao Xie @author: Peihua Li Please cite the paper below if you use the code: Peihua Li, Jiangtao Xie, Qilong Wang and Zilin Gao. Towards Faster Training of Global Covariance Pooling Networks by Iterative Matrix Square Root Normalization. IEEE Int. Conf. on Computer Vision and Pattern ...
8,981
37.384615
246
py
null
FastDifferentiableMatSqrt-main/So-ViT/src/normalization/PadeSqt.py
import torch import torch.nn as nn from torch.autograd import Function from mpmath import * import numpy as np mp.dps = 32 one = mpf(1) mp.pretty = True def f(x): return sqrt(one-x) a = taylor(f, 0, 10) pade_p, pade_q = pade(a, 5, 5) a = torch.from_numpy(np.array(a).astype(float)).half() pade_p = torch.from_numpy(...
5,478
31.229412
148
py
null
FastDifferentiableMatSqrt-main/So-ViT/src/normalization/svPN.py
import torch import torch.nn as nn import torch.nn.functional as F from .MPN import Triuvec from torch.autograd import Function import numpy as np class svPN(nn.Module): def __init__(self, alpha=0.5, iterNum=1, svNum=1, init_weight='learn', ...
3,517
34.18
86
py
null
FastDifferentiableMatSqrt-main/So-ViT/src/representation/covariance.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Function import numpy as np class Covariance(nn.Module): def __init__(self, cov_type='norm', remove_mean=True, dimension_reduction=None, input_dim=2048, ...
3,290
32.581633
94
py
null
FastDifferentiableMatSqrt-main/TACP/CosineAnnealingLR.py
import math from torch.optim.lr_scheduler import _LRScheduler from bisect import bisect_right class WarmupCosineLR(_LRScheduler): def __init__(self, optimizer, milestones, min_ratio=0., cycle_decay=1., warmup_iters=1000, warmup_factor=1./10, last_epoch=-1): if not list(milestones) == sorted(milestones): ...
1,556
46.181818
131
py
null
FastDifferentiableMatSqrt-main/TACP/README.md
## Introduction This directory constains the implementation of our model for video action recognition. The codes are based on the official implementation in [TACP](https://github.com/ZilinGao/Temporal-attentive-Covariance-Pooling-Networks-for-Video-Recognition). ## Model Arhictecture <div align=center><img src="T...
350
30.909091
159
md
null
FastDifferentiableMatSqrt-main/TACP/functions.py
import os import matplotlib matplotlib.use('Agg') from matplotlib import pyplot as plt import scipy.io as sio import torch import torch.nn as nn import numpy as np from src.torchviz import make_dot, make_dot_from_trace class stats: def __init__(self, path, start_epoch): if start_epoch is not 0: ...
3,874
34.87963
83
py
null
FastDifferentiableMatSqrt-main/TACP/main.py
''' Implementation of 'Temporal-attentive Covariance Pooling Networks for Action Recognition' Authors: Zilin Gao, Qilong Wang, Bingbing Zhang, Qinghua Hu and Peihua Li. ''' import pdb import os import time import shutil import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim from torch.nn.util...
18,211
37.831557
116
py
null
FastDifferentiableMatSqrt-main/TACP/opts.py
''' Implementation of 'Temporal-attentive Covariance Pooling Networks for Action Recognition' Authors: Zilin Gao, Qilong Wang, Bingbing Zhang, Qinghua Hu and Peihua Li. ''' import argparse parser = argparse.ArgumentParser(description="PyTorch implementation of Temporal-attentive Covariance Pooling Networks") parser.ad...
6,125
63.484211
120
py
null
FastDifferentiableMatSqrt-main/TACP/test_models.py
''' Implementation of 'Temporal-attentive Covariance Pooling Networks for Action Recognition' Authors: Zilin Gao, Qilong Wang, Bingbing Zhang, Qinghua Hu and Peihua Li. ''' # Notice that this file has been modified to support ensemble testing import argparse import time import torch.nn.parallel import torch.optim fr...
13,551
37.174648
125
py
null
FastDifferentiableMatSqrt-main/TACP/ops/Identity.py
import torch class Identity(torch.nn.Module): def __init__(self): super(Identity, self).__init__() def forward(self, x): return x
155
18.5
40
py
null
FastDifferentiableMatSqrt-main/TACP/ops/TRNmodule.py
# the relation consensus module by Bolei import torch import torch.nn as nn import torch.nn.functional as F import torch.optim as optim from torch.autograd import Variable import numpy as np import pdb class RelationModule(torch.nn.Module): # this is the naive implementation of the n-frame relation module, as num...
7,696
43.75
149
py
null
FastDifferentiableMatSqrt-main/TACP/ops/__init__.py
from ops.basic_ops import *
27
27
27
py
null
FastDifferentiableMatSqrt-main/TACP/ops/basic_ops.py
import torch class Identity(torch.nn.Module): def forward(self, input): return input class SegmentConsensus(torch.nn.Module): def __init__(self, consensus_type, dim=1): super(SegmentConsensus, self).__init__() self.consensus_type = consensus_type self.dim = dim self....
1,015
25.736842
87
py
null
FastDifferentiableMatSqrt-main/TACP/ops/dataset.py
import torch.utils.data as data from PIL import Image import os import numpy as np from numpy.random import randint import pandas as pd class VideoRecord(object): def __init__(self, row): self._data = row @property def path(self): return self._data[0] @property def num_frames(sel...
10,941
48.067265
121
py
null
FastDifferentiableMatSqrt-main/TACP/ops/dataset_config.py
''' Implementation of 'Temporal-attentive Covariance Pooling Networks for Action Recognition' Authors: Zilin Gao, Qilong Wang, Bingbing Zhang, Qinghua Hu and Peihua Li. ''' import os ROOT_DATASET = './' def return_ucf101(modality): filename_categories = 'UCF101/labels/classInd.txt' if modality == 'RGB': ...
6,547
42.946309
113
py
null
FastDifferentiableMatSqrt-main/TACP/ops/keys_mapping.py
''' Implementation of 'Temporal-attentive Covariance Pooling Networks for Action Recognition' Authors: Zilin Gao, Qilong Wang, Bingbing Zhang, Qinghua Hu and Peihua Li. This file is modified from non-local code. ''' def adaptive_mapping_old_style_keys(checkpoint, k_new, args): if 'resnet152' in args.arch: ...
5,991
34.455621
102
py
null
FastDifferentiableMatSqrt-main/TACP/ops/models.py
from torch import nn import pdb from ops.basic_ops import ConsensusModule from ops.transforms import * from torch.nn.init import normal_, constant_ from ops.TCP.TCP_module import TCP # from ops.torchvision import res_224 as rsn #gzl 01.18 class TSN(nn.Module): def __init__(self, num_class, num_segments, modali...
19,933
40.966316
132
py
null
FastDifferentiableMatSqrt-main/TACP/ops/temporal_shift.py
# Code for "TSM: Temporal Shift Module for Efficient Video Understanding" # arXiv:1811.08383 # Ji Lin*, Chuang Gan, Song Han # {jilin, songhan}@mit.edu, ganchuang@csail.mit.edu import torch import torch.nn as nn import torch.nn.functional as F class TemporalShift(nn.Module): def __init__(self, net, n_segment=3, ...
7,405
35.303922
101
py
null
FastDifferentiableMatSqrt-main/TACP/ops/transforms.py
import torchvision import random from PIL import Image, ImageOps import numpy as np import numbers import math import torch class GroupRandomCrop(object): def __init__(self, size): if isinstance(size, numbers.Number): self.size = (int(size), int(size)) else: self.size = siz...
12,718
33.375676
116
py
null
FastDifferentiableMatSqrt-main/TACP/ops/utils.py
import numpy as np def softmax(scores): es = np.exp(scores - scores.max(axis=-1)[..., None]) return es / es.sum(axis=-1)[..., None] class AverageMeter(object): """Computes and stores the average and current value""" def __init__(self): self.reset() def reset(self): self.val = 0...
984
22.452381
64
py
null
FastDifferentiableMatSqrt-main/TACP/ops/MPNCOV/MPNCOV.py
''' @file: MPNCOV.py @author: Jiangtao Xie @author: Peihua Li Please cite the paper below if you use the code: Peihua Li, Jiangtao Xie, Qilong Wang and Zilin Gao. Towards Faster Training of Global Covariance Pooling Networks by Iterative Matrix Square Root Normalization. IEEE Int. Conf. on Computer Vision and Pattern ...
10,756
38.116364
246
py