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
duckietown_imitation_learning
duckietown_imitation_learning-main/models/squeezenet.py
""" Copyright Notice: This is the official Duckietown implementation of the Squeezenet model: https://github.com/duckietown/gym-duckietown/blob/daffy/learning/imitation/iil-dagger/model/squeezenet.py """ import torch from torch import nn from torchvision import models import torch.nn.functional as F import to...
4,737
33.333333
109
py
duckietown_imitation_learning
duckietown_imitation_learning-main/models/model_gail.py
""" Copyright Notice: The implementation of our GAIL network was created based on the following public repository: https://github.com/Khrylx/PyTorch-RL """ import math import os import glob import torch import torch.nn as nn import torch.nn.functional as F import torchvision.models as models import numpy as ...
12,423
36.534743
135
py
duckietown_imitation_learning
duckietown_imitation_learning-main/models/model_dpl.py
import torch import torch.nn as nn import numpy as np import os import glob # If this variable is true, the image preprocessing wrapper will not only resize and crop the image, but it will also perform # a thresholding operation on the image to extract the white and yellow lines # So if it's True, the agent will lea...
8,137
44.719101
128
py
duckietown_imitation_learning
duckietown_imitation_learning-main/experiments/test.py
import argparse import glob import os import torch from utils.env import launch_env from utils.wrappers import wheel_to_steering from utils.wrappers import steering_to_wheel from utils.wrappers import preprocess_observation, preprocess_observation_GAIL, preprocess_observation_unit from utils.wrappers import ActionDela...
4,881
34.635036
131
py
duckietown_imitation_learning
duckietown_imitation_learning-main/experiments/test_unit_img2img.py
""" Copyright Notice: The implementation of our UNIT network was created based on the following public repository: https://github.com/eriklindernoren/PyTorch-GAN#unit """ import os import torch from torch.autograd import Variable from torch.utils.data import DataLoader import torchvision.transforms as transfo...
4,179
34.12605
96
py
duckietown_imitation_learning
duckietown_imitation_learning-main/experiments/train_unit_network.py
""" Copyright Notice: The implementation of our UNIT network was created based on the following public repository: https://github.com/eriklindernoren/PyTorch-GAN#unit """ import os import numpy as np import itertools import datetime import time import sys import torch from torch.autograd import Variable from ...
9,542
31.681507
109
py
duckietown_imitation_learning
duckietown_imitation_learning-main/experiments/log.py
import os import torch import argparse import numpy as np from utils.env import launch_env from utils.teacher import PurePursuitExpert from utils.loggers import Logger from utils.wrappers import steering_to_wheel from utils.wrappers import preprocess_observation, preprocess_observation_GAIL, preprocess_observation_uni...
9,099
37.559322
133
py
duckietown_imitation_learning
duckietown_imitation_learning-main/experiments/train_gail.py
""" Copyright Notice: The implementation of our GAIL network was created based on the following public repository: https://github.com/Khrylx/PyTorch-RL """ import os import glob import numpy as np import math from tqdm import tqdm from utils.loggers import Reader, ReplayBuffer from utils.wrappers import Action...
8,192
37.464789
165
py
duckietown_imitation_learning
duckietown_imitation_learning-main/experiments/eval.py
import argparse import torch import glob from utils.env import launch_env from utils.wrappers import ActionDelayWrapper from models.model_dpl import PytorchTrainer from models.squeezenet import Squeezenet from models.model_gail import Policy from utils.duckietown_world_evaluator import DuckietownWorldEvaluator # E...
2,306
27.8375
108
py
duckietown_imitation_learning
duckietown_imitation_learning-main/experiments/train.py
import argparse import time import numpy as np from tqdm import tqdm from utils.loggers import Reader from utils.gail_utils import extract_features_for_gail from models.model_dpl import PytorchTrainer from models.model_gail import PolicyPretrainer from models.model_unit_controller import UnitControllerTrainer from t...
6,873
31.2723
116
py
duckietown_imitation_learning
duckietown_imitation_learning-main/utils/gail_utils.py
""" Copyright Notice: The implementation of our GAIL network was created based on the following public repository: https://github.com/Khrylx/PyTorch-RL """ import torch import torch.nn as nn import torchvision.models as models import numpy as np from tqdm import tqdm from utils.loggers import Reader from uti...
5,871
33.745562
140
py
duckietown_imitation_learning
duckietown_imitation_learning-main/utils/unit_utils.py
""" Copyright Notice: The implementation of our UNIT network was created based on the following public repository: https://github.com/eriklindernoren/PyTorch-GAN#unit """ import glob import random import os from torch.utils.data import Dataset from PIL import Image import torchvision.transforms as transforms ...
1,172
31.583333
103
py
duckietown_imitation_learning
duckietown_imitation_learning-main/utils/wrappers.py
import gym from gym import spaces from gym_duckietown.simulator import Simulator import numpy as np import cv2 import torch from torchvision.transforms import ToTensor, Normalize, Compose # If this variable is true, the image preprocessing wrapper will not only resize and crop the image, but it will also perform # a t...
7,103
34.878788
185
py
PyDE
PyDE-master/doc/source/conf.py
# -*- coding: utf-8 -*- # # PyDE documentation build configuration file, created by # sphinx-quickstart on Mon Sep 23 16:00:28 2013. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All co...
9,101
30.825175
166
py
PRD
PRD-master/Agent/MAA2C/a2c_agent.py
import numpy as np import torch import torch.optim as optim from torch.distributions import Categorical from a2c_model import * import torch.nn.functional as F class A2CAgent: def __init__( self, env, arguments ): self.env = env self.env_name = arguments.environment self.value_lr = arguments.value_l...
10,489
37.708487
181
py
PRD
PRD-master/Agent/MAA2C/maa2c.py
from comet_ml import Experiment import os import torch import numpy as np from torch.utils.tensorboard import SummaryWriter from a2c_agent import A2CAgent import datetime class MAA2C: def __init__(self, env, arguments): self.device = arguments.device self.env = env self.save_gif = arguments.save_gif self.s...
14,881
40.921127
319
py
PRD
PRD-master/Agent/MAA2C/a2c_model.py
from typing import Any, List, Tuple, Union import torch import torch.nn as nn import torch.nn.functional as F import numpy as np import datetime import math class MLPPolicyNetwork(nn.Module): def __init__(self,state_dim,num_agents,action_dim,device): super(MLPPolicyNetwork,self).__init__() self.state_dim = stat...
9,998
39.979508
158
py
himp-gnn
himp-gnn-master/train_tox21.py
import argparse import torch from torch.optim import Adam import numpy as np from sklearn.metrics import roc_auc_score from ogb.graphproppred import PygGraphPropPredDataset from torch_geometric.data import DataLoader from torch_geometric.transforms import Compose from transform import JunctionTree from model import ...
3,928
30.18254
79
py
himp-gnn
himp-gnn-master/train_zinc_full.py
import argparse import torch from torch.optim import Adam from torch.optim.lr_scheduler import ReduceLROnPlateau from torch_geometric.datasets import ZINC from torch_geometric.data import DataLoader from transform import JunctionTree from model import Net parser = argparse.ArgumentParser() parser.add_argument('--de...
3,007
30.663158
79
py
himp-gnn
himp-gnn-master/transform.py
import torch from torch_geometric.data import Data from torch_geometric.utils import tree_decomposition from rdkit import Chem from rdkit.Chem.rdchem import BondType bonds = [BondType.SINGLE, BondType.DOUBLE, BondType.TRIPLE, BondType.AROMATIC] def mol_from_data(data): mol = Chem.RWMol() x = data.x if data...
1,651
27.982456
78
py
himp-gnn
himp-gnn-master/model.py
import torch import torch.nn.functional as F from torch.nn import Embedding, ModuleList from torch.nn import Sequential, Linear, BatchNorm1d, ReLU from torch_scatter import scatter from torch_geometric.nn import GINConv, GINEConv class AtomEncoder(torch.nn.Module): def __init__(self, hidden_channels): sup...
6,318
34.700565
79
py
himp-gnn
himp-gnn-master/train_zinc_subset.py
import argparse import torch from torch.optim import Adam from torch.optim.lr_scheduler import ReduceLROnPlateau from torch_geometric.datasets import ZINC from torch_geometric.data import DataLoader from transform import JunctionTree from model import Net parser = argparse.ArgumentParser() parser.add_argument('--de...
3,047
31.084211
79
py
himp-gnn
himp-gnn-master/train_ogbpcba.py
import argparse import torch from torch.optim import Adam from ogb.graphproppred import PygGraphPropPredDataset, Evaluator from torch_geometric.data import DataLoader from torch_geometric.transforms import Compose from transform import JunctionTree from model import Net parser = argparse.ArgumentParser() parser.add...
3,435
28.878261
79
py
himp-gnn
himp-gnn-master/train_muv.py
import argparse import torch from torch.optim import Adam import numpy as np from sklearn.metrics import roc_auc_score from ogb.graphproppred import PygGraphPropPredDataset from torch_geometric.data import DataLoader from torch_geometric.transforms import Compose from transform import JunctionTree from model import ...
3,924
30.150794
79
py
himp-gnn
himp-gnn-master/train_ogbhiv.py
import argparse import torch from torch.optim import Adam from ogb.graphproppred import PygGraphPropPredDataset, Evaluator from torch_geometric.data import DataLoader from torch_geometric.transforms import Compose from transform import JunctionTree from model import Net parser = argparse.ArgumentParser() parser.add...
3,368
28.814159
79
py
himp-gnn
himp-gnn-master/train_hiv.py
import argparse import torch from torch.optim import Adam import numpy as np from sklearn.metrics import roc_auc_score from ogb.graphproppred import PygGraphPropPredDataset from torch_geometric.data import DataLoader from torch_geometric.transforms import Compose from transform import JunctionTree from model import ...
3,926
30.166667
79
py
focal-frequency-loss
focal-frequency-loss-master/setup.py
import setuptools with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="focal_frequency_loss", version="0.3.0", author="Liming Jiang", author_email="liming002@ntu.edu.sg", description="Focal Frequency Loss for Image Reconstruction and Synthesis - Official PyTo...
780
31.541667
112
py
focal-frequency-loss
focal-frequency-loss-master/VanillaAE/test.py
from __future__ import print_function import argparse import os import random import numpy as np import torch import torch.backends.cudnn as cudnn from PIL import Image from tqdm import tqdm from networks import MLP from utils import get_dataloader, print_and_write_log, set_random_seed parser = argparse.ArgumentPar...
5,344
39.801527
130
py
focal-frequency-loss
focal-frequency-loss-master/VanillaAE/utils.py
import os import random import numpy as np import torch import torch.nn.init as init import torch.utils.data import torchvision.transforms as transforms from data import ImageFolderAll, ImageFilelist, ImagePairFilelist def get_dataloader(opt): if opt.dataroot is None: raise ValueError('`dataroot` parame...
4,870
42.882883
126
py
focal-frequency-loss
focal-frequency-loss-master/VanillaAE/data.py
############################################################################### # Code from # https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py # Modified the original code so that `ImageFolderAll` also loads images from # the current directory as well as the subdirectories ##################...
4,016
29.9
94
py
focal-frequency-loss
focal-frequency-loss-master/VanillaAE/networks.py
############################################################################### # Part of code from # https://github.com/NVlabs/MUNIT/blob/master/networks.py ############################################################################### import torch.nn as nn class MLP(nn.Module): def __init__(self, input_dim, o...
5,895
34.95122
150
py
focal-frequency-loss
focal-frequency-loss-master/VanillaAE/models.py
import os import torch import torch.nn as nn import torch.optim as optim from focal_frequency_loss import FocalFrequencyLoss as FFL from networks import MLP from utils import print_and_write_log, weights_init class VanillaAE(nn.Module): def __init__(self, opt): super(VanillaAE, self).__init__() ...
2,783
31
101
py
focal-frequency-loss
focal-frequency-loss-master/VanillaAE/train.py
from __future__ import print_function import argparse import os import random import torch import torch.backends.cudnn as cudnn import torchvision.utils as vutils from tqdm import tqdm from models import VanillaAE from utils import get_dataloader, print_and_write_log, set_random_seed parser = argparse.ArgumentParse...
5,165
46.394495
143
py
focal-frequency-loss
focal-frequency-loss-master/metrics/metric_utils.py
####################################################################################### # Part of code from # https://github.com/open-mmlab/mmediting/blob/master/mmedit/core/evaluation/metrics.py ####################################################################################### import cv2 import lpips as lpips_or...
11,939
34.430267
108
py
focal-frequency-loss
focal-frequency-loss-master/focal_frequency_loss/focal_frequency_loss.py
import torch import torch.nn as nn # version adaptation for PyTorch > 1.7.1 IS_HIGH_VERSION = tuple(map(int, torch.__version__.split('+')[0].split('.'))) > (1, 7, 1) if IS_HIGH_VERSION: import torch.fft class FocalFrequencyLoss(nn.Module): """The torch.nn.Module class that implements focal frequency loss - a...
5,065
43.052174
125
py
pba
pba-master/pba/data_utils.py
# Copyright 2018 The TensorFlow 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 applicab...
20,061
44.184685
109
py
Quatrain
Quatrain-master/learn/tool.py
""" sentence2vec : transfer sentences to vectors loaddata: load train/test/valid datas evaluation_metrics: return scores of (recall_p, recall_n, acc, prc, rc, f1, auc_) """ import numpy as np import torch from sklearn.metrics import roc_curve, auc, accuracy_score, recall_score, precision_score from sklearn.metrics imp...
3,856
35.733333
116
py
Quatrain
Quatrain-master/learn/test.py
import torch import torch.nn as nn import torch.optim import numpy as np seed = 3 torch.manual_seed(seed) torch.backends.cudnn.deterministric = True torch.backends.cudnn.benchmark = False import sys sys.path.append('../preprocess/') from tool import sentence2vec, loaddata, rightness, evaluation_metrics from constant...
4,545
35.66129
207
py
Quatrain
Quatrain-master/experiment/ML4Prediciton.py
from sklearn.preprocessing import StandardScaler, MinMaxScaler, Normalizer from sklearn.tree import DecisionTreeClassifier from sklearn.linear_model import LogisticRegression from sklearn.ensemble import RandomForestClassifier from sklearn.naive_bayes import GaussianNB from sklearn.model_selection import KFold, Stratif...
6,175
45.787879
238
py
Quatrain
Quatrain-master/preprocess/data_util.py
import json import sys import time from constants import Output_DATA_DIR, Origin_DATA_DIR <<<<<<< HEAD import nltk from nltk.corpus import stopwords ======= >>>>>>> 45fdc9b5e77fd91508f00a1412fc0e9b4c6aaadd #PyTorch-packages import torch import torch.nn as nn import torch.optim #from torch.autograd import Variable #...
6,876
29.295154
119
py
Quatrain
Quatrain-master/preprocess/bugReportDownloader.py
import sys import json import os import pickle import time import requests from urllib.request import urlopen from urllib import error import urllib import logging import socket from bs4 import BeautifulSoup from lxml import etree timeout = 30 socket.setdefaulttimeout(timeout) hdr = { 'User-Agent': 'Mozilla/5.0 ...
6,251
32.079365
125
py
Quatrain
Quatrain-master/CC2Vec/lmg_cli.py
import argparse import pickle import re from os import walk, path from CC2Vec.lmg_padding import processing_data from CC2Vec.lmg_utils import mini_batches, commit_msg_label from tqdm import tqdm import torch from CC2Vec.lmg_cc2ftr_model import HierachicalRNN def read_args_lmg(): parser = argparse.ArgumentParser() ...
7,009
43.649682
149
py
Quatrain
Quatrain-master/CC2Vec/lmg_cc2ftr_train.py
from CC2Vec.lmg_utils import mini_batches, commit_msg_label import os import datetime import torch.nn as nn from tqdm import tqdm import torch from CC2Vec.lmg_cc2ftr_model import HierachicalRNN from CC2Vec.lmg_utils import save def train_model(data, params): msg, pad_added_code, pad_removed_code, dict_msg, dict_c...
2,170
39.962264
133
py
Quatrain
Quatrain-master/CC2Vec/lmg_cc2ftr_extracted.py
from CC2Vec.lmg_utils import mini_batches, commit_msg_label from tqdm import tqdm import torch from CC2Vec.lmg_cc2ftr_model import HierachicalRNN import pickle def extracted_cc2ftr(data, params): msg, pad_added_code, pad_removed_code, dict_msg, dict_code = data labels = commit_msg_label(data=msg, dict_msg=dict...
1,742
42.575
149
py
Quatrain
Quatrain-master/CC2Vec/lmg_cc2ftr_model.py
import torch import torch.nn.functional as F import torch.nn as nn import numpy as np from torch.autograd import Variable # Make the the multiple attention with word vectors. def attention_mul(rnn_outputs, att_weights): attn_vectors = None for i in range(rnn_outputs.size(0)): h_i = rnn_outputs[i] ...
10,209
41.719665
116
py
Quatrain
Quatrain-master/CC2Vec/lmg_utils.py
import os import torch import numpy as np import math import re def commit_msg_label(data, dict_msg): labels_ = np.array([1 if w in d.split() else 0 for d in data for w in dict_msg]) labels_ = np.reshape(labels_, (int(labels_.shape[0] / len(dict_msg)), len(dict_msg))) return labels_ def save(model, save_...
4,294
37.348214
115
py
Quatrain
Quatrain-master/representation/CC2Vec/lmg_cli.py
import argparse import pickle import re from os import walk, path from representation.CC2Vec.lmg_padding import processing_data from representation.CC2Vec.lmg_utils import mini_batches, commit_msg_label from tqdm import tqdm import torch from representation.CC2Vec.lmg_cc2ftr_model import HierachicalRNN def read_args_l...
7,821
44.213873
149
py
Quatrain
Quatrain-master/representation/CC2Vec/lmg_cc2ftr_train.py
from representation.CC2Vec.lmg_utils import mini_batches, commit_msg_label import os import datetime import torch.nn as nn from tqdm import tqdm import torch from representation.CC2Vec.lmg_cc2ftr_model import HierachicalRNN from representation.CC2Vec.lmg_utils import save def train_model(data, params): msg, pad_a...
2,215
40.811321
133
py
Quatrain
Quatrain-master/representation/CC2Vec/lmg_cc2ftr_extracted.py
from .lmg_utils import mini_batches, commit_msg_label import tqdm import torch from representation.CC2Vec.lmg_cc2ftr_model import HierachicalRNN import pickle def extracted_cc2ftr(data, params): msg, pad_added_code, pad_removed_code, dict_msg, dict_code = data labels = commit_msg_label(data=msg, dict_msg=dict_...
1,741
42.55
149
py
Quatrain
Quatrain-master/representation/CC2Vec/lmg_cc2ftr_model.py
import torch import torch.nn.functional as F import torch.nn as nn import numpy as np from torch.autograd import Variable # Make the the multiple attention with word vectors. def attention_mul(rnn_outputs, att_weights): attn_vectors = None for i in range(rnn_outputs.size(0)): h_i = rnn_outputs[i] ...
10,125
41.725738
116
py
Quatrain
Quatrain-master/representation/CC2Vec/lmg_utils.py
import os import torch import numpy as np import math import re def commit_msg_label(data, dict_msg): labels_ = np.array([1 if w in d.split() else 0 for d in data for w in dict_msg]) labels_ = np.reshape(labels_, (int(labels_.shape[0] / len(dict_msg)), len(dict_msg))) return labels_ def save(model, save_...
4,294
37.348214
115
py
MvMM-RegNet
MvMM-RegNet-master/src_3d/core/model_ddf_mvmm_label_base.py
# -*- coding: utf-8 -*- """ Unified Multi-Atlas Segmentation implementations using dense displacement fields for model construction and training. The optimization is based on the multivariate mixture model of the target image and atlas probabilistic model. @author: Xinzhe Luo """ from __future__ import print_function...
67,761
59.447814
124
py
MvMM-RegNet
MvMM-RegNet-master/src_3d/core/radam.py
import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from tensorflow.python.ops import control_flow_ops from tensorflow.python.ops import math_ops, state_ops, array_ops from tensorflow.python.ops import resource_variable_ops from tensorflow.python.training impo...
13,125
47.795539
119
py
MvMM-RegNet
MvMM-RegNet-master/src_3d/core/image_dataset.py
# -*- coding: utf-8 -*- """ Image IO and pre-processing for testing multi-stage registration network of the unified multi-atlas segmentation framework. @author: Xinzhe Luo """ from __future__ import print_function, division, absolute_import, unicode_literals import glob # import random import itertools import loggin...
29,477
52.209386
179
py
MvMM-RegNet
MvMM-RegNet-master/src_3d/core/networks.py
# -*- coding: utf-8 -*- """ Network architectures for medical image registration. @author: Xinzhe Luo """ from __future__ import print_function, division, absolute_import, unicode_literals from core.layers import * from collections import OrderedDict import logging logging.basicConfig(level=logging.INFO, format='%(a...
20,757
56.501385
121
py
MvMM-RegNet
MvMM-RegNet-master/src_3d/core/layers.py
# -*- coding: utf-8 -*- """ Auxiliary functions and operations for network construction, some of which have been deprecated for high-level modules in TensorFlow. @author: Xinzhe Luo """ from __future__ import print_function, division, absolute_import, unicode_literals import tensorflow as tf import numpy as np from c...
42,974
45.309267
123
py
MvMM-RegNet
MvMM-RegNet-master/src_2d/core/image_2d_dataset.py
# -*- coding: utf-8 -*- """ Image IO and pre-processing for input pipeline. @author: Xinzhe Luo """ from __future__ import print_function, division, absolute_import, unicode_literals import glob from random import sample import itertools import logging # import cv2 import os # import nibabel as nib from PIL import I...
27,785
50.55102
139
py
MvMM-RegNet
MvMM-RegNet-master/src_2d/core/model_2d_ddf_mvmm_label_base.py
# -*- coding: utf-8 -*- """ Unified Multi-Atlas Segmentation implementations using dense displacement fields for model construction and training. The optimization is based on the multi-variate mixture model of the target image and atlas probabilistic labels. @author: Xinzhe Luo """ from __future__ import print_functi...
63,712
59.794847
129
py
MvMM-RegNet
MvMM-RegNet-master/src_2d/core/layers_2d.py
# -*- coding: utf-8 -*- """ Auxiliary functions and operations for network construction, some of which have been deprecated for high-level modules in TensorFlow. @author: Xinzhe Luo """ from __future__ import print_function, division, absolute_import, unicode_literals import tensorflow as tf import numpy as np from c...
41,961
42.80167
123
py
MvMM-RegNet
MvMM-RegNet-master/src_2d/core/networks_2d.py
# -*- coding: utf-8 -*- """ Network architectures for medical image registration. @author: Xinzhe Luo """ from __future__ import print_function, division, absolute_import, unicode_literals from core.layers_2d import * from collections import OrderedDict import logging logging.basicConfig(level=logging.INFO, format='...
19,976
61.040373
125
py
ImageNet21K
ImageNet21K-main/train_single_label_from_scratch.py
# -------------------------------------------------------- # ImageNet-21K Pretraining for The Masses # Copyright 2021 Alibaba MIIL (c) # Licensed under MIT License [see the LICENSE file for details] # Written by Tal Ridnik # -------------------------------------------------------- import argparse import time import to...
4,730
35.392308
120
py
ImageNet21K
ImageNet21K-main/train_single_label.py
# -------------------------------------------------------- # ImageNet-21K Pretraining for The Masses # Copyright 2021 Alibaba MIIL (c) # Licensed under MIT License [see the LICENSE file for details] # Written by Tal Ridnik # -------------------------------------------------------- import argparse import time import to...
4,691
35.092308
120
py
ImageNet21K
ImageNet21K-main/train_semantic_softmax.py
# -------------------------------------------------------- # ImageNet-21K Pretraining for The Masses # Copyright 2021 Alibaba MIIL (c) # Licensed under MIT License [see the LICENSE file for details] # Written by Tal Ridnik # -------------------------------------------------------- import argparse import time import to...
4,747
36.385827
119
py
ImageNet21K
ImageNet21K-main/visualize_detector.py
# -------------------------------------------------------- # ImageNet-21K Pretraining for The Masses # Copyright 2021 Alibaba MIIL (c) # Licensed under MIT License [see the LICENSE file for details] # Written by Tal Ridnik # -------------------------------------------------------- import os import urllib from argparse...
2,950
33.717647
127
py
ImageNet21K
ImageNet21K-main/tests/test_semantic_softmax_loss.py
# test_semantic_softmax_loss.py # tests auto-generated by https://www.codium.ai/ # testing https://github.com/Alibaba-MIIL/ImageNet21K/blob/2715baf0e38673809812409678f7d12e592cbaba/tests/test_semantic_softmax_loss.py#L5 class import unittest from src_files.semantic.semantic_loss import SemanticSoftmaxLoss from src_f...
4,847
52.866667
172
py
ImageNet21K
ImageNet21K-main/src_files/models/ofa/utils.py
# Adopted from https://github.com/mit-han-lab/once-for-all: # Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. # ----------------------------------------------------...
9,919
30.097179
118
py
ImageNet21K
ImageNet21K-main/src_files/models/ofa/layers.py
# Adopted from https://github.com/mit-han-lab/once-for-all: # Once for All: Train One Network and Specialize it for Efficient Deployment # Han Cai, Chuang Gan, Tianzhe Wang, Zhekai Zhang, Song Han # International Conference on Learning Representations (ICLR), 2020. # ----------------------------------------------------...
17,619
32.120301
118
py
ImageNet21K
ImageNet21K-main/src_files/models/utils/factory.py
import torch import timm from ..ofa.model_zoo import ofa_flops_595m_s from ..tresnet import TResnetM, TResnetL from src_files.helper_functions.distributed import print_at_master def load_model_weights(model, model_path): state = torch.load(model_path, map_location='cpu') for key in model.state_dict(): ...
2,490
41.220339
119
py
ImageNet21K
ImageNet21K-main/src_files/models/tresnet/tresnet.py
import torch import torch.nn as nn from torch.nn import Module as Module from collections import OrderedDict from src_files.models.tresnet.layers.anti_aliasing import AntiAliasDownsampleLayer from .layers.avg_pool import FastAvgPool2d from .layers.general_layers import SEModule, SpaceToDepthModule from inplace_abn impo...
9,343
39.803493
112
py
ImageNet21K
ImageNet21K-main/src_files/models/tresnet/layers/anti_aliasing.py
import torch import torch.nn.parallel import numpy as np import torch.nn as nn import torch.nn.functional as F class AntiAliasDownsampleLayer(nn.Module): def __init__(self, remove_model_jit: bool = False, filt_size: int = 3, stride: int = 2, channels: int = 0): super(AntiAliasDownsampleLa...
2,035
32.377049
99
py
ImageNet21K
ImageNet21K-main/src_files/models/tresnet/layers/general_layers.py
import torch import torch.nn as nn import torch.nn.functional as F from src_files.models.tresnet.layers.avg_pool import FastAvgPool2d class Flatten(nn.Module): def forward(self, x): return x.view(x.size(0), -1) class DepthToSpace(nn.Module): def __init__(self, block_size): super().__init__...
2,996
30.882979
102
py
ImageNet21K
ImageNet21K-main/src_files/models/tresnet/layers/avg_pool.py
import torch import torch.nn as nn import torch.nn.functional as F class FastAvgPool2d(nn.Module): def __init__(self, flatten=False): super(FastAvgPool2d, self).__init__() self.flatten = flatten def forward(self, x): if self.flatten: in_size = x.size() return ...
479
23
93
py
ImageNet21K
ImageNet21K-main/src_files/helper_functions/distributed.py
import os import torch import torch.distributed as dist def get_dist_info(): initialized = dist.is_available() and dist.is_initialized() if initialized: rank = dist.get_rank() world_size = dist.get_world_size() else: rank = 0 world_size = 1 return rank, world_size def...
1,023
20.333333
94
py
ImageNet21K
ImageNet21K-main/src_files/data_loading/data_loader.py
import os import torch from randaugment import RandAugment from torchvision import transforms from torchvision.datasets import ImageFolder from src_files.helper_functions.augmentations import CutoutPIL from src_files.helper_functions.distributed import num_distrib, print_at_master from timm.data.loader import Ordered...
3,393
33.282828
131
py
ImageNet21K
ImageNet21K-main/src_files/optimizers/create_optimizer.py
import torch from torch.optim import lr_scheduler from src_files.helper_functions.general_helper_functions import add_weight_decay from src_files.loss_functions.losses import CrossEntropyLS def create_optimizer(model, args): parameters = add_weight_decay(model, args.weight_decay) optimizer = torch.optim.Adam...
652
35.277778
110
py
ImageNet21K
ImageNet21K-main/src_files/loss_functions/losses.py
import torch import torch.nn as nn class CrossEntropyLS(nn.Module): def __init__(self, eps: float = 0.2): super(CrossEntropyLS, self).__init__() self.eps = eps self.logsoftmax = nn.LogSoftmax(dim=-1) def forward(self, inputs, target): num_classes = inputs.size()[-1] log...
689
37.333333
93
py
ImageNet21K
ImageNet21K-main/src_files/semantic/semantics.py
import torch import numpy as np from torch import Tensor @torch.jit.script def stable_softmax(logits: torch.Tensor): logits_m = logits - logits.max(dim=1)[0].unsqueeze(1) exp = torch.exp(logits_m) probs = exp / torch.sum(exp, dim=1).unsqueeze(1) return probs class ImageNet21kSemanticSoftmax: def...
6,255
46.037594
112
py
ImageNet21K
ImageNet21K-main/src_files/semantic/semantic_loss.py
import torch import torch.nn.functional as F class SemanticSoftmaxLoss(torch.nn.Module): def __init__(self, semantic_softmax_processor): super(SemanticSoftmaxLoss, self).__init__() self.semantic_softmax_processor = semantic_softmax_processor self.args = semantic_softmax_processor.args ...
1,991
39.653061
110
py
ImageNet21K
ImageNet21K-main/src_files/semantic/metrics.py
import torch from src_files.helper_functions.distributed import reduce_tensor, num_distrib class AccuracySemanticSoftmaxMet: "Average the values of `func` taking into account potential different batch sizes" def __init__(self, semantic_softmax_processor): self.semantic_softmax_processor = semantic_s...
2,108
38.055556
112
py
DTAAD
DTAAD-main/main.py
import pickle import os import pandas as pd from tqdm import tqdm from src.models import * from src.constants import * from src.plotting import * from src.pot import * from src.utils import * from src.diagnosis import * from torch.utils.data import Dataset, DataLoader, TensorDataset import torch.nn as nn from time impo...
18,608
41.583524
121
py
DTAAD
DTAAD-main/src/plotting.py
import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages import statistics import os, torch import numpy as np plt.style.use(['science', 'ieee']) plt.rcParams["text.usetex"] = False plt.rcParams['figure.figsize'] = 6, 2 os.makedirs('plots', exist_ok=True) def smooth(y, box_pts=1): bo...
2,304
42.490566
119
py
DTAAD
DTAAD-main/src/gltcn.py
import math import torch.nn as nn from torch.nn.utils import weight_norm class Chomp1d(nn.Module): def __init__(self, chomp_size): super(Chomp1d, self).__init__() self.chomp_size = chomp_size def forward(self, x): """ In fact, this is a cropping module, cropping the extra righ...
5,530
45.478992
191
py
DTAAD
DTAAD-main/src/dlutils.py
import torch.nn as nn import torch import torch.nn.functional as F from torch.autograd import Variable import math import numpy as np from src.parser import args class ConvLSTMCell(nn.Module): def __init__(self, input_dim, hidden_dim, kernel_size, bias): """ Initialize ConvLSTM cell. Par...
12,827
36.182609
111
py
DTAAD
DTAAD-main/src/models.py
import torch import torch.nn as nn import torch.optim as optim import pickle import dgl.nn from dgl.nn.pytorch import GATConv from torch.nn import TransformerEncoder from src.gltcn import * from src.dlutils import * from src.constants import * torch.manual_seed(1) torch.cuda.manual_seed(1) ## Separate LSTM for each ...
22,721
39.003521
120
py
path-space-PDE-solver
path-space-PDE-solver-master/utilities.py
#pylint: disable=invalid-name, no-member, too-many-arguments, missing-docstring #pylint: disable=too-many-branches from datetime import date import json import matplotlib.pyplot as plt import matplotlib.cm as cm import numpy as np import torch as pt COLORS = ['tab:blue', 'tab:orange', 'tab:green', 'tab:red', 'tab:p...
21,036
41.845214
213
py
path-space-PDE-solver
path-space-PDE-solver-master/problems.py
#pylint: disable=invalid-name, no-member, too-many-arguments, unused-argument, missing-docstring, too-many-instance-attributes import numpy as np import torch as pt from numpy import exp, log from scipy.linalg import expm, inv, solve_banded device = pt.device('cuda') class LLGC(): ''' Ornstein-Uhlenb...
61,480
33.833428
177
py
path-space-PDE-solver
path-space-PDE-solver-master/solver.py
#pylint: disable=invalid-name, no-member, too-many-arguments, missing-docstring #pylint: disable=too-many-instance-attributes, not-callable, no-else-return #pylint: disable=inconsistent-return-statements, too-many-locals, too-many-return-statements #pylint: disable=too-many-statements, too-many-public-methods from cop...
69,944
51.82855
264
py
path-space-PDE-solver
path-space-PDE-solver-master/function_space.py
#pylint: disable=invalid-name, no-member, too-many-arguments, missing-docstring, arguments-differ, unused-argument import torch as pt class SingleParam(pt.nn.Module): def __init__(self, lr, initial=None, seed=42): super(SingleParam, self).__init__() pt.manual_seed(seed) if initial is None...
7,450
37.015306
127
py
LyDROO
LyDROO-main/memory.py
# ################################################################# # This file contains the main DROO operations, including building DNN, # Storing data sample, Training DNN, and generating quantized binary offloading decisions. # version 1.0 -- February 2020. Written based on Tensorflow 2 by Weijian Pan and # ...
5,141
30.937888
109
py
LyDROO
LyDROO-main/memoryTF2conv.py
# ################################################################# # This file contains the main LyDROO operations, including building convolutional DNN, # Storing data sample, Training DNN, and generating quantized binary offloading decisions. # version 1.0 -- January 2021. Written based on Tensorflow 2 # Lia...
5,933
35.857143
146
py
CAFE
CAFE-master/train_neural_symbol.py
from __future__ import absolute_import, division, print_function import os import sys import argparse import numpy as np import pickle from tqdm import tqdm import logging import logging.handlers import torch import torch.nn as nn from torch.nn import functional as F import torch.optim as optim from tensorboardX impor...
4,183
36.026549
100
py
CAFE
CAFE-master/utils.py
from __future__ import absolute_import, division, print_function import os import random import argparse import pickle import numpy as np import gzip import scipy.sparse as sp from sklearn.feature_extraction.text import TfidfTransformer import torch BEAUTY = 'beauty' CELL = 'cell' CLOTH = 'clothing' CD = 'cd' DATA_D...
6,173
34.687861
122
py
CAFE
CAFE-master/data_utils.py
from __future__ import absolute_import, division, print_function import sys import os import argparse import pickle import random import time import numpy as np from math import log from tqdm import tqdm import gzip import torch from torch.utils.data import RandomSampler, DataLoader # from datasets import AmazonDatas...
11,010
33.195652
108
py
CAFE
CAFE-master/execute_neural_symbol.py
from __future__ import absolute_import, division, print_function import os import sys import argparse import time import random import numpy as np import pickle import logging import logging.handlers import math from tqdm import tqdm import torch import torch.nn as nn from torch.nn import functional as F import torch....
13,403
34.935657
108
py
CAFE
CAFE-master/symbolic_model.py
from __future__ import absolute_import, division, print_function import numpy as np import torch from torch import nn from torch.nn import functional as F from my_knowledge_graph import * import utils class EntityEmbeddingModel(nn.Module): def __init__(self, entity_info, embed_size, init_embed=None): su...
12,627
39.867314
111
py
ssl-chewing
ssl-chewing-master/src/experiments.py
""" Experiment based on the SimCLR idea [1] - LOSO experiment - dataset: wu2 - input: windows - ground-truth: chewing vs non-chewing or eating vs non-eating b) Training - model: combination of [1] and [2] b) Evaluate on wu2 LOSO [1] https://github.com/google-research/simclr [2] https://ieeexplore.ieee.org/abstract...
15,639
42.085399
119
py
ssl-chewing
ssl-chewing-master/src/evaluation/callbacks.py
from tensorflow.keras.backend import get_value from tensorflow.keras.callbacks import Callback from dataset.wu1.subset import Subset from evaluation.metrics import bml_accuracy, bml_f1score, bml_recall, bml_precision class ValidationResultsPerEpoch(Callback): def __init__(self, validation_set: Subset, show_only_...
1,805
40.045455
110
py
ssl-chewing
ssl-chewing-master/src/evaluation/metrics.py
import numpy as np import tensorflow as tf from sklearn.metrics import confusion_matrix from tensorflow.keras import backend as kbackend class BMLAccuracy(tf.keras.metrics.Metric): def __init__(self, name="bml_acc", **kwargs): super(BMLAccuracy, self).__init__(name=name, **kwargs) self.cm = self.a...
3,960
30.188976
114
py
ssl-chewing
ssl-chewing-master/src/dataset/labeltransform.py
from abc import ABC, abstractmethod import numpy as np from tensorflow.keras.utils import to_categorical from dataset.template.commons import PureAbstractError class BaseLabelTransform(ABC): @abstractmethod def transform_batch(self, x: np.ndarray) -> np.ndarray: raise PureAbstractError() class Ca...
961
24.315789
59
py
ssl-chewing
ssl-chewing-master/src/dataset/wu1/subset.py
from typing import List, Tuple, Union import numpy as np from dataset.commons import PartitionMode, SubsetType from dataset.template.basesubset import BaseSubset from dataset.wu1.commons import LabelMode from dataset.wu1.wu1experiment import WU1Experiment from utilities.numpyutils import is_numpy_1d_vector def _spl...
6,863
34.381443
119
py