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
tlp
tlp-main/scripts/tlp_make_dataset.py
import torch import os import glob import json import pickle from random import random from tvm import auto_scheduler from common import (load_and_register_tasks, get_measure_record_filename, get_to_measure_filename) import threading import multiprocessing from tvm.tir.expr import FloatImm import numpy as np import ran...
7,331
32.788018
136
py
tlp
tlp-main/scripts/tlp_fine_tune.py
import os import pickle import torch import time import numpy as np import random import math from torch import nn from torch import optim import argparse class AttentionModule(nn.Module): def __init__(self): super().__init__() self.fea_size = args.fea_size self.step_size = args.step_siz...
12,727
34.752809
105
py
tlp
tlp-main/scripts/train_model.py
"""Train a cost model with a dataset.""" import argparse import logging import pickle import random import torch import numpy as np import tvm from tvm.auto_scheduler.utils import to_str_round from tvm.auto_scheduler.cost_model import RandomModelInternal from common import load_and_register_tasks, str2bool from tv...
5,926
31.927778
100
py
tlp
tlp-main/scripts/nni_hyperparameter_opt.py
"""Train a cost model with a dataset.""" import argparse import logging import pickle import random import multiprocessing import nni import torch import numpy as np import tvm from tvm.auto_scheduler.utils import to_str_round from tvm.auto_scheduler.cost_model import RandomModelInternal from common import load_an...
6,092
31.238095
100
py
tlp
tlp-main/scripts/tlp_train.py
import os import pickle import torch import time import numpy as np import random import math from torch import nn from torch import optim import argparse def get_cosine_schedule_with_warmup( optimizer: optim.Optimizer, num_warmup_steps: int, num_training_steps: int, num_cycles: float = 0.5, last_epoch: int = -1...
26,402
33.156533
113
py
tlp
tlp-main/scripts/common.py
from collections import defaultdict, namedtuple import pickle import tvm from tvm import relay, auto_scheduler from tvm.auto_scheduler.utils import to_str_round #################################### ##### Network Utilities #################################### def convert_to_nhwc(mod): """Convert to NHWC layout""" ...
2,921
28.22
84
py
tlp
tlp-main/scripts/tlp_eval.py
import pickle import numpy as np import torch import argparse from tlp_train import * from mtl_tlp_train import MTLTLPAttentionModule top_ks = [1, 5, 10, 20] def pred_a_dataset(datas, task_pred_dict, model): datas_new = [] for data_idx, data in enumerate([datas]): file, file_idx, workloadkey_idx, w...
4,916
36.25
107
py
tlp
tlp-main/scripts/dump_network_info.py
"""Dump relay IR and task information for networks""" import argparse from collections import namedtuple import gc import glob import multiprocessing import os import pickle from tqdm import tqdm import tvm from tvm import relay from tvm import auto_scheduler from common import (convert_to_nhwc, dtype2torch, NETWOR...
8,740
35.26971
106
py
tlp
tlp-main/scripts/mtl_tlp_train.py
import os import pickle import torch import time import numpy as np import random from torch import nn from torch import optim import argparse class MTLTLPAttentionModule(nn.Module): def __init__(self): super().__init__() self.fea_size = args.fea_size self.step_size = args.step_size ...
14,420
37.050132
197
py
tlp
tlp-main/scripts/minGPT/gpt_model.py
import torch from .mingpt.model import GPT, GPTConfig from torch import nn class gpt_args: pass class GPUModel: def __init__(self, self_sup_model) -> None: vocab_size = 42336 args = gpt_args() args.block_size = 24 args.one_hot_len = 12 args.type_loss_factor = 10 ...
899
30.034483
68
py
tlp
tlp-main/scripts/minGPT/train_gpt.py
import pickle import logging import torch import torch.nn as nn from mingpt.model import GPT, GPTConfig from mingpt.trainer import Trainer, TrainerConfig from mingpt.utils import set_seed import argparse set_seed(42) logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt...
3,816
31.905172
126
py
tlp
tlp-main/scripts/minGPT/mingpt/utils.py
import random import numpy as np import torch import torch.nn as nn from torch.nn import functional as F def set_seed(seed): random.seed(seed) np.random.seed(seed) torch.manual_seed(seed) torch.cuda.manual_seed_all(seed) def top_k_logits(logits, k): v, ix = torch.topk(logits, k) out = logits.c...
1,718
34.8125
95
py
tlp
tlp-main/scripts/minGPT/mingpt/model.py
""" GPT model: - the initial stem consists of a combination of token encoding and a positional encoding - the meat of it is a uniform sequence of Transformer blocks - each Transformer is a sequential combination of a 1-hidden-layer MLP block and a self-attention block - all blocks feed into a central residual p...
9,253
42.04186
138
py
tlp
tlp-main/scripts/minGPT/mingpt/trainer.py
""" Simple training loop; Boilerplate that could apply to any arbitrary neural network, so nothing in this file really has anything to do with GPT specifically. """ import math import logging from tqdm import tqdm import numpy as np import torch import torch.optim as optim from torch.optim.lr_scheduler import Lambda...
5,775
38.561644
140
py
tlp
tlp-main/scripts/bert/bert_model.py
import torch from transformers import RobertaConfig, RobertaForMaskedLM, AdamW from torch import nn class BertModel: def __init__(self, self_sup_model) -> None: ########### RobertaConfig config = RobertaConfig( vocab_size=42335 + 3, # we align this to the tokenizer vocab_size...
856
25.78125
78
py
tlp
tlp-main/scripts/bert/train_bert.py
import argparse import pickle from transformers import RobertaConfig, RobertaForMaskedLM, AdamW import torch from torch import nn from tqdm.auto import tqdm import math class BertSegmentDataLoader: def __init__( self, dataset, batch_size, shuffle, ): self...
5,812
32.028409
114
py
tlp
tlp-main/nnvm/amalgamation/amalgamation.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,549
25.893939
99
py
tlp
tlp-main/tests/python/conftest.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
1,922
43.72093
92
py
tlp
tlp-main/tests/python/unittest/test_custom_datatypes.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
17,978
30.934281
142
py
tlp
tlp-main/tests/python/unittest/test_autotvm_xgboost_model.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
2,068
27.736111
82
py
tlp
tlp-main/tests/python/driver/tvmc/conftest.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
6,048
32.41989
99
py
tlp
tlp-main/tests/python/driver/tvmc/test_frontends.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
7,563
35.019048
96
py
tlp
tlp-main/tests/python/driver/tvmc/test_compiler.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
7,998
33.627706
97
py
tlp
tlp-main/tests/python/frontend/mxnet/test_qnn_ops_utils.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
7,755
33.471111
99
py
tlp
tlp-main/tests/python/frontend/mxnet/test_forward.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
92,936
38.716667
104
py
tlp
tlp-main/tests/python/frontend/mxnet/test_graph.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,841
29.983871
80
py
tlp
tlp-main/tests/python/frontend/mxnet/model_zoo/resnet.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
10,688
31.688073
100
py
tlp
tlp-main/tests/python/frontend/mxnet/model_zoo/squeezenet.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,892
38.72449
96
py
tlp
tlp-main/tests/python/frontend/mxnet/model_zoo/vgg.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
4,491
40.211009
98
py
tlp
tlp-main/tests/python/frontend/mxnet/model_zoo/mlp.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
1,950
45.452381
100
py
tlp
tlp-main/tests/python/frontend/mxnet/model_zoo/dqn.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
1,745
40.571429
93
py
tlp
tlp-main/tests/python/frontend/mxnet/model_zoo/dcgan.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
3,190
33.684783
98
py
tlp
tlp-main/tests/python/frontend/mxnet/model_zoo/inception_v3.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
11,306
29.642276
127
py
tlp
tlp-main/tests/python/frontend/caffe2/test_forward.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
7,882
30.035433
100
py
tlp
tlp-main/tests/python/frontend/caffe2/test_graph.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
1,507
34.904762
81
py
tlp
tlp-main/tests/python/frontend/caffe2/model_zoo/__init__.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
1,497
29.571429
90
py
tlp
tlp-main/tests/python/frontend/tflite/test_forward.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
154,612
34.864765
135
py
tlp
tlp-main/tests/python/frontend/onnx/test_forward.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
141,914
32.813438
100
py
tlp
tlp-main/tests/python/frontend/keras/test_forward.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
26,378
42.032626
99
py
tlp
tlp-main/tests/python/frontend/caffe/test_forward.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
27,553
28.917481
99
py
tlp
tlp-main/tests/python/frontend/pytorch/test_lstm.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
13,044
34.161725
111
py
tlp
tlp-main/tests/python/frontend/pytorch/test_forward.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
128,492
31.529873
115
py
tlp
tlp-main/tests/python/frontend/pytorch/qnn_test.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
20,687
32.803922
123
py
tlp
tlp-main/tests/python/frontend/pytorch/test_object_detection.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
5,259
30.878788
91
py
tlp
tlp-main/tests/python/frontend/tensorflow/test_forward.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
191,571
34.118607
113
py
tlp
tlp-main/tests/python/nightly/quantization/test_quantization_accuracy.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
6,803
30.5
126
py
tlp
tlp-main/tests/python/contrib/test_dlpack.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
2,256
33.723077
82
py
tlp
tlp-main/tests/python/contrib/test_tensorrt.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
48,785
34.766862
133
py
tlp
tlp-main/tests/python/contrib/test_mxnet_bridge.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
2,038
30.859375
81
py
tlp
tlp-main/tests/python/contrib/test_arm_compute_lib/test_network.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
5,647
29.695652
135
py
tlp
tlp-main/vta/tutorials/frontend/deploy_classification.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
11,496
38.644828
100
py
tlp
tlp-main/vta/tutorials/autotvm/tune_relay_vta.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
21,420
40.756335
322
py
tlp
tlp-main/vta/scripts/tune_resnet.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
11,949
33.240688
98
py
tlp
tlp-main/docs/conf.py
# -*- coding: utf-8 -*- # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # ...
12,868
30.235437
92
py
tlp
tlp-main/rust/tvm/examples/resnet/src/build_resnet.py
#!/usr/bin/env python3 # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "L...
5,391
33.126582
100
py
tlp
tlp-main/3rdparty/vta-hw/apps/deploy/resnet_export.py
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
5,296
38.827068
98
py
tlp
tlp-main/3rdparty/dmlc-core/tracker/dmlc_tracker/opts.py
# pylint: disable=invalid-name """Command line options of job submission script.""" import os import argparse def get_cache_file_set(args): """Get the list of files to be cached. Parameters ---------- args: ArgumentParser.Argument The arguments returned by the parser. Returns ------- ...
9,424
51.071823
110
py
tlp
tlp-main/3rdparty/dmlc-core/doc/conf.py
# -*- coding: utf-8 -*- # # documentation build configuration file, created by # sphinx-quickstart on Thu Jul 23 19:40:08 2015. # # 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 confi...
5,609
32.795181
88
py
met
met-master/code/networks/SiameseNet.py
import torch.nn as nn from code.networks.backbone import Embedder class siamese_network(nn.Module): '''Network architecture for contrastive learning. ''' def __init__(self,backbone,pooling = "gem",pretrained = True, emb_proj = False,init_emb_projector= None): super(siamese_network,self).__init__() n...
686
23.535714
70
py
met
met-master/code/networks/backbone.py
import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.parameter import Parameter import torchvision.models as models OUTPUT_DIM = { 'resnet18' : 512, 'resnet50' : 2048, 'r18_sw-sup' : 512, } class GeM(nn.Module): '''Credits to Filip Radenovic ...
4,008
26.087838
126
py
met
met-master/code/examples/train_contrastive.py
import argparse import os import sys import pickle import math import numpy as np from code.utils.train_utils import * from code.networks.SiameseNet import * from code.utils.datasets import * from code.utils.utils import * from code.utils.losses import * from code.utils.augmentations import augmentation import torch...
10,186
38.332046
147
py
met
met-master/code/examples/extract_descriptors.py
import os import sys import pickle import json import numpy as np import argparse from collections import OrderedDict import torch from torchvision import transforms from torch.utils.model_zoo import load_url from code.utils.datasets import * from code.utils.utils import * from code.networks.backbone import * from co...
7,872
34.786364
263
py
met
met-master/code/utils/losses.py
import torch import torch.nn as nn import torch.nn.functional as F class ContrastiveLoss(nn.Module): '''Contrastive loss. Takes as inputs the embeddings of two samples and a target label == 1 if samples come from the same class or 0 otherwise. Credits to https://github.com/adambielski/siamese-triple...
835
28.857143
111
py
met
met-master/code/utils/augmentations.py
from torchvision import transforms def augmentation(key,imsize = 500): '''Using ImageNet statistics for normalization. ''' augment_dict = { "augment_train": transforms.Compose([ transforms.RandomResizedCrop(imsize, scale=(0.7,1.0),ratio = (0.99,1/0.99)), transforms.RandomApply([transforms.ColorJitt...
700
22.366667
80
py
met
met-master/code/utils/utils.py
import torch import numpy as np from code.networks.backbone import * def gap(pred, score, class_ids): '''Implementation of the GAP metric described in the paper. Expects everything as np array. ''' rel = np.zeros(len(pred)) #rel is the binary indicator, 1 if correct prediction, 0 if false rel ...
4,248
25.067485
109
py
met
met-master/code/utils/train_utils.py
import sys import math import faiss import numpy as np import torch import torch.nn as nn from code.utils.utils import * from code.classifiers.knn_classifier import * def train_contrastive_1epoch_virtual(model,criterion,optimizer,train_loader,epoch,vbsizemul): '''Train model with the contrastive loss for one-epo...
5,078
23.77561
109
py
met
met-master/code/utils/datasets.py
import os import os.path import json import pickle import numpy as np from typing import Any, Callable, cast, Dict, List, Optional, Tuple from torch.utils.data import Dataset from torchvision.datasets.vision import VisionDataset from torchvision.datasets.folder import default_loader from code.utils.train_utils import...
9,873
29.475309
129
py
tkMapper
tkMapper-master/docs/conf.py
# -*- coding: utf-8 -*- # # KeplerMapper documentation build configuration file, created by # sphinx-quickstart on Mon Feb 19 11:19:26 2018. # # 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. ...
6,044
29.530303
133
py
tkMapper
tkMapper-master/depricated/km.py
from __future__ import division import numpy as np from collections import defaultdict import json import itertools from sklearn import cluster, preprocessing, manifold from datetime import datetime import sys class KeplerMapper(object): def __init__(self, cluster_algorithm=cluster.DBSCAN(eps=0.5,min_samples=3), nr_...
13,395
41.526984
336
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/main.py
""" Teacher free KD, main.py """ import argparse import logging import os import random import warnings import numpy as np import torch import torch.nn as nn import torch.optim as optim import utils import model.net as net import data_loader as data_loader import model.resnet as resnet import model.mobilenetv2 as mobi...
13,805
46.771626
130
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/evaluate.py
"""Evaluates the model""" import argparse import logging from torch.autograd import Variable import utils parser = argparse.ArgumentParser() parser.add_argument('--model_dir', default='experiments/base_model', help="Directory of params.json") parser.add_argument('--restore_file', default='best', help="name of the fi...
3,972
37.95098
113
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/my_loss_function.py
import torch import torch.nn as nn import torch.nn.functional as F def loss_kd(outputs, labels, teacher_outputs, params): """ loss function for Knowledge Distillation (KD) """ alpha = params.alpha T = params.temperature loss_CE = F.cross_entropy(outputs, labels) D_KL = nn.KLDivLoss()(F.lo...
2,212
31.544118
186
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/train_kd.py
import os import time import math import utils from tqdm import tqdm import logging from torch.autograd import Variable from evaluate import evaluate, evaluate_kd from tensorboardX import SummaryWriter from torch.optim.lr_scheduler import StepLR, MultiStepLR # KD train and evaluate def train_and_evaluate_kd(model, tea...
9,755
37.258824
142
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/data_loader.py
""" CIFAR-10 CIFAR-100, Tiny-ImageNet data loader """ import random import os import numpy as np from PIL import Image import torch import torchvision import torchvision.transforms as transforms from torch.utils.data.sampler import SubsetRandomSampler def fetch_dataloader(types, params): """ Fetch and retu...
6,917
43.922078
160
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/utils.py
""" Tensorboard logger code referenced from: https://github.com/yunjey/pytorch-tutorial/blob/master/tutorials/04-utils/ Other helper functions: https://github.com/cs230-stanford/cs230-stanford.github.io """ import json import logging import os import shutil import torch from collections import OrderedDict from torch.o...
8,449
30.180812
109
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/shufflenetv2.py
"""shufflenetv2 in pytorch [1] Ningning Ma, Xiangyu Zhang, Hai-Tao Zheng, Jian Sun ShuffleNet V2: Practical Guidelines for Efficient CNN Architecture Design https://arxiv.org/abs/1807.11164 """ import torch import torch.nn as nn import torch.nn.functional as F def channel_split(x, split): """split a tens...
4,802
30.392157
101
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/resnet.py
'''ResNet in PyTorch. For Pre-activation ResNet, see 'preact_resnet.py'. Reference: [1] Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun Deep Residual Learning for Image Recognition. arXiv:1512.03385 ''' import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd im...
5,966
34.730539
119
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/mobilenetv2.py
"""mobilenetv2 in pytorch [1] Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, Liang-Chieh Chen MobileNetV2: Inverted Residuals and Linear Bottlenecks https://arxiv.org/abs/1801.04381 """ import torch import torch.nn as nn import torch.nn.functional as F class LinearBottleNeck(nn.Module): de...
2,829
27.877551
109
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/utils.py
try: from torch.hub import load_state_dict_from_url except ImportError: from torch.utils.model_zoo import load_url as load_state_dict_from_url
150
36.75
74
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/densenet.py
""" dense net in pytorch [1] Gao Huang, Zhuang Liu, Laurens van der Maaten, Kilian Q. Weinberger. Densely Connected Convolutional Networks https://arxiv.org/abs/1608.06993v5 """ import torch import torch.nn as nn #"""Bottleneck layers. Although each layer only produces k #output feature-maps, it typically h...
5,141
39.488189
147
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/googlenet.py
"""google net in pytorch [1] Christian Szegedy, Wei Liu, Yangqing Jia, Pierre Sermanet, Scott Reed, Dragomir Anguelov, Dumitru Erhan, Vincent Vanhoucke, Andrew Rabinovich. Going Deeper with Convolutions https://arxiv.org/abs/1409.4842v1 """ import torch import torch.nn as nn class Inception(nn.Module): ...
4,371
33.15625
94
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/resnext.py
from __future__ import division """ Creates a ResNeXt Model as defined in: Xie, S., Girshick, R., Dollar, P., Tu, Z., & He, K. (2016). Aggregated residual transformations for deep neural networks. arXiv preprint arXiv:1611.05431. import from https://github.com/prlz77/ResNeXt.pytorch/blob/master/models/model.py """ i...
6,323
42.315068
144
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/net.py
""" Baseline CNN, losss function and metrics Also customizes knowledge distillation (KD) loss function here """ import numpy as np import torch import torch.nn as nn import torch.nn.functional as F class Net(nn.Module): """ This is the standard way to define your own network in PyTorch. You typically ch...
4,030
50.025316
116
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/alexnet.py
'''AlexNet for CIFAR10. FC layers are removed. Paddings are adjusted. Without BN, the start learning rate should be 0.01 (c) YANG, Wei ''' import torch.nn as nn __all__ = ['alexnet'] class AlexNet(nn.Module): def __init__(self, num_classes=100): super(AlexNet, self).__init__() self.features = n...
1,358
29.886364
69
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/model/wrn.py
import numpy as np import math import torch import torch.nn as nn import torch.nn.functional as F # __all__ = ['wrn'] class BasicBlock(nn.Module): def __init__(self, in_planes, out_planes, stride, dropRate=0.0): super(BasicBlock, self).__init__() self.bn1 = nn.BatchNorm2d(in_planes) self.r...
5,085
39.688
119
py
Teacher-free-Knowledge-Distillation
Teacher-free-Knowledge-Distillation-master/ImageNet_train/main.py
import argparse import os import random import shutil import time import warnings import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.distributed as dist import torch.optim import torch.multiprocessing as mp import torch.utils.data import torch.utils.data.distr...
21,167
40.182879
147
py
OccamNet_Public
OccamNet_Public-main/implicit/ExperimentTimeConstantPower.py
import torch import torch.nn as nn import numpy as np import Bases from DataGenerators import FunctionDataGenerator,ImplicitFunctionDataGenerator,MultivariateFunctionDataGenerator,ImplicitFunctionDataGeneratorSample,FunctionDataGeneratorSample from Losses import CrossEntropyLoss,CELTrivialRegularization,CELTrivialConst...
1,803
37.382979
374
py
OccamNet_Public
OccamNet_Public-main/implicit/Bases.py
from abc import ABC,abstractmethod import torch import sympy as sp import numpy as np #Nan represents unfixed units. Not wrong units. def checkNan(input): return np.isnan(input[0]) #Inf represents wrong units that need to be propagated further def checkInf(input): return np.isinf(input[0]) def matchUnits(uni...
9,524
25.02459
79
py
OccamNet_Public
OccamNet_Public-main/implicit/ExperimentTimeCircle.py
import torch import torch.nn as nn import numpy as np import Bases from DataGenerators import FunctionDataGenerator,ImplicitFunctionDataGenerator,MultivariateFunctionDataGenerator,ImplicitFunctionDataGeneratorSample from Losses import CrossEntropyLoss,CELTrivialRegularization,CELTrivialConstantRegularization,CELFlagReg...
1,854
36.857143
240
py
OccamNet_Public
OccamNet_Public-main/implicit/SparseSetters.py
import torch import math from NetworkRegularization import ActivationLayer class SetPartialSparse: def __init__(self, sparseInputs): self.sparseInputs = sparseInputs def getActivationsSparsity(self, inputSize, activationLists, outputSize): numItems = [outputSize] for i in range(len(act...
6,203
34.861272
111
py
OccamNet_Public
OccamNet_Public-main/implicit/ExperimentTimeCosine.py
import torch import torch.nn as nn import numpy as np import Bases from DataGenerators import FunctionDataGenerator,ImplicitFunctionDataGenerator,MultivariateFunctionDataGenerator,ImplicitFunctionDataGeneratorSample,FunctionDataGeneratorSample from Losses import CrossEntropyLoss,CELTrivialRegularization,CELTrivialConst...
1,827
35.56
200
py
OccamNet_Public
OccamNet_Public-main/implicit/ExperimentTimeDivide.py
import torch import torch.nn as nn import numpy as np import Bases from DataGenerators import FunctionDataGenerator,ImplicitFunctionDataGenerator,MultivariateFunctionDataGenerator,ImplicitFunctionDataGeneratorSample from Losses import CrossEntropyLoss,CELTrivialRegularization,CELTrivialConstantRegularization,CELFlagReg...
1,647
33.333333
240
py
OccamNet_Public
OccamNet_Public-main/implicit/ExperimentTimeTaylor.py
import torch import torch.nn as nn import numpy as np import Bases from DataGenerators import FunctionDataGenerator,ImplicitFunctionDataGenerator,MultivariateFunctionDataGenerator,ImplicitFunctionDataGeneratorSample,FunctionDataGeneratorSample from Losses import CrossEntropyLoss,CELTrivialRegularization,CELTrivialConst...
1,884
35.960784
249
py
OccamNet_Public
OccamNet_Public-main/implicit/NetworkRegularization.py
from numpy.lib.npyio import save import torch import torch.nn as nn import numpy as np import math import matplotlib.pyplot as plt import Bases from DataGenerators import FunctionDataGenerator,ImplicitFunctionDataGenerator from Losses import CrossEntropyLoss,CELFlagRegularization import argparse import sympy as sp from...
37,276
38.280295
265
py
OccamNet_Public
OccamNet_Public-main/implicit/ExperimentTimeMomentum.py
import torch import torch.nn as nn import numpy as np import Bases from DataGenerators import FunctionDataGenerator,ImplicitFunctionDataGenerator,MultivariateFunctionDataGenerator,ImplicitFunctionDataGeneratorSample from Losses import CrossEntropyLoss,CELTrivialRegularization,CELTrivialConstantRegularization,CELFlagReg...
1,792
36.354167
240
py
OccamNet_Public
OccamNet_Public-main/implicit/ExperimentTimeArccos.py
import torch import torch.nn as nn import numpy as np import Bases from DataGenerators import FunctionDataGenerator,ImplicitFunctionDataGenerator,MultivariateFunctionDataGenerator,ImplicitFunctionDataGeneratorSample from Losses import CrossEntropyLoss,CELTrivialRegularization,CELTrivialConstantRegularization,CELFlagReg...
1,789
35.530612
240
py
OccamNet_Public
OccamNet_Public-main/implicit/Losses.py
import torch import math class CrossEntropyLoss: def __init__(self, var, topNumber): self.setVar(var) self.topNumber = topNumber self.weighting = torch.tensor([1.0/(n) for n in range(topNumber, 0, -1)]) def setVar(self, var): self.var = var def getError(self, y, predic...
7,400
42.02907
149
py
OccamNet_Public
OccamNet_Public-main/implicit/ExperimentTimeHyperbola.py
import torch import torch.nn as nn import numpy as np import Bases from DataGenerators import FunctionDataGenerator,ImplicitFunctionDataGenerator,MultivariateFunctionDataGenerator,ImplicitFunctionDataGeneratorSample from Losses import CrossEntropyLoss,CELTrivialRegularization,CELTrivialConstantRegularization,CELFlagReg...
1,661
32.918367
240
py
OccamNet_Public
OccamNet_Public-main/implicit/DataGenerators.py
import torch class FunctionDataGenerator: def __init__(self, batchSize, dataRange, function): self.batchSize = batchSize self.dataRange = dataRange self.function = function def getBatch(self): x = (torch.rand([self.batchSize], dtype = torch.float)*(self.dataRange[1]-self.da...
3,632
38.48913
160
py
OccamNet_Public
OccamNet_Public-main/constant-fitting/ExperimentTimeConstantPower.py
import torch import Bases from Losses import CrossEntropyLoss from Network import NetworkConstants, ActivationLayer from SparseSetters import SetPartialSparse as SPS from SparseSetters import SetNoSparse as SNS def func(x): return 10.5*torch.pow(x,3.1) if __name__ == '__main__': fileName = "constantPower" ...
1,007
36.333333
373
py