repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
VLC-BERT
VLC-BERT-master/data/conceptual-captions/utils/gen_val4download.py
import os captions = [] urls = [] with open('Validation_GCC-1.1.0-Validation.tsv') as fp: for cnt, line in enumerate(fp): s = line.split('\t') captions.append(s[0].split(' ')) urls.append(s[1][:-1]) with open('val4download.txt', 'w') as fp: for cnt, url in enumerate(urls): ...
459
26.058824
70
py
VLC-BERT
VLC-BERT-master/data/conceptual-captions/utils/check_valid.py
import sys from PIL import Image import warnings warnings.filterwarnings("ignore", "(Possibly )?corrupt EXIF data", UserWarning) try: im = Image.open(sys.argv[1]).convert('RGB') # remove images with too small or too large size if (im.size[0] < 10 or im.size[1] < 10 or im.size[0] > 10000 or im.size[1] > 1...
386
24.8
88
py
HVAE
HVAE-master/setup.py
from distutils.core import setup from setuptools import dist dist.Distribution().fetch_build_eggs(['Cython', 'numpy<=1.19']) import numpy from Cython.Build import cythonize required = [ "cython", "numpy", "torch", "editdistance", "scikit-learn", "tqdm", "pymoo" ] setup(name='HVAE', ...
606
20.678571
63
py
HVAE
HVAE-master/src/symbolic_regression.py
import argparse import json import random import time import numpy as np import torch from pymoo.algorithms.soo.nonconvex.ga import GA from pymoo.optimize import minimize from pymoo.core.problem import ElementwiseProblem from pymoo.core.sampling import Sampling from pymoo.core.crossover import Crossover from pymoo.cor...
6,382
37.920732
125
py
HVAE
HVAE-master/src/batch_model.py
import torch from torch.autograd import Variable import torch.nn.functional as F import torch.nn as nn from tree import Node, BatchedNode from symbol_library import SymType class HVAE(nn.Module): _symbols = None def __init__(self, input_size, output_size, hidden_size=None): super(HVAE, self).__init_...
8,343
38.545024
111
py
HVAE
HVAE-master/src/batch_train.py
from argparse import ArgumentParser import numpy as np import torch from torch.utils.data import Sampler, Dataset, DataLoader from tqdm import tqdm # from utils import tokens_to_tree, read_expressions from utils import read_expressions_json from batch_model import HVAE from symbol_library import generate_symbol_libra...
4,883
31.778523
112
py
HVAE
HVAE-master/src/tree.py
import torch from torch.autograd import Variable class Node: _symbols = None _s2c = None def __init__(self, symbol=None, right=None, left=None): self.symbol = symbol self.right = right self.left = left self.target = None self.prediction = None def __str__(self...
9,097
34.263566
117
py
HVAE
HVAE-master/src/utils.py
import json from symbol_library import SymType from tree import Node def read_expressions(filepath): expressions = [] with open(filepath, "r") as file: for line in file: expressions.append(line.strip().split(" ")) return expressions def read_expressions_json(filepath): with open...
2,630
41.435484
109
py
HVAE
HVAE-master/src/model.py
import torch from torch.autograd import Variable import torch.nn.functional as F import torch.nn as nn from tree import Node from symbol_library import SymType class HVAE(nn.Module): _symbols = None def __init__(self, input_size, output_size, hidden_size=None): super(HVAE, self).__init__() ...
7,496
39.090909
111
py
HVAE
HVAE-master/src/reconstruction_accuracy.py
from argparse import ArgumentParser import numpy as np import torch from sklearn.model_selection import KFold import editdistance from utils import read_expressions, tokens_to_tree from symbol_library import generate_symbol_library from model import HVAE from train import train_hvae def one_fold(model, train, test,...
3,214
38.691358
119
py
HVAE
HVAE-master/src/__init__.py
0
0
0
py
HVAE
HVAE-master/src/evaluation.py
from rusteval import Evaluator import numpy as np from pymoo.core.problem import ElementwiseProblem from pymoo.algorithms.soo.nonconvex.de import DE from pymoo.operators.sampling.lhs import LHS from pymoo.optimize import minimize from pymoo.termination.default import DefaultSingleObjectiveTermination def read_eq_dat...
3,639
29.847458
112
py
HVAE
HVAE-master/src/linear_interpolation.py
import torch from model import HVAE from utils import tokens_to_tree from symbol_library import generate_symbol_library def interpolateAB(model, exprA, exprB, steps=5): tokensA = exprA.split(" ") tokensB = exprB.split(" ") treeA = tokens_to_tree(tokensA, s2t) treeB = tokens_to_tree(tokensB, s2t) ...
1,089
28.459459
89
py
HVAE
HVAE-master/src/train.py
from argparse import ArgumentParser import numpy as np import torch from torch.utils.data import Sampler, Dataset, DataLoader from tqdm import tqdm from utils import tokens_to_tree, read_expressions, read_json from model import HVAE from symbol_library import generate_symbol_library def collate_fn(batch): retur...
4,523
34.904762
112
py
HVAE
HVAE-master/src/symbol_library.py
from enum import Enum class SymType(Enum): Var = 1 Const = 2 Operator = 3 Fun = 4 Literal = 5 def generate_symbol_library(num_vars, symbol_list, has_constant=True): all_symbols = { "+": {"symbol": '+', "type": SymType.Operator, "precedence": 0, "psymbol": "add"}, "-": {"symbo...
2,430
48.612245
125
py
RL4SRD
RL4SRD-master/RL4SRD.py
""" Created on 2016-12-11 class: RL4SRD @author: Long Xia @contact: [email protected] """ # !/usr/bin/python # -*- coding:utf-8 -*- import sys import json import yaml import copy import math import random import numpy as np import os class RL4SRD(object): """docstring for RL4SRD""" def __init__(self, ...
13,959
41.953846
168
py
User-Object-Attention-Level
User-Object-Attention-Level-master/data_generate/util.py
import numpy as np def ade_classes(): """ADE20K class names for external use.""" return [ 'wall', 'building', 'sky', 'floor', 'tree', 'ceiling', 'road', 'bed ', 'windowpane', 'grass', 'cabinet', 'sidewalk', 'person', 'earth', 'door', 'table', 'mountain', 'plant', 'curtain', 'chair', 'c...
3,390
43.038961
102
py
User-Object-Attention-Level
User-Object-Attention-Level-master/data_generate/convert.py
import os import shutil import numpy as np import json import matplotlib.pyplot as plt import cv2 from util import ade_classes from tqdm import tqdm import numpy as np import pandas as pd save = '../UOAL/Labels' raw_image = '../UOAL/Images' fix = '../UOAL/Attention' # save = '/Users/liujiazhen/Downloads/pas_save_new...
12,772
36.239067
108
py
lolo
lolo-main/python/setup.py
from setuptools import setup from glob import glob import shutil import os # single source of truth for package version version_ns = {} with open(os.path.join("lolopy", "version.py")) as f: exec(f.read(), version_ns) version = version_ns['__version__'] # Find the lolo jar JAR_FILE = glob(os.path.join('..', 'targe...
1,522
31.404255
102
py
lolo
lolo-main/python/lolopy/utils.py
import sys import numpy as np def send_feature_array(gateway, X): """Send a feature array to the JVM Args: gateway (JavaGateway): Connection the JVM X ([[double]]): 2D array of features Returns: (Seq[Vector[Double]]) Reference to feature array in JVM """ # Convert X t...
1,266
29.902439
105
py
lolo
lolo-main/python/lolopy/loloserver.py
"""Methods related to starting and stopping the Java Gateway""" from py4j.java_gateway import JavaGateway import sys import os # Directory where the lolo project root should be _lolo_root = os.path.join(os.path.dirname(__file__), '..', '..') # Used for allowing multiple objects to use the same gateway _lolopy_gateway...
2,571
35.225352
106
py
lolo
lolo-main/python/lolopy/version.py
# single source of truth for package version, # see https://packaging.python.org/en/latest/single_source_version/ __version__ = "3.0.0"
136
33.25
67
py
lolo
lolo-main/python/lolopy/metrics.py
"""Functions to call lolo Merit classes, which describe the performance of a machine learning model These are very similar to the "metrics" from scikit-learn, which is the reason for the name of this module. """ from lolopy.loloserver import get_java_gateway from lolopy.utils import send_1D_array import numpy as np ...
3,556
33.201923
123
py
lolo
lolo-main/python/lolopy/__init__.py
0
0
0
py
lolo
lolo-main/python/lolopy/learners.py
from abc import abstractmethod, ABCMeta import numpy as np from lolopy.loloserver import get_java_gateway from lolopy.utils import send_feature_array, send_1D_array from sklearn.base import BaseEstimator, RegressorMixin, ClassifierMixin, is_regressor from sklearn.exceptions import NotFittedError __all__ = [ 'Rand...
31,442
45.651335
140
py
lolo
lolo-main/python/lolopy/tests/test_learners.py
from lolopy.learners import ( RandomForestRegressor, RandomForestClassifier, MultiTaskRandomForest, RegressionTreeLearner, LinearRegression, ExtraRandomTreesRegressor, ExtraRandomTreesClassifier ) from sklearn.exceptions import NotFittedError from sklearn.metrics import r2_score, accuracy_sc...
11,873
33.923529
121
py
lolo
lolo-main/python/lolopy/tests/test_server.py
from lolopy.loloserver import get_java_gateway from py4j.java_gateway import java_import, JavaClass from unittest import TestCase import os class TestLoloGateway(TestCase): def test_launch(self): # Launch the gateway gate = get_java_gateway() # Make sure it runs by making a random number...
1,512
32.622222
71
py
lolo
lolo-main/python/lolopy/tests/test_metrics.py
from lolopy.loloserver import get_java_gateway from lolopy.metrics import (root_mean_squared_error, standard_confidence, standard_error, uncertainty_correlation) from numpy.random import multivariate_normal, uniform, normal, seed from unittest import TestCase class TestMetrics(TestCase): def test_rmse(self): ...
1,752
42.825
114
py
pyasn
pyasn-master/setup.py
from __future__ import print_function import codecs import sys import platform import glob from setuptools import setup, find_packages, Extension from os.path import abspath, dirname, join here = abspath(dirname(__file__)) with codecs.open(join(here, 'README.md'), encoding='utf-8') as f: README = f.read() libs ...
1,966
29.261538
89
py
pyasn
pyasn-master/pyasn/mrtx.py
# Copyright (c) 2009-2017 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, d...
28,342
44.640902
99
py
pyasn
pyasn-master/pyasn/_version.py
__version__ = '1.6.2'
22
10.5
21
py
pyasn
pyasn-master/pyasn/__init__.py
# Copyright (c) 2014-2017 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, d...
10,702
42.864754
105
py
pyasn
pyasn-master/tests/test_simple.py
# Copyright (c) 2014-2017 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, d...
12,259
43.42029
99
py
pyasn
pyasn-master/tests/test_PyASN_1_2_aggressive.py
# Copyright (c) 2009-2014 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, d...
2,810
37.506849
97
py
pyasn
pyasn-master/tests/test_comparative.py
# Copyright (c) 2014-2017 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, d...
4,457
44.030303
99
py
pyasn
pyasn-master/tests/test_mrtx.py
# Copyright (c) 2014-2017 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, d...
23,833
47.443089
99
py
pyasn
pyasn-master/tests/utilities/gen_pyasn_v1_2_mapping.py
# Copyright (c) 2009-2014 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, d...
2,652
36.9
101
py
pyasn
pyasn-master/tests/utilities/gen_cymru_mapping.py
# Copyright (c) 2009-2014 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, d...
2,712
39.492537
119
py
pyasn
pyasn-master/pyasn-utils/pyasn_util_convert.py
#!/usr/bin/python # Copyright (c) 2009-2017 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify...
5,474
45.794872
99
py
pyasn
pyasn-master/pyasn-utils/pyasn_util_download.py
#!/usr/bin/python # Copyright (c) 2009-2017 Hadi Asghari # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify...
7,426
39.807692
104
py
pyasn
pyasn-master/pyasn-utils/pyasn_util_asnames.py
#!/usr/bin/python # Copyright (c) 2016 Italo Maia # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge...
3,814
27.901515
83
py
AutoPruner
AutoPruner-master/ResNet50/50/fine_tune_compressed_model.py
import argparse import os import shutil import time import sys 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.utils.data import torch.utils.data.distributed from torchvision import datasets, transforms fro...
10,872
35.733108
106
py
AutoPruner
AutoPruner-master/ResNet50/50/main.py
# ************************************************************ # Author : Bumsoo Kim, 2017 # Github : https://github.com/meliketoy/fine-tuning.pytorch # # Korea University, Data-Mining Lab # Deep Convolutional Network Fine tuning Implementation # # Description : main.py # The main code for training classification netwo...
14,783
42.354839
146
py
AutoPruner
AutoPruner-master/ResNet50/50/evaluate_network.py
import torch import torch.backends.cudnn as cudnn import os import sys import argparse import time from src_code.lmdbdataset import lmdbDataset from src_code import Network_FT parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argument('--batch_size', default=100, type=int...
4,037
31.564516
106
py
AutoPruner
AutoPruner-master/ResNet50/50/fine_tune_again.py
import argparse import os import shutil import time import sys 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.utils.data import torch.utils.data.distributed from torchvision import datasets, transforms fro...
10,815
35.789116
106
py
AutoPruner
AutoPruner-master/ResNet50/50/tools/create_lmdb.py
# loads imagenet and writes it into one massive binary file import os import numpy as np from tensorpack.dataflow import * import sys if __name__ == '__main__': if len(sys.argv) < 4 : print("Usage: python create_lmdb.py gt_file.txt root_folder target_lmdb_name") print("gt_file.txt split by \"\t\"")...
1,514
35.95122
86
py
AutoPruner
AutoPruner-master/ResNet50/50/tools/organize_dataset.py
""" this script is used for organize CUB200 dataset: -- images -- train -- [:class 0] -- [:class 1] ... -- [:class n] -- val -- [:class 0] -- [:class 1] ... -- [:class n] """ import os import PIL.Image import numpy as np import shutil ori...
2,295
31.8
82
py
AutoPruner
AutoPruner-master/ResNet50/50/src_code/my_op_fc.py
import torch from torch.autograd import Variable import torch.nn as nn from torch.autograd import gradcheck import numpy as np class MyGAP_fc(torch.autograd.Function): ''' Global Average Pooling with batchsize: N*4096 -> 1*4096 ''' @staticmethod def forward(ctx, input): ctx.save_for_backw...
2,729
31.117647
76
py
AutoPruner
AutoPruner-master/ResNet50/50/src_code/my_op.py
import torch from torch.autograd import Variable import torch.nn as nn from torch.autograd import gradcheck import numpy as np import math class MyGAP(torch.autograd.Function): ''' Global Average Pooling with batchsize: N*512*14*14 -> 1*512*14*14 ''' @staticmethod def forward(ctx, input): ...
3,182
33.225806
93
py
AutoPruner
AutoPruner-master/ResNet50/50/src_code/Network_FT.py
import torch.nn as nn import math import torch from . import my_op class Bottleneck(nn.Module): expansion = 4 def __init__(self, number_list, stride=1, downsample=None): super(Bottleneck, self).__init__() self.conv1 = nn.Conv2d(number_list[1], number_list[0], kernel_size=1, bias=False) ...
12,489
37.549383
111
py
AutoPruner
AutoPruner-master/ResNet50/50/src_code/lmdbdataset.py
import cv2 import numpy as np import torchvision.transforms as transforms import lmdb import msgpack from torch.utils.data import Dataset from PIL import Image class lmdbDataset(Dataset): def __init__(self, location, is_train): self.env = lmdb.open(location, subdir=False, max_readers=1, readonly=True, loc...
2,431
34.246377
111
py
AutoPruner
AutoPruner-master/ResNet50/50/compress_model/new_model.py
import torch.nn as nn import torch import numpy as np class Bottleneck(nn.Module): expansion = 4 def __init__(self, number_list, stride=1, downsample=None): super(Bottleneck, self).__init__() self.conv1 = nn.Conv2d(number_list[1], number_list[0], kernel_size=1, bias=False) self.bn1 = ...
8,768
35.235537
95
py
AutoPruner
AutoPruner-master/ResNet50/50/compress_model/compress_model.py
import torch from new_model import NetworkNew import argparse import torch.backends.cudnn as cudnn parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argument('--group_id', default=0, type=int, help='the id of compressed layer, starting from 0') args = parser.parse_args() ...
786
28.148148
106
py
AutoPruner
AutoPruner-master/ResNet50/50/compress_model/evaluate_net.py
import torch from new_model import NetworkNew_test import argparse import torch.backends.cudnn as cudnn import os import sys import time sys.path.append('../') from src_code.lmdbdataset import lmdbDataset parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argument('--batch_...
3,966
31.516393
106
py
AutoPruner
AutoPruner-master/ResNet50/30/fine_tune_compressed_model.py
import argparse import os import shutil import time import sys 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.utils.data import torch.utils.data.distributed from torchvision import datasets, transforms fro...
10,872
35.733108
106
py
AutoPruner
AutoPruner-master/ResNet50/30/main.py
# ************************************************************ # Author : Bumsoo Kim, 2017 # Github : https://github.com/meliketoy/fine-tuning.pytorch # # Korea University, Data-Mining Lab # Deep Convolutional Network Fine tuning Implementation # # Description : main.py # The main code for training classification netwo...
14,760
42.160819
146
py
AutoPruner
AutoPruner-master/ResNet50/30/evaluate_network.py
import torch import torch.backends.cudnn as cudnn import os import sys import argparse import time from src_code.lmdbdataset import lmdbDataset from src_code import Network_FT parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argument('--batch_size', default=100, type=int...
4,037
31.564516
106
py
AutoPruner
AutoPruner-master/ResNet50/30/fine_tune_again.py
import argparse import os import shutil import time import sys 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.utils.data import torch.utils.data.distributed from torchvision import datasets, transforms fro...
10,814
35.785714
106
py
AutoPruner
AutoPruner-master/ResNet50/30/tools/create_lmdb.py
# loads imagenet and writes it into one massive binary file import os import numpy as np from tensorpack.dataflow import * import sys if __name__ == '__main__': if len(sys.argv) < 4 : print("Usage: python create_lmdb.py gt_file.txt root_folder target_lmdb_name") print("gt_file.txt split by \"\t\"")...
1,514
35.95122
86
py
AutoPruner
AutoPruner-master/ResNet50/30/tools/organize_dataset.py
""" this script is used for organize CUB200 dataset: -- images -- train -- [:class 0] -- [:class 1] ... -- [:class n] -- val -- [:class 0] -- [:class 1] ... -- [:class n] """ import os import PIL.Image import numpy as np import shutil ori...
2,295
31.8
82
py
AutoPruner
AutoPruner-master/ResNet50/30/src_code/my_op_fc.py
import torch from torch.autograd import Variable import torch.nn as nn from torch.autograd import gradcheck import numpy as np class MyGAP_fc(torch.autograd.Function): ''' Global Average Pooling with batchsize: N*4096 -> 1*4096 ''' @staticmethod def forward(ctx, input): ctx.save_for_backw...
2,729
31.117647
76
py
AutoPruner
AutoPruner-master/ResNet50/30/src_code/my_op.py
import torch from torch.autograd import Variable import torch.nn as nn from torch.autograd import gradcheck import numpy as np import math class MyGAP(torch.autograd.Function): ''' Global Average Pooling with batchsize: N*512*14*14 -> 1*512*14*14 ''' @staticmethod def forward(ctx, input): ...
3,182
33.225806
93
py
AutoPruner
AutoPruner-master/ResNet50/30/src_code/Network_FT.py
import torch.nn as nn import math import torch from . import my_op class Bottleneck(nn.Module): expansion = 4 def __init__(self, number_list, stride=1, downsample=None): super(Bottleneck, self).__init__() self.conv1 = nn.Conv2d(number_list[1], number_list[0], kernel_size=1, bias=False) ...
12,489
37.549383
111
py
AutoPruner
AutoPruner-master/ResNet50/30/src_code/lmdbdataset.py
import cv2 import numpy as np import torchvision.transforms as transforms import lmdb import msgpack from torch.utils.data import Dataset from PIL import Image class lmdbDataset(Dataset): def __init__(self, location, is_train): self.env = lmdb.open(location, subdir=False, max_readers=1, readonly=True, loc...
2,431
34.246377
111
py
AutoPruner
AutoPruner-master/ResNet50/30/compress_model/new_model.py
import torch.nn as nn import torch import numpy as np class Bottleneck(nn.Module): expansion = 4 def __init__(self, number_list, stride=1, downsample=None): super(Bottleneck, self).__init__() self.conv1 = nn.Conv2d(number_list[1], number_list[0], kernel_size=1, bias=False) self.bn1 = ...
8,767
35.381743
95
py
AutoPruner
AutoPruner-master/ResNet50/30/compress_model/compress_model.py
import torch from new_model import NetworkNew import argparse import torch.backends.cudnn as cudnn parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argument('--group_id', default=3, type=int, help='the id of compressed layer, starting from 0') args = parser.parse_args() ...
786
28.148148
106
py
AutoPruner
AutoPruner-master/ResNet50/30/compress_model/evaluate_net.py
import torch from new_model import NetworkNew_test import argparse import torch.backends.cudnn as cudnn import os import sys import time sys.path.append('../') from src_code.lmdbdataset import lmdbDataset parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argument('--batch_...
3,968
31.532787
106
py
AutoPruner
AutoPruner-master/vgg16/50/fine_tune_compressed_model.py
import argparse import os import shutil import time import sys 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.utils.data import torch.utils.data.distributed from torchvision import datasets, transforms fro...
10,897
35.693603
106
py
AutoPruner
AutoPruner-master/vgg16/50/main.py
# ************************************************************ # Author : Bumsoo Kim, 2017 # Github : https://github.com/meliketoy/fine-tuning.pytorch # # Korea University, Data-Mining Lab # Deep Convolutional Network Fine tuning Implementation # # Description : main.py # The main code for training classification netwo...
12,807
38.409231
126
py
AutoPruner
AutoPruner-master/vgg16/50/evaluate_network.py
import torch import torch.backends.cudnn as cudnn import os import sys import argparse import time from src_code.lmdbdataset import lmdbDataset from src_code import Network_FT parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argument('--batch_size', default=100, type=int...
4,055
31.709677
107
py
AutoPruner
AutoPruner-master/vgg16/50/mytest.py
# ************************************************************ # Author : Bumsoo Kim, 2017 # Github : https://github.com/meliketoy/fine-tuning.pytorch # # Korea University, Data-Mining Lab # Deep Convolutional Network Fine tuning Implementation # # Description : main.py # The main code for training classification netwo...
11,382
37.849829
120
py
AutoPruner
AutoPruner-master/vgg16/50/fine_tune_vgg16.py
import argparse import os import shutil import time import sys 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.utils.data import torch.utils.data.distributed from torchvision import datasets, models, transf...
11,358
35.760518
106
py
AutoPruner
AutoPruner-master/vgg16/50/fine_tune_GAP.py
import argparse import os import shutil import time import sys 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.utils.data import torch.utils.data.distributed from torchvision import datasets, transforms fro...
10,791
35.707483
106
py
AutoPruner
AutoPruner-master/vgg16/50/tools/create_lmdb.py
# loads imagenet and writes it into one massive binary file import os import numpy as np from tensorpack.dataflow import * import sys if __name__ == '__main__': if len(sys.argv) < 4 : print("Usage: python create_lmdb.py gt_file.txt root_folder target_lmdb_name") print("gt_file.txt split by \"\t\"")...
1,514
35.95122
86
py
AutoPruner
AutoPruner-master/vgg16/50/tools/organize_dataset.py
""" this script is used for organize CUB200 dataset: -- images -- train -- [:class 0] -- [:class 1] ... -- [:class n] -- val -- [:class 0] -- [:class 1] ... -- [:class n] """ import os import PIL.Image import numpy as np import shutil ori...
2,295
31.8
82
py
AutoPruner
AutoPruner-master/vgg16/50/src_code/my_op_fc.py
import torch from torch.autograd import Variable import torch.nn as nn from torch.autograd import gradcheck import numpy as np class MyGAP_fc(torch.autograd.Function): ''' Global Average Pooling with batchsize: N*4096 -> 1*4096 ''' @staticmethod def forward(ctx, input): ctx.save_for_backw...
2,729
31.117647
76
py
AutoPruner
AutoPruner-master/vgg16/50/src_code/my_op.py
import torch from torch.autograd import Variable import torch.nn as nn from torch.autograd import gradcheck import math class MyGAP(torch.autograd.Function): ''' Global Average Pooling with batchsize: N*512*14*14 -> 1*512*14*14 ''' @staticmethod def forward(ctx, input): ctx.save_for_backw...
3,318
33.572917
93
py
AutoPruner
AutoPruner-master/vgg16/50/src_code/Network_FT.py
import torch from . import my_op from torch import nn class NetworkNew(torch.nn.Module): def __init__(self, layer_id=0): torch.nn.Module.__init__(self) model_weight = torch.load('checkpoint/model.pth') channel_length = list() channel_length.append(3) for k, v in model_weigh...
8,144
49.590062
119
py
AutoPruner
AutoPruner-master/vgg16/50/src_code/lmdbdataset.py
import cv2 import numpy as np import torchvision.transforms as transforms import lmdb import msgpack from torch.utils.data import Dataset from PIL import Image class lmdbDataset(Dataset): def __init__(self, location, is_train): self.env = lmdb.open(location, subdir=False, max_readers=1, readonly=True, loc...
2,431
34.246377
111
py
AutoPruner
AutoPruner-master/vgg16/50/compress_model/new_model.py
import torch from torch import nn import numpy as np import os import torch.nn.init as init class vgg16_compressed(torch.nn.Module): def __init__(self, layer_id=0, model_path=None): torch.nn.Module.__init__(self) model_weight = torch.load(model_path + 'model.pth') channel_index = torch.loa...
10,696
43.570833
119
py
AutoPruner
AutoPruner-master/vgg16/50/compress_model/compress_model.py
import torch from new_model import vgg16_compressed import argparse import torch.backends.cudnn as cudnn parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argument('--layer_id', default=2, type=int, help='the id of compressed layer, starting from 0') args = parser.parse_a...
908
31.464286
106
py
AutoPruner
AutoPruner-master/vgg16/50/compress_model/evaluate_net.py
import torch from new_model import vgg16_compressed, vgg16_test import argparse import torch.backends.cudnn as cudnn import os import sys import time sys.path.append('../') from src_code.lmdbdataset import lmdbDataset parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argum...
4,451
31.977778
106
py
AutoPruner
AutoPruner-master/MobileNetv2/released_model/evaluate.py
import torch import torch.nn as nn import torch.backends.cudnn as cudnn import time import os import sys import argparse from torchvision import datasets, transforms import mobilenetv2 from torchsummaryX import summary parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argu...
5,806
32.761628
116
py
AutoPruner
AutoPruner-master/MobileNetv2/released_model/mobilenetv2.py
""" Creates a MobileNetV2 Model as defined in: Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, Liang-Chieh Chen. (2018). MobileNetV2: Inverted Residuals and Linear Bottlenecks arXiv preprint arXiv:1801.04381. import from https://github.com/tonylins/pytorch-mobilenet-v2 """ import torch.nn as nn import mat...
5,774
32.77193
120
py
AutoPruner
AutoPruner-master/MobileNetv2/2_fine_tune/main.py
import torch import torch.nn as nn import torch.backends.cudnn as cudnn import time import os import sys import argparse from torchvision import datasets, transforms from src_code import mobilenetv2 from torchsummaryX import summary from math import cos, pi parser = argparse.ArgumentParser(description='PyTorch Digital...
9,434
33.944444
119
py
AutoPruner
AutoPruner-master/MobileNetv2/2_fine_tune/src_code/mobilenetv2.py
""" Creates a MobileNetV2 Model as defined in: Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, Liang-Chieh Chen. (2018). MobileNetV2: Inverted Residuals and Linear Bottlenecks arXiv preprint arXiv:1801.04381. import from https://github.com/tonylins/pytorch-mobilenet-v2 """ import torch.nn as nn import to...
6,370
32.356021
120
py
AutoPruner
AutoPruner-master/MobileNetv2/2_fine_tune/src_code/Network_FT.py
import torch from torch import nn import numpy as np class VGG16(torch.nn.Module): def __init__(self, model_path): torch.nn.Module.__init__(self) self.maxpool = nn.MaxPool2d(kernel_size=2, stride=2) self.ReLU = nn.ReLU(inplace=True) # load channel index f = open('../1_prun...
4,591
38.247863
108
py
AutoPruner
AutoPruner-master/MobileNetv2/1_pruning/main.py
import torch import torch.nn as nn import torch.backends.cudnn as cudnn import time import os import sys import argparse import numpy as np import shutil from torchvision import datasets, transforms from src_code import mobilenetv2 parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') pa...
11,003
35.68
144
py
AutoPruner
AutoPruner-master/MobileNetv2/1_pruning/evaluate.py
import torch import torch.nn as nn import torch.backends.cudnn as cudnn import time import os import sys import argparse from torchvision import datasets, transforms from src_code import mobilenetv2 from torchsummaryX import summary parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') p...
8,623
34.489712
144
py
AutoPruner
AutoPruner-master/MobileNetv2/1_pruning/src_code/mobilenetv2.py
""" Creates a MobileNetV2 Model as defined in: Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, Liang-Chieh Chen. (2018). MobileNetV2: Inverted Residuals and Linear Bottlenecks arXiv preprint arXiv:1801.04381. import from https://github.com/tonylins/pytorch-mobilenet-v2 """ import torch.nn as nn import ma...
7,872
34.949772
122
py
AutoPruner
AutoPruner-master/MobileNetv2/1_pruning/src_code/my_op.py
import torch from torch.autograd import Variable import torch.nn as nn from torch.autograd import gradcheck import math class MyGAP(torch.autograd.Function): ''' Global Average Pooling with batchsize: N*512*14*14 -> 1*512*14*14 ''' @staticmethod def forward(ctx, input): ctx.save_for_backw...
3,128
34.965517
93
py
AutoPruner
AutoPruner-master/MobileNetv2/1_pruning/src_code/Network_FT.py
import torch from . import my_op from torch import nn class VGG16(torch.nn.Module): def __init__(self, model_path): torch.nn.Module.__init__(self) self.maxpool = nn.MaxPool2d(kernel_size=2, stride=2) self.ReLU = nn.ReLU(inplace=True) # add feature layers self.conv1_1 = nn....
4,519
50.363636
98
py
AutoPruner
AutoPruner-master/MobileNetv2/1_pruning/compress_model/new_model.py
import torch from torch import nn import numpy as np import os import torch.nn.init as init class vgg16_compressed(torch.nn.Module): def __init__(self, layer_id=0, model_path=None): torch.nn.Module.__init__(self) model_weight = torch.load(model_path + 'model.pth') channel_index = torch.loa...
10,696
43.570833
119
py
AutoPruner
AutoPruner-master/MobileNetv2/1_pruning/compress_model/compress_model.py
import torch from new_model import vgg16_compressed import argparse import torch.backends.cudnn as cudnn parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argument('--layer_id', default=2, type=int, help='the id of compressed layer, starting from 0') args = parser.parse_a...
908
31.464286
106
py
AutoPruner
AutoPruner-master/MobileNetv2/1_pruning/compress_model/evaluate_net.py
import torch from new_model import vgg16_compressed, vgg16_test import argparse import torch.backends.cudnn as cudnn import os import sys import time sys.path.append('../') from src_code.lmdbdataset import lmdbDataset parser = argparse.ArgumentParser(description='PyTorch Digital Mammography Training') parser.add_argum...
4,451
31.977778
106
py
noise2noise
noise2noise-master/train_mri.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
19,442
39.422037
282
py
noise2noise
noise2noise-master/config_mri.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
3,947
40.125
134
py
noise2noise
noise2noise-master/validation.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
3,678
36.540816
114
py
noise2noise
noise2noise-master/network.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain...
3,609
30.391304
97
py
noise2noise
noise2noise-master/dataset.py
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # This work is licensed under the Creative Commons Attribution-NonCommercial # 4.0 International License. To view a copy of this license, visit # http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to # Creative Commons, PO Box 1866, Mountain ...
2,009
35.545455
128
py