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 |
|---|---|---|---|---|---|---|
dtr-prototype | dtr-prototype-master/checkmate_comp/tests/test_keras_testnet.py | import logging
from experiments.common.load_keras_model import get_keras_model
from remat.core.solvers.strategy_checkpoint_all import solve_checkpoint_all
from remat.tensorflow2.extraction import dfgraph_from_keras
def test_testnet_checkpointall():
model = get_keras_model("test")
g = dfgraph_from_keras(mod=m... | 1,287 | 35.8 | 88 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/tests/test_execution.py | # from experiments.common.definitions import remat_data_dir
# from experiments.common.graph_plotting import render_dfgraph
# from experiments.common.load_keras_model import get_keras_model
# from remat.tensorflow2.extraction import dfgraph_from_keras
# from experiments.common.execution_utils import random_batch
# from ... | 1,860 | 40.355556 | 88 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/tests/print_graphs.py | from remat.core.solvers.strategy_checkpoint_all import solve_checkpoint_all, solve_checkpoint_all_ap
from remat.core.solvers.strategy_checkpoint_last import solve_checkpoint_last_node
from remat.core.solvers.strategy_chen import solve_chen_greedy, solve_chen_sqrtn
from remat.core.solvers.strategy_griewank import solve_... | 714 | 54 | 100 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/remat/tensorflow2/extraction.py | import logging
from collections import defaultdict
from typing import Optional
import tensorflow as tf
from experiments.common.profile.cost_model import CostModel
from remat.core import dfgraph
from remat.tensorflow2.extraction_hooks import op_hook, MEMORY_MULTIPLIER
try:
from tensorflow.python.keras.utils.layer... | 5,319 | 46.079646 | 127 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/remat/tensorflow2/extraction_hooks.py | import numpy as np
MEMORY_MULTIPLIER = 4 # 4 bytes per variable
LAST_DIMS = None
def get_attr(node, name, typ="ints"):
out = []
for attr in node.attribute:
if attr.name == name:
for val in eval("attr.{}".format(typ)):
out.append(val)
return tuple(out)
def conv_trans... | 7,327 | 29.280992 | 92 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/remat/tensorflow2/tf_losses.py | import tensorflow as tf
# noinspection PyUnresolvedReferences
def categorical_cross_entropy(pred_logits, labels, model_losses=[]):
loss = tf.keras.losses.categorical_crossentropy(labels, pred_logits, from_logits=True)
loss += 0 if not model_losses else tf.add_n(model_losses) # regularization
return loss
| 320 | 34.666667 | 90 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/experiments/plot_simrd_comparison.py | import argparse
import logging
import os
import pathlib
import pickle
import shutil
import uuid
from collections import defaultdict
from typing import Dict, List, Optional
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import ray
import seaborn as sns
import tensorflow as tf
f... | 9,430 | 38.961864 | 110 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/experiments/experiment_approxsweep.py | from remat.core.dfgraph import gen_linear_graph
from remat.core.solvers.strategy_approx_lp import solve_approx_lp_deterministic_sweep
from experiments.common.definitions import remat_data_dir
from experiments.common.graph_plotting import plot
from remat.core.solvers.strategy_checkpoint_all import solve_checkpoint_all
f... | 4,288 | 47.738636 | 168 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/experiments/experiment_budget_sweep_with_approximation.py | import argparse
import logging
import os
import pathlib
import pickle
import shutil
import uuid
from collections import defaultdict
from typing import Dict, List, Optional
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import ray
import seaborn as sns
import tensorflow as tf
from matplotlib.lin... | 23,651 | 50.529412 | 120 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/experiments/experiment_budget_sweep_simrd.py | import argparse
import logging
import os
import pathlib
import pickle
import shutil
import uuid
from collections import defaultdict
from typing import Dict, List, Optional
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import ray
import seaborn as sns
import tensorflow as tf
from matplotlib.lin... | 5,373 | 38.807407 | 113 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/experiments/experiment_budget_sweep.py | import argparse
import logging
import os
import pathlib
import pickle
import shutil
import uuid
from collections import defaultdict
from typing import Dict, List, Optional
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import ray
import seaborn as sns
import tensorflow as tf
from matplotlib.lin... | 20,252 | 48.157767 | 120 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/experiments/experiment_max_batchsize_baseline.py | import argparse
import logging
import os
import pathlib
import shutil
import uuid
from collections import defaultdict
from typing import Dict, List
import numpy as np
import pandas
import tensorflow as tf
import ray
from tqdm import tqdm
from experiments.common.definitions import remat_data_dir
from experiments.commo... | 6,193 | 46.646154 | 116 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/experiments/experiment_max_batchsize_ilp.py | import argparse
import logging
import math
import os
import pathlib
import shutil
from collections import defaultdict
from typing import Dict, List
import tensorflow as tf
from experiments.common.definitions import remat_data_dir
from experiments.common.graph_plotting import render_dfgraph, plot
from experiments.comm... | 3,531 | 40.552941 | 116 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/experiments/common/load_keras_model.py | import re
from typing import Optional, List
import keras_segmentation
import tensorflow as tf
KERAS_APPLICATION_MODEL_NAMES = ['InceptionV3', 'VGG16', 'VGG19', 'ResNet50',
'Xception', 'MobileNet', 'MobileNetV2', 'DenseNet121',
'DenseNet169', 'DenseNet2... | 3,329 | 42.246753 | 118 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/experiments/common/execution_utils.py | import tensorflow as tf
def random_batch(batch_size, data_format="channels_last", num_classes=1000, img_h=224, img_w=224, num_channels=3):
shape = (num_channels, img_h, img_w) if data_format == "channels_first" else (img_h, img_w, num_channels)
shape = (batch_size,) + shape
images = tf.keras.backend.rando... | 514 | 50.5 | 114 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/_deprecated_src/execute_one.py | #!/bin/env/python
# Executes a model under a single batch size, input size, solver, and platform configuration
import argparse
import os
import pickle
import dotenv
from remat.core.enum_strategy import SolveStrategy
from experiments.common.load_keras_model import MODEL_NAMES
from evaluation.eval_execution import ex... | 5,427 | 41.740157 | 180 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/_deprecated_src/profile_keras.py | import argparse
import json
import os.path as osp
import numpy as np
import tensorflow.compat.v2 as tf
from tensorflow.python.client import timeline
import tensorflow.compat.v1 as tf1
from experiments.common.load_keras_model import MODEL_NAMES, get_keras_model
def get_names(timeline):
print()
events = json.... | 9,991 | 39.453441 | 107 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/_deprecated_src/get_shapes.py | from experiments.common.load_keras_model import MODEL_NAMES, get_keras_model
# MODEL_NAMES = ['VGG16', 'VGG19', 'MobileNet', 'fcn_8', 'pspnet', 'vgg_unet', 'unet', 'segnet', 'resnet50_segnet']
if __name__ == "__main__":
for name in MODEL_NAMES:
print(name, end=" ")
try:
model = get_ker... | 477 | 35.769231 | 115 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/_deprecated_src/evaluation/eval_execution.py | import os
from typing import Optional, List, Tuple
from tqdm import tqdm
import pandas
import tensorflow as tf
import tensorflow.compat.v1 as tf1
import numpy as np
from remat.core.enum_strategy import SolveStrategy
from integration.tf2.TF2ExtractorParams import TF2ExtractorParams
from experiments.common.load_keras_m... | 7,707 | 40.44086 | 120 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/_deprecated_src/integration/tf2/runtimes.py | import tensorflow as tf
import numpy as np
import importlib
import os.path as osp
# from tensorflow.keras import layers
from tensorflow import keras
from tensorflow.python.client import timeline
from tensorflow.keras import backend as K
import numpy as np
import matplotlib.pyplot as plt
import tensorflow.compat.v1 as t... | 6,254 | 36.909091 | 87 | py |
dtr-prototype | dtr-prototype-master/checkmate_comp/_deprecated_src/integration/tf2/TF2Runner.py | import os
import tensorflow as tf
from remat.tensorflow2.execution import sort_by_dep_order, match_variables
from remat.tensorflow2.tf_losses import categorical_cross_entropy
from remat.core.schedule import OperatorEvaluation, AllocateRegister, DeallocateRegister, Schedule
from remat.core.dfgraph import DFGraph
from ... | 6,193 | 50.616667 | 112 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/pt_trial_util.py | """
Utilities for setting up PyTorch memory usage experiments.
"""
import csv
from itertools import product as iter_product
import os
import subprocess
import time
import numpy as np
from common import (check_file_exists, prepare_out_file,
read_json, render_exception, write_json)
MEASURED_KEYS = ... | 21,466 | 39.58034 | 174 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/validate_config.py | """Checks that experiment config is valid and pre-populates default values."""
from common import read_config
from config_util import check_config, bool_cond, non_negative_cond, string_cond
MODELS = {
# CIFAR resnets
'resnet20', 'resnet32', 'resnet44', 'resnet56', 'resnet110', 'resnet1202',
# Torchvision ... | 3,168 | 31.336735 | 85 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/run_torch_trial.py | """
To avoid any issues of memory hanging around between inputs,
we run each input as a separate process.
A little ugly but effective
"""
import glob
import os
import random
import math
import time
from queue import Queue as LocalQueue # contrast with mp.Queue
import multiprocessing as mp
from common import invoke_m... | 15,578 | 36.539759 | 116 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/model_util.py | import json
import os
import random
import torch
import copy
import numpy as np
from torch_models import word_language_model as wlm
from torch_models import vision_models as vm
from torch_models import treelstm
from torch_models import unet
from torch_models import lstm
from torch_models import unroll_gan
from torch_m... | 30,942 | 35.022119 | 154 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/__init__.py | from . import word_language_model
from . import vision_models
from . import inceptionv4
from . import pytorch_resnet_cifar10
from . import treelstm
from . import unet
from . import lstm
from . import densenet_bc
| 212 | 22.666667 | 36 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/densenet_bc/model.py | '''
This model is adopted from
https://github.com/bamos/densenet.pytorch/blob/master/densenet.py
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
import sys
import math
class Bottleneck(nn.Module):
def __init__(self, nChannels, growthRate):
super(Bottleneck, self).__init__()
... | 3,977 | 34.837838 | 87 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/unroll_gan/utils.py | import torch
import higher
import copy
# from .configs import yes_higher_unroll as config
from .data import noise_sampler
def d_loop(config, dset, G, D, d_optimizer, criterion):
# 1. Train D on real+fake
d_optimizer.zero_grad()
# 1A: Train D on real
d_real_data = torch.from_numpy(dset.sample(conf... | 5,113 | 39.267717 | 120 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/unroll_gan/model.py | '''
This model is from
https://github.com/MarisaKirisame/unroll_gan/blob/master/model.py
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class Generator(nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(Generator, self).__init__()
self.map1 = nn.Lin... | 1,494 | 33.767442 | 66 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/word_language_model/main.py | # coding: utf-8
import math
import torch
import torch.nn as nn
from . import data
from . import model
# commented out so that this file's functions can be imported
# parser = argparse.ArgumentParser(description='PyTorch Wikitext-2 RNN/LSTM Language Model')
# parser.add_argument('--data', type=str, default='./data/wi... | 10,439 | 40.593625 | 123 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/word_language_model/model.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class RNNModel(nn.Module):
"""Container module with an encoder, a recurrent module, and a decoder."""
def __init__(self, rnn_type, ntoken, ninp, nhid, nlayers, dropout=0.5, tie_weights=False):
super(RNNModel, self).__init__... | 6,242 | 40.344371 | 110 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/word_language_model/data.py | import os
from io import open
import torch
class Dictionary(object):
def __init__(self):
self.word2idx = {}
self.idx2word = []
def add_word(self, word):
if word not in self.word2idx:
self.idx2word.append(word)
self.word2idx[word] = len(self.idx2word) - 1
... | 1,482 | 29.265306 | 67 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/lstm/model.py | '''
This model is obtained from
https://github.com/jiangqy/LSTM-Classification-pytorch/blob/master/utils/LSTMClassifier.py
'''
import torch.nn as nn
import torch.nn.functional as F
import torch
from torch.autograd import Variable
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional... | 4,426 | 37.495652 | 134 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/lstm/data_processing.py | '''
This source is obtained from
https://github.com/jiangqy/LSTM-Classification-pytorch/blob/master/utils/DataProcessing.py
'''
import os
import torch
from torch.utils.data.dataset import Dataset
import numpy as np
import random
class Dictionary(object):
def __init__(self):
self.word2idx = {}
self... | 3,369 | 34.473684 | 124 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/lstm/data/split_data.py | '''
This source is obtained from
https://github.com/jiangqy/LSTM-Classification-pytorch/blob/master/data/split_data.py
'''
import os
TRAIN_FILE = 'r8-train-all-terms.txt'
TEST_FILE = 'r8-test-all-terms.txt'
TRAID_DIR = 'train_txt'
TEST_DIR = 'test_txt'
if __name__=='__main__':
train_file = []
fp = open(os.path... | 1,966 | 27.507246 | 85 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/pytorch_resnet_cifar10/resnet.py | '''
Properly implemented ResNet-s for CIFAR10 as described in paper [1].
The implementation and structure of this file is hugely influenced by [2]
which is implemented for ImageNet and doesn't have option A for identity.
Moreover, most of the implementations on the web is copy-paste from
torchvision's resnet and has w... | 4,985 | 30.358491 | 120 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/treelstm/main.py | from __future__ import division
from __future__ import print_function
import os
import random
import logging
import torch
import torch.nn as nn
import torch.optim as optim
# IMPORT CONSTANTS
from treelstm import Constants
# NEURAL NETWORK MODULES/LAYERS
from treelstm import SimilarityTreeLSTM
# DATA HANDLING CLASSES... | 7,336 | 39.988827 | 99 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/treelstm/treelstm/utils.py | from __future__ import division
from __future__ import print_function
import os
import math
import torch
import random
import math
from .vocab import Vocab
from .tree import Tree
# loading GLOVE word vectors
# if .pth file is found, will load that
# else will load from .txt file & save
def load_word_vectors(path)... | 2,868 | 33.154762 | 130 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/treelstm/treelstm/model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from . import Constants
from torch_models import lstm as LSTM
# module for childsumtreelstm
class ChildSumTreeLSTM(nn.Module):
def __init__(self, in_dim, mem_dim):
super(ChildSumTreeLSTM, self).__init__()
self.in_dim = in_dim
... | 3,819 | 36.821782 | 100 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/treelstm/treelstm/dataset.py | import os
from tqdm import tqdm
from copy import deepcopy
import torch
import random
import torch.utils.data as data
from . import Constants
from .tree import Tree
# Dataset class for SICK dataset
class SICKDataset(data.Dataset):
def __init__(self, path, vocab, num_classes):
super(SICKDataset, self).__i... | 3,618 | 33.141509 | 97 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/treelstm/treelstm/metrics.py | from copy import deepcopy
import torch
class Metrics():
def __init__(self, num_classes):
self.num_classes = num_classes
def pearson(self, predictions, labels):
x = deepcopy(predictions)
y = deepcopy(labels)
x = (x - x.mean()) / x.std()
y = (y - y.mean()) / y.std()
... | 504 | 23.047619 | 43 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/treelstm/treelstm/trainer.py | from tqdm import tqdm
import torch
from . import utils
import torchviz
class Trainer(object):
def __init__(self, args, model, criterion, optimizer, device):
super(Trainer, self).__init__()
self.args = args
self.model = model
self.criterion = criterion
self.optimizer = opti... | 2,297 | 40.781818 | 96 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/shufflenetv2.py | import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = [
'ShuffleNetV2', 'shufflenet_v2_x0_5', 'shufflenet_v2_x1_0',
'shufflenet_v2_x1_5', 'shufflenet_v2_x2_0'
]
model_urls = {
'shufflenetv2_x0.5': 'https://download.pytorch.org/models/shufflenetv2_x0.5-f707e7126e.pth',
... | 7,698 | 35.837321 | 114 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/_utils.py | from collections import OrderedDict
import torch
from torch import nn
from torch.jit.annotations import Dict
class IntermediateLayerGetter(nn.ModuleDict):
"""
Module wrapper that returns intermediate layers from a model
It has a strong assumption that the modules have been registered
into the model ... | 2,604 | 37.308824 | 89 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/inception.py | from collections import namedtuple
import warnings
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.jit.annotations import Optional
from torch import Tensor
from .utils import load_state_dict_from_url
__all__ = ['Inception3', 'inception_v3', 'InceptionOutputs', '_InceptionOutputs']
mode... | 16,694 | 36.68623 | 119 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/resnet.py | import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152', 'resnext50_32x4d', 'resnext101_32x8d',
'wide_resnet50_2', 'wide_resnet101_2']
model_urls = {
'resnet18': 'https://download.pytor... | 13,737 | 38.251429 | 107 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/squeezenet.py | import torch
import torch.nn as nn
import torch.nn.init as init
from .utils import load_state_dict_from_url
__all__ = ['SqueezeNet', 'squeezenet1_0', 'squeezenet1_1']
model_urls = {
'squeezenet1_0': 'https://download.pytorch.org/models/squeezenet1_0-a815701f.pth',
'squeezenet1_1': 'https://download.pytorch.or... | 5,449 | 38.492754 | 86 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/vgg.py | import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = [
'VGG', 'vgg11', 'vgg11_bn', 'vgg13', 'vgg13_bn', 'vgg16', 'vgg16_bn',
'vgg19_bn', 'vgg19',
]
model_urls = {
'vgg11': 'https://download.pytorch.org/models/vgg11-bbd30ac9.pth',
'vgg13': 'https://download.pytorch... | 7,233 | 38.315217 | 113 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/mnasnet.py | import math
import warnings
import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = ['MNASNet', 'mnasnet0_5', 'mnasnet0_75', 'mnasnet1_0', 'mnasnet1_3']
_MODEL_URLS = {
"mnasnet0_5":
"https://download.pytorch.org/models/mnasnet0.5_top1_67.823-3ffadce67e.pth",
"mnasnet0_75... | 10,620 | 40.007722 | 83 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/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
| 151 | 29.4 | 74 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/densenet.py | import re
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as cp
from collections import OrderedDict
from .utils import load_state_dict_from_url
from torch import Tensor
from torch.jit.annotations import List
__all__ = ['DenseNet', 'densenet121', 'densenet169', 'densene... | 11,809 | 40.879433 | 112 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/googlenet.py | from __future__ import division
import warnings
from collections import namedtuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.jit.annotations import Optional, Tuple
from torch import Tensor
from .utils import load_state_dict_from_url
__all__ = ['GoogLeNet', 'googlenet', "GoogLeNetOu... | 10,372 | 34.892734 | 101 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/mobilenet.py | from torch import nn
from .utils import load_state_dict_from_url
__all__ = ['MobileNetV2', 'mobilenet_v2']
model_urls = {
'mobilenet_v2': 'https://download.pytorch.org/models/mobilenet_v2-b0353104.pth',
}
def _make_divisible(v, divisor, min_value=None):
"""
This function is taken from the original tf ... | 6,338 | 34.813559 | 107 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/vision_models/alexnet.py | import torch
import torch.nn as nn
from .utils import load_state_dict_from_url
__all__ = ['AlexNet', 'alexnet']
model_urls = {
'alexnet': 'https://download.pytorch.org/models/alexnet-owt-4df8aa71.pth',
}
class AlexNet(nn.Module):
def __init__(self, num_classes=1000):
super(AlexNet, self).__init__... | 2,102 | 30.863636 | 83 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/unet/unet_model.py | """ Full assembly of the parts to form the complete network """
import torch.nn.functional as F
from .unet_parts import *
class UNet(nn.Module):
def __init__(self, n_channels, n_classes, bilinear=True):
super(UNet, self).__init__()
self.n_channels = n_channels
self.n_classes = n_classes
... | 1,162 | 28.820513 | 63 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/unet/unet_parts.py | """ Parts of the U-Net model """
import torch
import torch.nn as nn
import torch.nn.functional as F
class DoubleConv(nn.Module):
"""(convolution => [BN] => ReLU) * 2"""
def __init__(self, in_channels, out_channels, mid_channels=None):
super().__init__()
if not mid_channels:
mid_c... | 2,580 | 31.670886 | 122 | py |
dtr-prototype | dtr-prototype-master/dtr_code/shared/torch_models/inceptionv4/inceptionv4.py | from __future__ import print_function, division, absolute_import
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.model_zoo as model_zoo
import os
import sys
__all__ = ['InceptionV4', 'inceptionv4']
class BasicConv2d(nn.Module):
def __init__(self, in_planes, out_planes, kernel... | 9,170 | 30.954704 | 91 | py |
dtr-prototype | dtr-prototype-master/simrd/tests/test_graph.py | import traceback
from simrd.parse import *
from simrd.runtime import *
from simrd.heuristic import Heuristic, DTR, DTREqClass
try:
from remat.core.solvers import strategy_optimal_ilp as ilp
from remat.core.solvers import strategy_checkpoint_last as last
from remat.tensorflow2.extraction import dfgraph_from_kera... | 11,586 | 35.209375 | 111 | py |
oracle-mnist | oracle-mnist-main/src/train_tensorflow_keras.py | import argparse
import numpy as np
from tensorflow.python.keras.utils.np_utils import to_categorical
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Activation, Convolution2D, MaxPool2D,Flatten
from tensorflow.keras.optimizers import Adam, SGD
import mnist_reader
def train(arg... | 2,514 | 41.627119 | 160 | py |
oracle-mnist | oracle-mnist-main/src/train_pytorch.py | import argparse
import torch, os, gzip
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from PIL import Image
from torch.utils.data import Dataset
from torchvision import datasets, transforms
import mnist_reader
class Net1(nn.Module):
def __init__(self):
... | 7,054 | 40.745562 | 140 | py |
OAProgressionMR | OAProgressionMR-main/entry/eval_prog.py | import os
import logging
import time
import pickle
import functools
from pathlib import Path
from collections import defaultdict
os.environ["MKL_NUM_THREADS"] = "1"
os.environ["NUMEXPR_NUM_THREADS"] = "1"
os.environ["OMP_NUM_THREADS"] = "1"
import numpy as np
from scipy.special import softmax
import cv2
import pandas ... | 10,993 | 36.780069 | 96 | py |
OAProgressionMR | OAProgressionMR-main/entry/train_prog.py | import os
import gc
import logging
from pathlib import Path
from collections import defaultdict
os.environ["MKL_NUM_THREADS"] = "1"
os.environ["NUMEXPR_NUM_THREADS"] = "1"
os.environ["OMP_NUM_THREADS"] = "1"
import numpy as np
import cv2
import torch
from torch import nn
from torch.utils.tensorboard import SummaryWrit... | 14,204 | 38.678771 | 87 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_core_fes.py | from torchvision import models
from ._torchvision import resnext50_32x4d
dict_fes = {
"squeezenet1_0": models.squeezenet1_0,
"vgg16": models.vgg16,
"inception_v3": models.inception_v3,
"resnet18": models.resnet18,
"resnet34": models.resnet34,
"resnet50": models.resnet50,
"resnext50_32x4d":... | 340 | 23.357143 | 42 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_core_trf.py | import torch
import torch.functional as F
from torch import nn
from einops import rearrange
class FeaT(nn.Module):
def __init__(self, num_patches, patch_dim, emb_dim, depth, heads, mlp_dim,
num_classes, emb_dropout=0., with_cls=True, num_cls_tokens=1,
mlp_dropout=0., num_outputs=... | 4,981 | 35.101449 | 96 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_mr_cnn_lstm.py | import math
from collections import OrderedDict
import torch
from torch import nn
from einops import rearrange, repeat
from ._core_fes import dict_fes
class MRCnnLstm(nn.Module):
def __init__(self, config, path_weights):
super(MRCnnLstm, self).__init__()
self.config = config
if self.confi... | 4,407 | 34.264 | 88 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_torchvision.py | import torch
from torch import Tensor
import torch.nn as nn
from torch.utils.model_zoo import load_url as load_state_dict_from_url
from typing import Type, Any, Callable, Union, List, Optional
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152', 'resnext50_32x4d', 'resnext101_... | 15,460 | 39.794195 | 111 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_mr_cnn_trf.py | import copy
from collections import OrderedDict
import torch
from torch import nn
from einops import rearrange, repeat
from ._core_trf import FeaT
from ._core_fes import dict_fes
class MRCnnTrf(nn.Module):
def __init__(self, config, path_weights):
super(MRCnnTrf, self).__init__()
self.config = co... | 11,060 | 37.947183 | 91 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_mr_cnn_fc.py | import math
from collections import OrderedDict
import torch
from torch import nn
from einops import rearrange, repeat
from einops.layers.torch import Rearrange, Reduce
from ._core_fes import dict_fes
class MRCnnFc(nn.Module):
def __init__(self, config, path_weights):
super(MRCnnFc, self).__init__()
... | 4,306 | 35.5 | 88 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_resnet2p1d.py | """Partially based on https://github.com/kenshohara/3D-ResNets-PyTorch/blob/master/models/resnet2p1d.py
See also https://openaccess.thecvf.com/content_cvpr_2018/papers/Tran_A_Closer_Look_CVPR_2018_paper.pdf"""
from collections import OrderedDict
from functools import partial
import torch
import torch.nn as nn
import t... | 9,661 | 34.522059 | 105 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_shufflenet3d.py | """
Partially based on https://github.com/okankop/Efficient-3DCNNs/blob/master/models/shufflenet.py
Comparison against other archs: https://arxiv.org/pdf/1904.02422.pdf
See also "ShuffleNet: An Extremely Efficient Convolutional Neural Network for Mobile Devices"
"""
from collections import OrderedDict
import torch
imp... | 4,949 | 36.5 | 96 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_xr_cnn.py | from collections import OrderedDict
import torch
from torch import nn
from einops import rearrange, repeat
from ._core_fes import dict_fes
class XRCnn(nn.Module):
def __init__(self, config, path_weights):
super(XRCnn, self).__init__()
self.config = config
if self.config["debug"]:
... | 2,407 | 31.106667 | 90 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/models/_resnet_resnext_3d.py | """Partially based on https://github.com/okankop/Efficient-3DCNNs/tree/master/models
For Inception3D - I3D - see https://github.com/tomrunia/PyTorchConv3D/blob/master/models/i3d.py"""
import math
from collections import OrderedDict
from functools import partial
import torch
import torch.nn as nn
import torch.nn.functi... | 13,322 | 34.718499 | 101 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/various/_losses.py | import logging
import torch
import torch.nn.functional as F
from torch import nn
logging.basicConfig()
logger = logging.getLogger('losses')
logger.setLevel(logging.DEBUG)
class CrossEntropyLoss(nn.Module):
def __init__(self, num_classes, batch_avg=True, batch_weight=None,
class_avg=True, class... | 3,255 | 26.82906 | 89 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/various/_checkpoint.py | import os
from pathlib import Path
import logging
import torch
logging.basicConfig()
logger = logging.getLogger('handler')
logger.setLevel(logging.DEBUG)
class CheckpointHandler(object):
def __init__(self, path_root,
fname_pattern=('{model_name}__'
'fold_{fold_i... | 2,074 | 32.467742 | 79 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/various/_seed.py | def set_ultimate_seed(base_seed=777):
import os
import random
os.environ['PYTHONHASHSEED'] = str(base_seed)
random.seed(base_seed)
try:
import numpy as np
np.random.seed(base_seed)
except ModuleNotFoundError:
print('Module `numpy` has not been found')
try:
i... | 603 | 27.761905 | 50 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/various/_optimizers.py | from torch import optim
def CustomWarmupStaticDecayLR(optimizer, epochs_warmup, epochs_static, epochs_decay,
warmup_factor=0.1, decay_factor=0.9, **kwargs):
def fn(epoch):
end_w = epochs_warmup
end_s = end_w + epochs_static
if epoch <= end_w:
## L... | 2,119 | 32.125 | 86 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/datasets/_data_provider.py | """
Entry point to all available datasets, subsets, folds, and dataloaders.
"""
import logging
from pathlib import Path
from collections import defaultdict
import pandas as pd
import sklearn.model_selection
from torch.utils.data import DataLoader, WeightedRandomSampler
from oaprmr import preproc
from oaprmr.various ... | 15,185 | 39.604278 | 100 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/datasets/oai/_dataset.py | import os
import logging
from pathlib import Path
from functools import reduce
from collections import defaultdict
from joblib import Parallel, delayed
import numpy as np
import pandas as pd
from torch.utils.data.dataset import Dataset
from tqdm import tqdm
from oaprmr.various import nifti_to_numpy, png_to_numpy
l... | 12,156 | 34.861357 | 95 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/preproc/_pt.py | import random
import torch
import torch.nn.functional as F
from einops import rearrange
class PTToUnitRange(object):
def __init__(self):
pass
def __call__(self, image, mask=None):
"""
Parameters
----------
image: (D0, ...) 1D-nD Tensor
mask: (D0, ...) 1D-nD Te... | 8,088 | 28.848708 | 88 | py |
OAProgressionMR | OAProgressionMR-main/oaprmr/preproc/_various.py | import torch
class NumpyToTensor(object):
def __call__(self, *args):
if len(args) > 1:
return [torch.from_numpy(e.copy()) for e in args]
else:
return torch.from_numpy(args[0].copy())
class TensorToNumpy(object):
def __call__(self, *args):
if len(args) > 1:
... | 591 | 21.769231 | 61 | py |
Mead | Mead-master/Audio2Landmark/test.py | from utils import prepare_sub_folder, write_loss, write_log, get_config, Timer, draw_heatmap_from_78_landmark, save_image
from data1 import get_data_loader_list
import argparse
from torch.autograd import Variable
from trainer1 import LipTrainer
import torch.backends.cudnn as cudnn
import torch
try:
from itertools i... | 2,651 | 35.833333 | 152 | py |
Mead | Mead-master/Audio2Landmark/utils.py | from torch.optim import lr_scheduler
import torchvision.utils as vutils
import torch
import os
import numpy as np
import math
import yaml
import torch.nn.init as init
import time
#import librosa
import cv2
# Methods
# get_all_data_loaders : primary data loader interface (load trainA, testA, trainB, testB)
# get_da... | 8,406 | 37.56422 | 141 | py |
Mead | Mead-master/Audio2Landmark/data.py | """
Copyright (C) 2018 NVIDIA Corporation. All rights reserved.
Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
"""
import torch
import torch.utils.data as data
from torch.utils.data import DataLoader
import os.path
import numpy as np
import random
#import libr... | 10,746 | 35.063758 | 154 | py |
Mead | Mead-master/Audio2Landmark/networks.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
import torch.nn.init as init
import torch
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download.pytorch.org/models/resnet34-333f7ec4.pth',
'resnet50': 'https://downlo... | 18,692 | 34.538023 | 149 | py |
Mead | Mead-master/Audio2Landmark/train.py | from utils import prepare_sub_folder, write_loss, write_log, get_config, Timer
from data import get_data_loader_list
import argparse
from torch.autograd import Variable
from trainer import LipTrainer
import torch.backends.cudnn as cudnn
import torch
try:
from itertools import izip as zip
except ImportError: # will ... | 2,326 | 33.220588 | 98 | py |
Mead | Mead-master/Audio2Landmark/trainer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import os.path
from utils import OneHot, weights_init, get_model_list, get_scheduler, Dict_Unite
from networks1 import resnet18_AT, SoundNet, FusionAV, FusionGL, EXCGEN, EXCINT, Audio2Exp, EMCINT
class LipTrainer(nn.Module):
def __init__(self, pa... | 2,590 | 33.546667 | 115 | py |
Mead | Mead-master/Refinement/trainer_demo.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import os.path
import pickle
import torchvision.transforms as transforms
from utils_parallel import OneHot_emc_label, OneHot_int_label, weights_init, get_model_list, get_scheduler, vgg_preprocess, load_gan, draw_heatmap_from_78_landmark
from networks im... | 2,564 | 35.642857 | 163 | py |
Mead | Mead-master/Refinement/data.py | import torch
import torch.utils.data as data
from torch.utils.data import DataLoader
from torch.utils.data.distributed import DistributedSampler
import os.path
import numpy as np
import random
import librosa
import pickle
from PIL import Image
import torchvision.transforms as transforms
def path_extractor(name): #JK_... | 13,838 | 38.881844 | 205 | py |
Mead | Mead-master/Refinement/networks.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
import torch.nn.init as init
import torch
from torch.nn.utils import weight_norm
import torch.nn.functional as F
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download.pyto... | 25,153 | 39.310897 | 149 | py |
Mead | Mead-master/Refinement/demo.py | from utils_parallel import prepare_sub_folder, get_config, save_image, write_image, tensor_to_cv2, dict_unite
from data import get_data_loader_list
import argparse
from trainer_demo import GanimationTrainer
import torch.backends.cudnn as cudnn
import torch
try:
from itertools import izip as zip
except ImportError... | 2,886 | 36.012821 | 136 | py |
Mead | Mead-master/Refinement/train.py | from utils_parallel import prepare_sub_folder, write_loss, write_log, get_config, Timer, write_image
from data import get_data_loader_list
import argparse
from torch.autograd import Variable
from trainer import GanimationTrainer
import torch.backends.cudnn as cudnn
import torch
import os
#os.environ["CUDA_VISIBLE_DEVIC... | 3,253 | 37.282353 | 247 | py |
Mead | Mead-master/Refinement/trainer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import os.path
from utils_parallel import OneHot_emc_label, OneHot_int_label, weights_init, get_model_list, get_scheduler, vgg_preprocess, load_vgg16, load_unetenc, load_unetint, load_gan, mouth_center, mouth_extract, mouth_crop
from networks import Une... | 8,858 | 39.637615 | 213 | py |
Mead | Mead-master/Refinement/utils_parallel.py | import torchfile
from torch.optim import lr_scheduler
from networks import Vgg16, Unet_Enc_384x384, Unet_Int_384x384, Generator
import torchvision.utils as vutils
import torch
import os
import numpy as np
import math
import yaml
import torch.nn.init as init
import time
import librosa
import cv2
from torchvision import ... | 13,565 | 38.208092 | 141 | py |
Mead | Mead-master/Neutral2Emotion/data.py | import torch
import torch.utils.data as data
from torch.utils.data import DataLoader
from torch.utils.data.distributed import DistributedSampler
import os.path
import numpy as np
import random
import librosa
import pickle
from PIL import Image
import torchvision.transforms as transforms
def path_extractor(name): #JK... | 10,791 | 36.472222 | 200 | py |
Mead | Mead-master/Neutral2Emotion/networks.py | import torch.nn as nn
import math
import torch.utils.model_zoo as model_zoo
import torch.nn.init as init
import torch
from torch.nn.utils import weight_norm
import torch.nn.functional as F
model_urls = {
'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde.pth',
'resnet34': 'https://download.pyto... | 24,896 | 39.286408 | 149 | py |
Mead | Mead-master/Neutral2Emotion/train.py | from utils_parallel import prepare_sub_folder, write_loss, write_log, get_config, Timer, write_image
from data import get_data_loader_list
import argparse
from torch.autograd import Variable
from trainer import GanimationTrainer
import torch.backends.cudnn as cudnn
import torch
import os
#os.environ["CUDA_VISIBLE_DEVIC... | 3,359 | 37.62069 | 247 | py |
Mead | Mead-master/Neutral2Emotion/trainer.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import os.path
from utils_parallel import OneHot_emc_label, OneHot_int_label, weights_init, get_model_list, get_scheduler, vgg_preprocess, load_vgg16, load_unetenc, load_unetint
from networks import Unet_V9_384x384, FaceDiscriminator, Generator, Express... | 9,474 | 41.873303 | 162 | py |
Mead | Mead-master/Neutral2Emotion/utils_parallel.py | import torchfile
from torch.optim import lr_scheduler
from networks import Vgg16, Unet_Enc_384x384, Unet_Int_384x384
import torchvision.utils as vutils
import torch
import os
import numpy as np
import math
import yaml
import torch.nn.init as init
import time
import librosa
import cv2
from torchvision import transforms
... | 11,512 | 37.76431 | 141 | py |
RNPRF-RNDFF-RNPMF | RNPRF-RNDFF-RNPMF-master/Houston_code/SSRN_Houston_3_DF_F.py | #Write by Chiru Ge, contact: gechiru@126.com
# stack (HSI+HSI_EPLBP+LiDAR_EPLBP) ++ Resnet
# 3 deep feature fusion
### use CPU only
#import os
#import sys
#os.environ["CUDA_DEVICE_ORDER"]="PCA_BUS_ID"
#os.environ["CUDA_VISIBLE_DEVICES"]="-1"
## use GPU
import os
import tensorflow as tf
os.environ['CUDA_VISIBLE_DEV... | 18,756 | 52.744986 | 260 | py |
RNPRF-RNDFF-RNPMF | RNPRF-RNDFF-RNPMF-master/Houston_code/SSRN_Houston_stack.py | #Write by Chiru Ge, contact: gechiru@126.com
# HSI ++ Resnet
# use CPU only
#import os
#import sys
#os.environ["CUDA_DEVICE_ORDER"]="PCA_BUS_ID"
#os.environ["CUDA_VISIBLE_DEVICES"]="0"
#import tensorflow as tf
#sess = tf.Session(config=tf.ConfigProto(device_count={'gpu':-1}))
#use GPU
import os
import tensorflow... | 11,080 | 39.441606 | 203 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.