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
XFL
XFL-master/test/common/crypto/one_time_pad/test_one_time_add.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
10,297
34.388316
135
py
XFL
XFL-master/test/common/fedavg/otp/test_trainer3.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
2,072
29.485294
87
py
XFL
XFL-master/test/common/fedavg/otp/test_trainer1.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
2,075
29.985075
87
py
XFL
XFL-master/test/common/fedavg/otp/random_input.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
2,199
24.882353
74
py
XFL
XFL-master/test/common/fedavg/otp/test_trainer2.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
2,072
29.485294
87
py
XFL
XFL-master/test/common/fedavg/otp/test_scheduler.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
2,756
28.967391
87
py
XFL
XFL-master/test/common/utils/test_model_preserver.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
1,425
35.564103
140
py
XFL
XFL-master/test/common/utils/test_config_parser.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
1,168
28.225
74
py
XFL
XFL-master/test/algorithm/core/test_optimizer.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
801
31.08
74
py
XFL
XFL-master/test/algorithm/framework/horizontal/test_h_poisson_regression.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
8,853
39.063348
117
py
XFL
XFL-master/test/algorithm/framework/horizontal/test_h_vgg_jax.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
7,515
41.948571
130
py
XFL
XFL-master/test/algorithm/framework/horizontal/test_h_nbafl.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
10,433
37.360294
130
py
XFL
XFL-master/test/algorithm/framework/transfer/test_transfer_logistic_regression.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
6,386
36.133721
106
py
XFL
XFL-master/test/algorithm/framework/vertical/test_kmeans.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
23,214
35.330203
123
py
XFL
XFL-master/test/algorithm/framework/vertical/test_logistic_regression.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
30,427
39.952894
120
py
XFL
XFL-master/test/algorithm/framework/vertical/test_xgboost.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
33,748
48.053779
557
py
XFL
XFL-master/test/algorithm/framework/vertical/test_xgb.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
24,834
36.402108
117
py
XFL
XFL-master/test/algorithm/framework/vertical/test_xgb2.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
43,089
43.560496
118
py
XFL
XFL-master/demo/horizontal/chatglm/chatglm-demo/quantization.py
from torch.nn import Linear from torch.nn.parameter import Parameter import bz2 import torch import base64 import ctypes from transformers.utils import logging from typing import List from functools import partial logger = logging.get_logger(__name__) try: from cpm_kernels.kernels.base import LazyKernelCModule,...
15,054
73.529703
7,375
py
XFL
XFL-master/demo/horizontal/chatglm/chatglm-demo/modeling_chatglm.py
""" PyTorch ChatGLM model. """ import math import copy import os import warnings import re import sys import torch import torch.utils.checkpoint import torch.nn.functional as F from torch import nn from torch.nn import CrossEntropyLoss, LayerNorm from torch.nn.utils import skip_init from typing import Optional, Tuple...
57,568
39.089833
121
py
XFL
XFL-master/docs/en/source/conf.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
3,375
32.76
79
py
XFL
XFL-master/docs/zh_CN/source/conf.py
# Copyright 2022 The XFL Authors. 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.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
3,378
32.79
79
py
ultrasound-nerve-segmentation
ultrasound-nerve-segmentation-master/train.py
from __future__ import print_function import os from skimage.transform import resize from skimage.io import imsave import numpy as np from keras.models import Model from keras.layers import Input, concatenate, Conv2D, MaxPooling2D, Conv2DTranspose from keras.optimizers import Adam from keras.callbacks import ModelChec...
5,352
33.75974
107
py
deep-video-mvs
deep-video-mvs-master/dataset/scannet-export/scannet-export.py
import os import random import numpy as np from multiprocessing import Pool import copy import os import struct import zlib from itertools import groupby import cv2 import imageio import numpy as np import torch COMPRESSION_TYPE_COLOR = {-1: 'unknown', 0: 'raw', 1: 'png', 2: 'jpeg'} COMPRESSION_TYPE_DEPTH = {-1: 'unkn...
12,059
40.586207
124
py
deep-video-mvs
deep-video-mvs-master/dvmvs/losses.py
from __future__ import division import torch from torch import nn class LossMeter(object): def __init__(self): self.count = 0.0 self.sum = 0.0 self.avg = 0.0 self.item_average = 0.0 def update(self, loss, count): self.sum += loss self.count += count s...
3,529
41.53012
146
py
deep-video-mvs
deep-video-mvs-master/dvmvs/utils.py
from __future__ import division import os import zipfile import cv2 import kornia import numpy as np import torch from path import Path from pytorch3d import structures, renderer from dvmvs.errors import compute_errors # GEOMETRIC UTILS def pose_distance(reference_pose, measurement_pose): """ :param refere...
19,349
47.014888
156
py
deep-video-mvs
deep-video-mvs-master/dvmvs/layers.py
import torch def down_conv_layer(input_channels, output_channels, kernel_size): return torch.nn.Sequential( torch.nn.Conv2d( input_channels, output_channels, kernel_size, padding=(kernel_size - 1) // 2, stride=1, bias=False), ...
1,984
29.075758
84
py
deep-video-mvs
deep-video-mvs-master/dvmvs/dataset_loader.py
import copy import random from functools import partial from multiprocessing import Manager from multiprocessing.pool import Pool import cv2 import numpy as np import torch from kornia import adjust_brightness, adjust_gamma, adjust_contrast from path import Path from torch.utils.data import Dataset, DataLoader from d...
21,202
38.192237
128
py
deep-video-mvs
deep-video-mvs-master/dvmvs/convlstm.py
import torch import torch.nn as nn from dvmvs.utils import warp_frame_depth class MVSLayernormConvLSTMCell(nn.Module): def __init__(self, input_dim, hidden_dim, kernel_size, activation_function=None): super(MVSLayernormConvLSTMCell, self).__init__() self.activation_function = activation_functio...
2,554
38.307692
116
py
deep-video-mvs
deep-video-mvs-master/dvmvs/train.py
import torch import torchvision from tqdm import tqdm from dvmvs.config import Config from dvmvs.losses import LossMeter from dvmvs.utils import save_checkpoint, save_optimizer, freeze_batchnorm def switch_mode(model, mode): if mode == 'train': for module in model: module.train() ...
8,579
56.583893
153
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/mvdepthnet/encoder.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Variable from dvmvs.utils import freeze_batchnorm def down_conv_layer(input_channels, output_channels, kernel_size): return nn.Sequential( nn.Conv2d( input_channels, output_channels, ...
3,979
28.051095
77
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/mvdepthnet/run-testing.py
import cv2 import numpy as np import torch from path import Path from tqdm import tqdm from dvmvs.baselines.mvdepthnet.decoder import Decoder from dvmvs.baselines.mvdepthnet.encoder import Encoder from dvmvs.config import Config from dvmvs.dataset_loader import PreprocessImage, load_image from dvmvs.utils import cost_...
9,324
48.078947
138
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/mvdepthnet/decoder.py
import torch import torch.nn as nn import torch.nn.functional as F from dvmvs.utils import freeze_batchnorm def down_conv_layer(input_channels, output_channels, kernel_size): return nn.Sequential( nn.Conv2d( input_channels, output_channels, kernel_size, padd...
3,920
28.044444
80
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/deltas/base_model.py
import collections from abc import ABCMeta, abstractmethod from torch import nn def dict_update(d, u): """Improved update for nested dictionaries. Arguments: d: The dictionary to be updated. u: The update dictionary. Returns: The updated dictionary. """ d = d.copy() ...
1,752
24.042857
75
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/deltas/utils.py
import torch def reorder_desc(desc, batch_sz): """Reorders Descriptors""" b, c, h, w = desc.shape desc = desc.view(-1, batch_sz, c, h, w) desc = desc.transpose(1, 0) return desc def pose_square(pose): """Converts pose matrix of size 3x4 to a square matrix of size 4x4""" pose_sh = pose....
1,006
24.175
73
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/deltas/superpoint.py
import torch import torchvision from .base_model import BaseModel def simple_nms(scores, radius): """Performs non maximum suppression on the heatmap using max-pooling. This method does not suppress contiguous points that have the same score. Arguments: scores: the score heatmap, with shape `[B, H...
9,883
38.536
153
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/deltas/densedepth.py
import math import torch import torch.nn as nn import torch.nn.functional as F from .base_model import BaseModel from .resnet_s2d import resnet50 def conv3x3(in_planes, out_planes, stride=1): """3x3 convolution with padding""" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, ...
13,604
37.109244
160
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/deltas/run-testing.py
import argparse import cv2 import numpy as np import torch.backends.cudnn as cudnn import torch.utils.data from path import Path from tqdm import tqdm from dvmvs.baselines.deltas import superpoint, triangulation, densedepth from dvmvs.baselines.deltas.utils import * from dvmvs.config import Config from dvmvs.dataset_...
15,377
46.462963
170
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/deltas/resnet_s2d.py
import torch.nn as nn __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152'] def conv3x3(in_planes, out_planes, stride=1, groups=1, dilation=1): """3x3 convolution with padding""" return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride, padding=di...
9,946
36.394737
106
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/deltas/triangulation.py
import numpy as np import torch from torch import svd from .base_model import BaseModel def homogeneous_to_euclidean(points): """Converts homogeneous points to euclidean Args: points numpy array or torch tensor of shape (N, M + 1): N homogeneous points of dimension M Returns: numpy arra...
22,576
37.527304
157
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/gpmvs/encoder.py
import torch import torch.nn as nn from dvmvs.utils import freeze_batchnorm def down_conv_layer(input_channels, output_channels, kernel_size): return nn.Sequential( nn.Conv2d( input_channels, output_channels, kernel_size, padding=(kernel_size - 1) // 2, ...
2,588
26.542553
66
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/gpmvs/run-testing.py
from copy import deepcopy import cv2 import numpy as np import torch from path import Path from scipy.linalg import expm from tqdm import tqdm from dvmvs.baselines.gpmvs.decoder import Decoder from dvmvs.baselines.gpmvs.encoder import Encoder from dvmvs.baselines.gpmvs.gplayer import GPlayer from dvmvs.config import ...
10,783
45.283262
153
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/gpmvs/decoder.py
import torch import torch.nn as nn import torch.nn.functional as F from dvmvs.utils import freeze_batchnorm def down_conv_layer(input_channels, output_channels, kernel_size): return nn.Sequential( nn.Conv2d( input_channels, output_channels, kernel_size, padd...
3,920
28.044444
80
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/gpmvs/gplayer.py
import math import torch from dvmvs.utils import freeze_batchnorm class GPlayer(torch.nn.Module): def __init__(self, device): super(GPlayer, self).__init__() self.gamma2 = torch.nn.Parameter(torch.randn(1).to(device).float(), requires_grad=True) self.ell = torch.nn.Parameter(torch.randn(...
1,637
37.093023
134
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/dpsnet/run-testing.py
import cv2 import numpy as np import torch from path import Path from tqdm import tqdm from dvmvs.baselines.dpsnet.dpsnet import PSNet from dvmvs.config import Config from dvmvs.dataset_loader import PreprocessImage, load_image from dvmvs.utils import save_results, InferenceTimer, visualize_predictions def predict()...
7,607
46.849057
138
py
deep-video-mvs
deep-video-mvs-master/dvmvs/baselines/dpsnet/dpsnet.py
from __future__ import print_function import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data import torch.utils.data from torch.autograd import Variable from dvmvs.utils import freeze_batchnorm pixel_coords = None def set_id_grid(depth): globa...
16,381
40.684478
157
py
deep-video-mvs
deep-video-mvs-master/dvmvs/pairnet/run-training.py
import datetime import itertools import os import numpy as np from path import Path from tensorboardX import SummaryWriter from torch.backends import cudnn from torch.utils.data import DataLoader from dvmvs.dataset_loader import MVSDataset from dvmvs.losses import LossMeter, update_losses from dvmvs.pairnet.model imp...
12,924
45.160714
132
py
deep-video-mvs
deep-video-mvs-master/dvmvs/pairnet/model.py
from collections import OrderedDict import torch from torchvision import models from torchvision.ops import FeaturePyramidNetwork from dvmvs.config import Config from dvmvs.layers import conv_layer, depth_layer_3x3 fpn_output_channels = 32 hyper_channels = 32 class StandardLayer(torch.nn.Module): def __init__(...
14,393
46.193443
127
py
deep-video-mvs
deep-video-mvs-master/dvmvs/pairnet/run-testing.py
import cv2 import numpy as np import torch from path import Path from tqdm import tqdm from dvmvs.config import Config from dvmvs.dataset_loader import PreprocessImage, load_image from dvmvs.pairnet.model import FeatureExtractor, FeatureShrinker, CostVolumeEncoder, CostVolumeDecoder from dvmvs.utils import cost_volume...
10,187
50.715736
138
py
deep-video-mvs
deep-video-mvs-master/dvmvs/pairnet/run-testing-online.py
import cv2 import numpy as np import torch from path import Path from tqdm import tqdm from dvmvs.config import Config from dvmvs.dataset_loader import PreprocessImage, load_image from dvmvs.keyframe_buffer import KeyframeBuffer from dvmvs.pairnet.model import FeatureExtractor, FeatureShrinker, CostVolumeEncoder, Cost...
9,280
48.897849
138
py
deep-video-mvs
deep-video-mvs-master/dvmvs/fusionnet/run-training.py
import datetime import itertools import os import numpy as np from path import Path from tensorboardX import SummaryWriter from torch.backends import cudnn from torch.utils.data import DataLoader from dvmvs.dataset_loader import MVSDataset from dvmvs.fusionnet.model import * from dvmvs.losses import LossMeter, update...
13,088
44.290657
144
py
deep-video-mvs
deep-video-mvs-master/dvmvs/fusionnet/model.py
from collections import OrderedDict import torch from torchvision import models from torchvision.ops import FeaturePyramidNetwork from dvmvs.config import Config from dvmvs.convlstm import MVSLayernormConvLSTMCell from dvmvs.layers import conv_layer, depth_layer_3x3 fpn_output_channels = 32 hyper_channels = 32 cla...
15,992
46.316568
127
py
deep-video-mvs
deep-video-mvs-master/dvmvs/fusionnet/run-testing.py
import cv2 import numpy as np import torch from dvmvs.config import Config from dvmvs.dataset_loader import PreprocessImage, load_image from dvmvs.fusionnet.model import FeatureExtractor, FeatureShrinker, CostVolumeEncoder, LSTMFusion, CostVolumeDecoder from dvmvs.utils import cost_volume_fusion, save_results, visualiz...
12,702
53.055319
149
py
deep-video-mvs
deep-video-mvs-master/dvmvs/fusionnet/run-testing-online.py
import cv2 import numpy as np import torch from path import Path from tqdm import tqdm from dvmvs.config import Config from dvmvs.dataset_loader import PreprocessImage, load_image from dvmvs.fusionnet.model import FeatureExtractor, FeatureShrinker, CostVolumeEncoder, LSTMFusion, CostVolumeDecoder from dvmvs.keyframe_b...
12,118
50.351695
149
py
featuretools
featuretools-main/featuretools/tests/testing_utils/mock_ds.py
from datetime import datetime import numpy as np import pandas as pd from woodwork.logical_types import ( URL, Boolean, Categorical, CountryCode, Datetime, Double, EmailAddress, Filepath, Integer, IPAddress, LatLong, NaturalLanguage, Ordinal, PersonFullName, ...
47,055
61.741333
2,445
py
scientific-re
scientific-re-main/main.py
import os import random import torch import numpy import torch.backends.cudnn from src.data.prepare_data import Preparedata from src.model.CNN import CNN from src.model.run import Run from src.parameters.parameters import Parameters class Controller(Parameters): def __init__(self): # prepare the data ...
1,999
26.027027
73
py
scientific-re
scientific-re-main/src/model/CNN.py
import torch from torch import nn import torch.nn.functional as F class CNN(torch.nn.Module): def __init__(self, params): super().__init__() self.device = params.device self.dropout = nn.Dropout(params.dropout) self.embedding_size = params.bert_emb_size + 2 * params.position_emb...
1,788
33.403846
125
py
scientific-re
scientific-re-main/src/model/run.py
import torch from sklearn.metrics import f1_score from torch import optim, nn from torch.utils.data import Dataset, DataLoader from transformers import AutoTokenizer, AutoModel class DatasetMaper(Dataset): def __init__(self, s, p1, p2, y): self.s = s self.p1 = p1 self.p2 = p2 self....
9,545
45.565854
200
py
scientific-re
scientific-re-main/src/parameters/parameters.py
from dataclasses import dataclass import torch @dataclass class Parameters: device = torch.device("cuda" if torch.cuda.is_available() else "cpu") seeds = [3828, 3152, 2396] # Files train = 'sample-data/sample-train.txt' train_relations = 'sample-data/sample-train-rel.txt' dev = 'sample-data/...
1,140
25.534884
106
py
taskgrouping
taskgrouping-master/taskonomy_loader.py
import torch.utils.data as data from PIL import Image, ImageOps import os import os.path import zipfile as zf import io import logging import random import copy import numpy as np import time import torch import multiprocessing import warnings import torchvision.transforms as transforms from multiprocessing import M...
10,600
29.81686
131
py
taskgrouping
taskgrouping-master/taskonomy_losses.py
import torch import collections sl=0 nl=0 nl2=0 nl3=0 dl=0 el=0 rl=0 kl=0 tl=0 al=0 cl=0 popular_offsets=collections.defaultdict(int) batch_number=0 def segment_semantic_loss(output,target,mask): global sl sl = torch.nn.functional.cross_entropy(output.float(),target.long().squeeze(dim=1),ignore_index=0,reduct...
6,961
27.650206
119
py
taskgrouping
taskgrouping-master/train_taskonomy.py
import argparse import os import shutil import time import platform import torch from torch.autograd import Variable import torch.nn as nn import torch.backends.cudnn as cudnn import torchvision.datasets as datasets from taskonomy_losses import * from taskonomy_loader import TaskonomyLoader from apex.parallel impo...
26,764
35.917241
160
py
taskgrouping
taskgrouping-master/read_training_history.py
import argparse import os import torch from collections import defaultdict from train_taskonomy import print_table parser = argparse.ArgumentParser(description='PyTorch ImageNet Training') parser.add_argument('--model_file', '-m', default='', type=str, metavar='PATH', help='path to latest checkpoin...
2,820
30.696629
83
py
taskgrouping
taskgrouping-master/sync_batchnorm/replicate.py
# -*- coding: utf-8 -*- # File : replicate.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import functools from torch.nn.parallel.da...
3,226
32.968421
115
py
taskgrouping
taskgrouping-master/sync_batchnorm/unittest.py
# -*- coding: utf-8 -*- # File : unittest.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import unittest import torch class TorchTes...
746
23.9
59
py
taskgrouping
taskgrouping-master/sync_batchnorm/batchnorm.py
# -*- coding: utf-8 -*- # File : batchnorm.py # Author : Jiayuan Mao # Email : maojiayuan@gmail.com # Date : 27/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import collections import contextlib import...
15,829
39.075949
116
py
taskgrouping
taskgrouping-master/sync_batchnorm/batchnorm_reimpl.py
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # File : batchnorm_reimpl.py # Author : acgtyrant # Date : 11/01/2018 # # This file is part of Synchronized-BatchNorm-PyTorch. # https://github.com/vacancy/Synchronized-BatchNorm-PyTorch # Distributed under MIT License. import torch import torch.nn as nn import torch...
2,385
30.813333
95
py
taskgrouping
taskgrouping-master/model_definitions/ozan_rep_fun.py
import torch.autograd import sys import math from .ozan_min_norm_solvers import MinNormSolver import statistics class OzanRepFunction(torch.autograd.Function): # def __init__(self,copies,noop=False): # super(OzanRepFunction,self).__init__() # self.copies=copies # self.noop=noop n=5 d...
7,442
34.442857
155
py
taskgrouping
taskgrouping-master/model_definitions/xception_taskonomy_small.py
""" Creates an Xception Model as defined in: Francois Chollet Xception: Deep Learning with Depthwise Separable Convolutions https://arxiv.org/pdf/1610.02357.pdf This weights ported from the Keras implementation. Achieves the following performance on the validation set: Loss:0.9173 Prec@1:78.892 Prec@5:94.292 REMEM...
29,185
34.37697
317
py
taskgrouping
taskgrouping-master/model_definitions/resnet_taskonomy.py
import torch.nn as nn import math import torch.nn.functional as F import torch.utils.model_zoo as model_zoo from torch.nn import init import torch from .ozan_rep_fun import ozan_rep_function,trevor_rep_function,OzanRepFunction,TrevorRepFunction #from .utils import load_state_dict_from_url __all__ = ['resnet18_taskon...
16,822
36.301552
154
py
taskgrouping
taskgrouping-master/model_definitions/ozan_min_norm_solvers.py
import numpy as np import torch import math class MinNormSolver: MAX_ITER = 250 STOP_CRIT = 1e-5 def _min_norm_element_from2(v1v1, v1v2, v2v2): """ Analytical solution for min_{c} |cx_1 + (1-c)x_2|_2^2 d is the distance (objective) optimzed v1v1 = <x1,x1> v1v2 = <x...
7,628
36.214634
147
py
taskgrouping
taskgrouping-master/model_definitions/xception_taskonomy_joined_decoder.py
""" Creates an Xception Model as defined in: Francois Chollet Xception: Deep Learning with Depthwise Separable Convolutions https://arxiv.org/pdf/1610.02357.pdf This weights ported from the Keras implementation. Achieves the following performance on the validation set: Loss:0.9173 Prec@1:78.892 Prec@5:94.292 REMEM...
13,355
31.183133
251
py
taskgrouping
taskgrouping-master/model_definitions/xception_taskonomy_new.py
""" """ import math import torch.nn as nn import torch.nn.functional as F import torch.utils.model_zoo as model_zoo from torch.nn import init import torch from .ozan_rep_fun import ozan_rep_function,trevor_rep_function,OzanRepFunction,TrevorRepFunction __all__ = ['xception_taskonomy_new','xception_taskonomy_new_fifth...
14,950
32.979545
181
py
vae_lesion_deficit
vae_lesion_deficit-main/utils.py
import numpy as np import random from torch.utils.data import Dataset, DataLoader from monai.transforms import * def resize(volume, target_size): resize_transform = Compose([Resize((target_size[0], target_size[1], target_size[2]))]) ...
4,837
35.104478
111
py
vae_lesion_deficit
vae_lesion_deficit-main/model.py
import math import torch import torch.nn as nn import torch.distributions as D import torch.nn.functional as F # Define two globals bce_fn = nn.BCELoss(reduction='none') Tensor = torch.cuda.FloatTensor def add_coords(x, just_coords=False): ''' This just the Uber CoordConv method extended to 3D. Definitely u...
13,659
36.322404
132
py
vae_lesion_deficit
vae_lesion_deficit-main/train.py
import numpy as np import os import argparse import torch import torch.optim as optim import datetime import torch as tc from model import ModelWrapper from utils import create_train_val_cal_loaders Tensor = torch.cuda.FloatTensor def count_parameters(model): return sum(p.numel() for p in model.parameters() if...
6,905
34.234694
107
py
GCNH
GCNH-main/main.py
""" Perform training and testing of GCNH on the 10 available splits """ import torch import torch.nn.functional as F import torch.optim as optim import numpy as np from utils import * from datetime import datetime from copy import deepcopy from scipy.sparse import coo_matrix from models import GCNH from tqdm import tq...
5,717
34.7375
161
py
GCNH
GCNH-main/utils.py
import scipy.sparse as sp import torch import numpy as np import pickle as pkl import sys import networkx as nx from dataset import CustomDataset import argparse import random from os import path as path """ READ ARGUMENTS """ def parse_boolean(value): """Parse boolean values passed as argument""" value = v...
12,193
38.980328
127
py
GCNH
GCNH-main/layers.py
""" GCNH Layer """ import torch import torch.nn as nn from torch.nn.modules.module import Module from torch_scatter import scatter class GCNH_layer(Module): def __init__(self, nfeat, nhid, maxpool): super(GCNH_layer, self).__init__() self.nhid = nhid self.maxpool = maxpool ...
1,967
28.373134
84
py
GCNH
GCNH-main/models.py
""" Define GCNH model """ import torch.nn as nn import torch.nn.functional as F from layers import GCNH_layer import torch from utils import * class GCNH(nn.Module): def __init__(self, nfeat, nclass, nhid, dropout, nlayers, maxpool): super(GCNH, self).__init__() self.nhid = nhid s...
1,619
28.454545
109
py
GCNH
GCNH-main/main_syn.py
""" Perform training and testing of GCNH on the synthetic dataset """ import torch import torch.nn.functional as F import torch.optim as optim import numpy as np from utils import * import os from tqdm import tqdm from copy import deepcopy from models import GCNH from scipy.sparse import coo_matrix if __name__ == "_...
4,675
36.111111
141
py
merc2020
merc2020-master/feature_extract.py
""" train code """ import os import tensorflow as tf import keras from keras.layers import Dense, Lambda, AveragePooling1D import numpy as np from keras import backend as K from keras.models import load_model, Model os.environ["CUDA_VISIBLE_DEVICES"]='0' def attention_pooling(model_input): """ attention pooli...
2,279
28.230769
117
py
merc2020
merc2020-master/train.py
""" train code """ import os import tensorflow as tf import keras from keras.callbacks import EarlyStopping, ModelCheckpoint from keras.layers import Dense, Conv2D, Dropout, MaxPooling2D, Input, Flatten, Lambda, AveragePooling1D, Activation, TimeDistributed, LSTM, Bidirectional, BatchNormalization import numpy as np fr...
4,570
34.434109
173
py
CLMR
CLMR-master/main.py
import argparse import pytorch_lightning as pl from pytorch_lightning.callbacks.early_stopping import EarlyStopping from pytorch_lightning import Trainer from pytorch_lightning.loggers import TensorBoardLogger from torch.utils.data import DataLoader # Audio Augmentations from torchaudio_augmentations import ( Rand...
5,117
28.583815
88
py
CLMR
CLMR-master/export.py
""" This script will extract a pre-trained CLMR PyTorch model to an ONNX model. """ import argparse import os import torch from collections import OrderedDict from copy import deepcopy from clmr.models import SampleCNN, Identity from clmr.utils import load_encoder_checkpoint, load_finetuner_checkpoint def convert_en...
2,321
28.025
87
py
CLMR
CLMR-master/setup.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # Note: To use the 'upload' functionality of this file, you must: # $ pipenv install twine --dev import io import os import sys from shutil import rmtree from setuptools import find_packages, setup, Command # Package meta-data. NAME = "clmr" DESCRIPTION = "Contrastive...
3,919
27.405797
86
py
CLMR
CLMR-master/linear_evaluation.py
import os import argparse import pytorch_lightning as pl from torch.utils.data import DataLoader from torchaudio_augmentations import Compose, RandomResizedCrop from pytorch_lightning import Trainer from pytorch_lightning.callbacks import EarlyStopping from pytorch_lightning.loggers import TensorBoardLogger from clmr....
4,555
28.393548
87
py
CLMR
CLMR-master/tests/test_spectogram.py
import unittest import torchaudio import torch.nn as nn from torchaudio_augmentations import * from clmr.datasets import AUDIO class TestAudioSet(unittest.TestCase): sample_rate = 16000 def get_audio_transforms(self, num_samples): transform = Compose( [ RandomResizedCrop(...
1,659
29.740741
86
py
CLMR
CLMR-master/tests/test_audioset.py
import unittest import torchaudio from torchaudio_augmentations import ( Compose, RandomApply, RandomResizedCrop, PolarityInversion, Noise, Gain, Delay, PitchShift, Reverb, ) from clmr.datasets import AUDIO class TestAudioSet(unittest.TestCase): sample_rate = 16000 def get...
1,500
29.632653
86
py
CLMR
CLMR-master/clmr/data.py
"""Wrapper for Torch Dataset class to enable contrastive training """ import torch from torch import Tensor from torch.utils.data import Dataset from torchaudio_augmentations import Compose from typing import Tuple, List class ContrastiveDataset(Dataset): def __init__(self, dataset: Dataset, input_shape: List[int...
1,258
27.613636
85
py
CLMR
CLMR-master/clmr/evaluation.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.utils.data import Dataset from tqdm import tqdm from sklearn import metrics def evaluate( encoder: nn.Module, finetuned_head: nn.Module, test_dataset: Dataset, dataset_name: str, audio_length: int, device, ) -> dict:...
1,921
30.508197
95
py
CLMR
CLMR-master/clmr/modules/callbacks.py
import matplotlib import matplotlib.pyplot as plt matplotlib.use("Agg") from pytorch_lightning.callbacks import Callback class PlotSpectogramCallback(Callback): def on_train_start(self, trainer, pl_module): if not pl_module.hparams.time_domain: x, y = trainer.train_dataloader.dataset[0] ...
725
24.928571
61
py
CLMR
CLMR-master/clmr/modules/linear_evaluation.py
import torch import torch.nn as nn import torchmetrics from copy import deepcopy from pytorch_lightning import LightningModule from torch import Tensor from torch.utils.data import DataLoader, Dataset, TensorDataset from typing import Tuple from tqdm import tqdm class LinearEvaluation(LightningModule): def __init...
3,975
31.590164
98
py
CLMR
CLMR-master/clmr/modules/supervised_learning.py
import torch import torchmetrics import torch.nn as nn from pytorch_lightning import LightningModule class SupervisedLearning(LightningModule): def __init__(self, args, encoder: nn.Module, output_dim: int): super().__init__() self.save_hyperparameters(args) self.encoder = encoder ...
2,082
29.632353
75
py
CLMR
CLMR-master/clmr/modules/contrastive_learning.py
import torch import torch.nn as nn from pytorch_lightning import LightningModule from torch import Tensor from simclr import SimCLR from simclr.modules import NT_Xent, LARS class ContrastiveLearning(LightningModule): def __init__(self, args, encoder: nn.Module): super().__init__() self.save_hyper...
2,587
35.450704
87
py
CLMR
CLMR-master/clmr/models/sample_cnn.py
import torch import torch.nn as nn from .model import Model class SampleCNN(Model): def __init__(self, strides, supervised, out_dim): super(SampleCNN, self).__init__() self.strides = strides self.supervised = supervised self.sequential = [ nn.Sequential( ...
1,881
26.676471
84
py
CLMR
CLMR-master/clmr/models/sample_cnn_xl.py
import torch import torch.nn as nn from .model import Model class SampleCNNXL(Model): def __init__(self, strides, supervised, out_dim): super(SampleCNN, self).__init__() self.strides = strides self.supervised = supervised self.sequential = [ nn.Sequential( ...
1,892
26.838235
84
py
CLMR
CLMR-master/clmr/models/shortchunk_cnn.py
import torch.nn as nn class ShortChunkCNN_Res(nn.Module): """ Short-chunk CNN architecture with residual connections. """ def __init__(self, n_channels=128, n_classes=50): super(ShortChunkCNN_Res, self).__init__() self.spec_bn = nn.BatchNorm2d(1) # CNN self.layer1 = ...
2,845
28.340206
85
py
CLMR
CLMR-master/clmr/models/model.py
import torch.nn as nn import numpy as np class Model(nn.Module): def __init__(self): super(Model, self).__init__() def initialize(self, m): if isinstance(m, (nn.Conv1d)): # nn.init.xavier_uniform_(m.weight) # if m.bias is not None: # nn.init.xavier_unif...
555
22.166667
82
py
CLMR
CLMR-master/clmr/models/sinc_net.py
import numpy as np import torch import torch.nn.functional as F import torch.nn as nn import sys from torch.autograd import Variable import math def flip(x, dim): xsize = x.size() dim = x.dim() + dim if dim < 0 else dim x = x.contiguous() x = x.view(-1, *xsize[dim:]) x = x.view(x.size(0), x.size(1...
16,565
28.902527
226
py