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 |
|---|---|---|---|---|---|---|
AutoAE | AutoAE-master/get_record_list.py | import sys
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"
import torch
import torch.nn as nn
from torch.nn import functional as F
from PIL import Image
import numpy as np
import torchvision
import imageio
from torchvision import transforms
import argparse
from attack_ops import apply_attacker
from tqdm import tqd... | 10,906 | 44.827731 | 187 | py |
AutoAE | AutoAE-master/attack_utils.py | import torch
import torch.nn as nn
#from torch.autograd.gradcheck import zero_gradients
import numpy as np
device = torch.device("cuda") if torch.cuda.is_available() else torch.device('cpu')
def zero_gradients(x):
if isinstance(x, torch.Tensor):
if x.grad is not None:
x.grad.detach_()
... | 4,672 | 31.227586 | 152 | py |
AutoAE | AutoAE-master/tv_utils.py | from PIL import Image
import PIL
from PIL import ImageFilter
import numbers
import torchvision.transforms.functional as TF
from torch.utils.data import Dataset
import numpy as np
import os
import torch
import torch.nn as nn
import torchvision.datasets
_pil_interpolation_to_str = {
Image.NEAREST: 'PIL.Image.NEARE... | 4,615 | 30.616438 | 101 | py |
AutoAE | AutoAE-master/fab_projections.py | import math
import torch
from torch.nn import functional as F
def fab_projection_linf(points_to_project, w_hyperplane, b_hyperplane):
device = points_to_project.device
t, w, b = points_to_project, w_hyperplane.clone(), b_hyperplane.clone()
sign = 2 * ((w * t).sum(1) - b >= 0) - 1
w.mul_(sign.unsque... | 5,081 | 29.987805 | 98 | py |
AutoAE | AutoAE-master/cifar_models/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 torch
import torch.nn as nn
import torch.nn.functional as F
class SequentialWithArgs(torch.nn.Sequentia... | 5,685 | 34.31677 | 102 | py |
Riptide | Riptide-master/scripts/autotune_model.py | import os
import numpy as np
import tensorflow as tf
import argparse
import tvm
from tvm import autotvm
from tvm import relay
from tvm.relay import testing
import tvm.relay.testing.tf as tf_testing
from tvm.autotvm.tuner import XGBTuner, GATuner, GridSearchTuner
from tvm.contrib.util import tempdir
import tvm.contrib.... | 5,505 | 34.070064 | 147 | py |
Riptide | Riptide-master/scripts/train_imagenet.py | import os
import multiprocessing
import tensorflow as tf
import tensorflow_datasets as tfds
from functools import partial
from riptide.get_models import get_model
from riptide.utils.thread_helper import setup_gpu_threadpool
from riptide.binary.binary_layers import Config, DQuantize, XQuantize
from riptide.utils.preproc... | 7,430 | 36.720812 | 109 | py |
Riptide | Riptide-master/scripts/autotune_model_rpi.py | import os
import numpy as np
import tensorflow as tf
import argparse
import tvm
from tvm import autotvm
from tvm import relay
from tvm.relay import testing
import tvm.relay.testing.tf as tf_testing
from tvm.autotvm.tuner import XGBTuner, GATuner, GridSearchTuner
from tvm.contrib.util import tempdir
from tvm.contrib im... | 6,799 | 28.694323 | 136 | py |
Riptide | Riptide-master/scripts/measure_rpi.py | import os
import numpy as np
import tensorflow as tf
import argparse
import tvm
from tvm import autotvm
from tvm import relay
from tvm.relay import testing
import tvm.relay.testing.tf as tf_testing
from tvm.autotvm.tuner import XGBTuner, GATuner, GridSearchTuner
from tvm.contrib.util import tempdir
from tvm.contrib im... | 3,782 | 29.756098 | 160 | py |
Riptide | Riptide-master/scripts/anneal/train_imagenet.py | import os
import multiprocessing
import tensorflow as tf
from functools import partial
from riptide.utils.datasets import imagerecord_dataset
from riptide.utils.thread_helper import setup_gpu_threadpool
from riptide.anneal.anneal_config import Config
from riptide.anneal.models import get_model, get_optimizer
from ripti... | 6,920 | 37.45 | 109 | py |
Riptide | Riptide-master/riptide/binary/binary_layers.py | import tensorflow as tf
import tensorflow.keras as keras
from .binary_funcs import *
from functools import partial
from tensorflow.python.keras import backend as K
from tensorflow.python.keras import constraints
from tensorflow.python.keras import initializers
from tensorflow.python.keras import regularizers
from tenso... | 31,802 | 39.461832 | 106 | py |
Riptide | Riptide-master/riptide/binary/binary_funcs.py | import numpy as np
import tensorflow as tf
import tensorflow.keras as keras
from .bit_approximations import load_clusters, load_bits
def log2(x):
return tf.math.log(x) / tf.math.log(2.0)
@tf.custom_gradient
def AP2(x):
#x = tf.clip_by_value(x, 1e-7, 1.0)
# Positive ap2 might be fine
y = 2**(tf.round... | 7,331 | 29.297521 | 79 | py |
Riptide | Riptide-master/riptide/binary/models/q_resnetv1b.py | """ResNetV1bs, implemented in tf Keras."""
# pylint: disable=arguments-differ,unused-argument,missing-docstring,dangerous-default-value
import os
import tensorflow as tf
from .. import binary_layers as nn
#from tensorflow.keras.models import Sequential
from riptide.utils.sequential import forward
class BasicBlockV1b... | 22,333 | 30.679433 | 100 | py |
Riptide | Riptide-master/riptide/binary/models/q_cifar_resnet.py | import os
import tensorflow as tf
from .. import binary_layers as nn
#from tensorflow.keras.models import Sequential
from riptide.utils.sequential import forward_layer_list
def _conv3x3(channels, stride, normal=False):
if normal:
return nn.Conv2DBatchNorm(
channels,
kernel_size=3,
... | 12,031 | 30.170984 | 94 | py |
Riptide | Riptide-master/riptide/models/squeezenet_batchnorm.py | import tensorflow as tf
from riptide.binary import binary_layers as nn
bnmomemtum=0.9
class SqueezeNet(tf.keras.Model):
def __init__(self, classes=1000):
super(SqueezeNet, self).__init__()
self.classes = classes
self.c0 = nn.NormalConv2D(kernel_size=7, strides=4, filters=96, padding='same... | 8,191 | 43.521739 | 114 | py |
Riptide | Riptide-master/riptide/models/vggnet_normal.py | import os
import tensorflow as tf
import tensorflow.keras.layers as nn
class vggnet(tf.keras.Model):
def __init__(self, classes=1000):
super(vggnet, self).__init__()
self.conv1 = nn.Conv2D(
filters=96,
kernel_size=7,
strides=2,
padding='same',
... | 5,389 | 26.5 | 71 | py |
Riptide | Riptide-master/riptide/models/cifarnet.py | import os
import tensorflow as tf
from riptide.binary import binary_layers as nn
#from tensorflow.keras.models import Sequential
from riptide.utils.sequential import forward_layer_list
class CifarNet(tf.keras.Model):
def __init__(self):
super(CifarNet, self).__init__()
self.conv1 = nn.NormalConv2... | 2,800 | 26.732673 | 57 | py |
Riptide | Riptide-master/riptide/models/resnet18.py | import os
import tensorflow as tf
from riptide.binary import binary_layers as nn
class resnet18(tf.keras.Model):
def __init__(self, classes=1000):
super(resnet18, self).__init__()
# Input Layer
self.conv1 = nn.NormalConv2D(
filters=64,
kernel_size=7,
st... | 10,958 | 30.222222 | 79 | py |
Riptide | Riptide-master/riptide/models/squeezenet.py | import tensorflow as tf
from riptide.binary import binary_layers as nn
bnmomemtum=0.9
class SqueezeNet(tf.keras.Model):
def __init__(self, classes=1000):
super(SqueezeNet, self).__init__()
self.classes = classes
self.c0 = nn.NormalConv2D(kernel_size=7, strides=4, filters=96, padding='same... | 8,503 | 45.217391 | 114 | py |
Riptide | Riptide-master/riptide/models/vggnet.py | import os
import tensorflow as tf
from riptide.binary import binary_layers as nn
class vggnet(tf.keras.Model):
def __init__(self, classes=1000):
super(vggnet, self).__init__()
self.conv1 = nn.NormalConv2D(
filters=96,
kernel_size=7,
strides=2,
paddi... | 5,825 | 27.419512 | 73 | py |
Riptide | Riptide-master/riptide/models/alexnet_normal.py | import os
import tensorflow as tf
from riptide.binary import binary_layers as nn
class alexnet(tf.keras.Model):
def __init__(self, classes=1000):
super(alexnet, self).__init__()
self.conv1 = nn.NormalConv2D(
filters=64,
kernel_size=11,
strides=4,
pad... | 2,810 | 28.589474 | 76 | py |
Riptide | Riptide-master/riptide/models/cifar_resnet.py | import os
import tensorflow as tf
import tensorflow.keras.layers as nn
#from tensorflow.keras.models import Sequential
from riptide.utils.sequential import forward_layer_list
def _conv3x3(channels, stride):
return nn.Conv2D(
channels,
kernel_size=3,
strides=stride,
padding="same",
... | 11,875 | 30.839142 | 94 | py |
Riptide | Riptide-master/riptide/models/vgg11.py | import os
import tensorflow as tf
from riptide.binary import binary_layers as nn
#from tensorflow.keras.models import Sequential
from riptide.utils.sequential import forward_layer_list
class vgg11(tf.keras.Model):
def __init__(self, classes=1000):
super(vgg11, self).__init__()
# Set up configurab... | 5,477 | 30.66474 | 78 | py |
Riptide | Riptide-master/riptide/models/resnetv1b.py | """ResNetV1bs, implemented in tf Keras."""
# pylint: disable=arguments-differ,unused-argument,missing-docstring,dangerous-default-value
import os
import tensorflow as tf
import tensorflow.keras.layers as nn
#from tensorflow.keras.models import Sequential
from riptide.utils.sequential import forward
class BasicBlockV... | 23,710 | 31.216033 | 100 | py |
Riptide | Riptide-master/riptide/models/squeezenet_normal.py | import tensorflow as tf
import tensorflow.keras.layers as nn
bnmomemtum=0.9
class SqueezeNet(tf.keras.Model):
def __init__(self, classes=1000):
super(SqueezeNet, self).__init__()
self.classes = classes
self.c0 = tf.keras.layers.Conv2D(kernel_size=7, strides=2, filters=96, padding='same', ... | 8,215 | 44.644444 | 128 | py |
Riptide | Riptide-master/riptide/models/darknet.py | import os
import tensorflow as tf
from riptide.binary import binary_layers as nn
#from tensorflow.keras.models import Sequential
from riptide.utils.sequential import forward_layer_list
class DarkNet(tf.keras.Model):
def __init__(self):
super(DarkNet, self).__init__()
self.conv1 = nn.NormalConv2D(... | 3,266 | 28.432432 | 64 | py |
Riptide | Riptide-master/riptide/models/alexnet.py | import os
import tensorflow as tf
from riptide.binary import binary_layers as nn
class alexnet(tf.keras.Model):
def __init__(self, classes=1000):
super(alexnet, self).__init__()
self.conv1 = nn.NormalConv2D(
filters=64,
kernel_size=11,
strides=4,
pad... | 2,970 | 29.010101 | 76 | py |
Riptide | Riptide-master/riptide/utils/datasets_test.py | import tensorflow as tf
import numpy as np
from functools import partial
from datasets import imagerecord_dataset, imagefolder_dataset
from riptide.utils.preprocessing.inception_preprocessing import preprocess_image
class DatasetTest(tf.test.TestCase):
def test_get_dataset(self):
#preprocess = tf.keras.ap... | 1,146 | 36 | 80 | py |
Riptide | Riptide-master/riptide/utils/sequential.py | import tensorflow as tf
def _forward_core(x, layers):
for l in layers:
if isinstance(l, list):
x = forward_layer_list(x, l)
else:
x = l(x)
return x
def forward_layer_list(x, layers):
if isinstance(layers[0], str):
name = layers.pop(0)
with tf.name_... | 1,132 | 22.604167 | 47 | py |
Riptide | Riptide-master/riptide/anneal/anneal_funcs.py | import tensorflow as tf
from riptide.anneal.anneal_config import Config
@tf.custom_gradient
def AlphaClip(x, alpha):
output = tf.clip_by_value(x, 0, alpha)
def grad_fn(dy):
x_grad_mask = tf.cast(tf.logical_and(x >= 0, x <= alpha), tf.float32)
alpha_grad_mask = tf.cast(x >= alpha, tf.float32)
... | 6,278 | 32.57754 | 92 | py |
Riptide | Riptide-master/riptide/anneal/models/resnet.py | import six
import tensorflow as tf
import tensorflow.keras as keras
from tensorflow.keras.layers import Input, Activation, Reshape, Dense, Conv2D, MaxPooling2D, GlobalMaxPooling2D, GlobalAveragePooling2D, Dropout, BatchNormalization, Add
from tensorflow.keras.regularizers import l2
from riptide.anneal.anneal_funcs impo... | 12,689 | 36.214076 | 169 | py |
Riptide | Riptide-master/riptide/anneal/models/resnet18.py | import tensorflow as tf
import tensorflow.keras.layers as nn
from riptide.anneal.anneal_funcs import *
from tensorflow.keras.regularizers import l2
from tensorflow.keras.models import Sequential
from riptide.binary.binary_layers import Scalu
class resnet18(tf.keras.Model):
def __init__(self, classes=1000):
... | 10,989 | 28.543011 | 81 | py |
Riptide | Riptide-master/riptide/anneal/models/squeezenet.py | import tensorflow as tf
import tensorflow.keras.layers as nn
from riptide.anneal.anneal_funcs import *
from tensorflow.keras.regularizers import l2
class SqueezeNet(tf.keras.models.Model):
def __init__(self, classes=1000):
super(SqueezeNet, self).__init__()
self.classes = classes
l2_reg = 5... | 8,902 | 33.507752 | 131 | py |
Riptide | Riptide-master/riptide/anneal/models/alexnet.py | import tensorflow as tf
import tensorflow.keras.layers as nn
from riptide.anneal.anneal_funcs import *
from tensorflow.keras.regularizers import l2
from tensorflow.keras.models import Sequential
class alexnet(tf.keras.models.Model):
def __init__(self, *args, **kwargs):
super(alexnet, self).__init__(*args,... | 2,787 | 26.60396 | 71 | py |
Riptide | Riptide-master/notebooks/squeezenet_test.py | # To add a new cell, type '#%%'
# To add a new markdown cell, type '#%% [markdown]'
#%% Change working directory from the workspace root to the ipynb file location. Turn this addition off with the DataScience.changeDirOnImportExport setting
# ms-python.python added
import os
try:
os.chdir(os.path.join(os.getcwd(), 'no... | 1,682 | 23.391304 | 169 | py |
TextSiM | TextSiM-main/Text_Simplification_Systems/access-main/access/preprocess.py | # Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
from functools import wraps
import multiprocessing
import random
import re
from joblib import Parallel, delayed
import t... | 5,957 | 34.676647 | 116 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/setup.py | """
Simple check list from AllenNLP repo: https://github.com/allenai/allennlp/blob/master/setup.py
To create the package for pypi.
1. Change the version in __init__.py, setup.py as well as docs/source/conf.py.
2. Unpin specific versions from setup.py (like isort).
2. Commit these changes with the message: "Release:... | 6,260 | 39.921569 | 217 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/hubconf.py | import os
import sys
SRC_DIR = os.path.join(os.path.dirname(__file__), "src")
sys.path.append(SRC_DIR)
from transformers import (
AutoConfig,
AutoModel,
AutoModelForQuestionAnswering,
AutoModelForSequenceClassification,
AutoModelWithLMHead,
AutoTokenizer,
add_start_docstrings,
)
depende... | 6,612 | 50.664063 | 189 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/xla_spawn.py | """
A simple launcher script for TPU training
Inspired by https://github.com/pytorch/pytorch/blob/master/torch/distributed/launch.py
::
>>> python xla_spawn.py --num_cores=NUM_CORES_YOU_HAVE
YOUR_TRAINING_SCRIPT.py (--arg1 --arg2 --arg3 and all other
arguments of your training script... | 1,913 | 25.219178 | 108 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/lightning_base.py | import argparse
import logging
import os
import random
from pathlib import Path
from typing import Any, Dict
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.utilities import rank_zero_info, rank_zero_only
from transformers import (
AdamW,
AutoConfig,
AutoModel,
Au... | 12,332 | 35.92515 | 118 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/longform-qa/eli5_app.py | import faiss
import nlp
import numpy as np
import torch
from elasticsearch import Elasticsearch
import streamlit as st
import transformers
from eli5_utils import (
embed_questions_for_retrieval,
make_qa_s2s_model,
qa_s2s_generate,
query_es_index,
query_qa_dense_index,
)
from transformers import Aut... | 13,298 | 38.936937 | 159 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/longform-qa/eli5_utils.py | import functools
import math
import os # noqa: F401
from random import choice, randint
from time import time
import faiss # noqa: F401
import nlp # noqa: F401
import numpy as np
import pandas as pd
import torch
import torch.utils.checkpoint as checkpoint
from elasticsearch import Elasticsearch # noqa: F401
from el... | 27,779 | 41.477064 | 119 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/question-answering/run_squad.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 34,081 | 40.462287 | 126 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/token-classification/run_pl_ner.py | import argparse
import glob
import logging
import os
import numpy as np
import torch
from seqeval.metrics import f1_score, precision_score, recall_score
from torch.nn import CrossEntropyLoss
from torch.utils.data import DataLoader, TensorDataset
from lightning_base import BaseTransformer, add_generic_args, generic_tr... | 8,769 | 42.20197 | 118 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/token-classification/run_ner.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 11,184 | 35.672131 | 133 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/token-classification/utils_ner.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 15,996 | 39.092732 | 160 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/bertology/run_bertology.py | #!/usr/bin/env python3
# Copyright 2018 CMU and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | 18,191 | 40.158371 | 118 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/text-classification/run_pl_glue.py | import argparse
import glob
import logging
import os
import time
import numpy as np
import torch
from torch.utils.data import DataLoader, TensorDataset
from lightning_base import BaseTransformer, add_generic_args, generic_train
from transformers import glue_compute_metrics as compute_metrics
from transformers import ... | 7,757 | 39.831579 | 118 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/text-classification/run_xnli.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 27,174 | 42.972492 | 150 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/adversarial/run_hans.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 7,810 | 32.668103 | 133 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/adversarial/utils_hans.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 11,529 | 33.728916 | 118 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/text-generation/run_generation.py | #!/usr/bin/env python3
# coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in c... | 10,422 | 36.901818 | 119 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/text-generation/pplm/run_pplm.py | #! /usr/bin/env python3
# coding=utf-8
# Copyright (c) 2019 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless ... | 28,106 | 34.533502 | 182 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/text-generation/pplm/run_pplm_discrim_train.py | #! /usr/bin/env python3
# coding=utf-8
# Copyright (c) 2019 Uber Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless ... | 18,693 | 35.088803 | 117 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/text-generation/pplm/pplm_classification_head.py | import torch
class ClassificationHead(torch.nn.Module):
"""Classification Head for transformer encoders"""
def __init__(self, class_size, embed_size):
super().__init__()
self.class_size = class_size
self.embed_size = embed_size
# self.mlp1 = torch.nn.Linear(embed_size, embed_... | 655 | 31.8 | 63 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/multiple-choice/utils_multiple_choice.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 20,484 | 35.580357 | 116 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/movement-pruning/counts_parameters.py | # Copyright 2020-present, the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 3,394 | 35.505376 | 124 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/movement-pruning/masked_run_glue.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 40,389 | 42.854506 | 156 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/movement-pruning/bertarize.py | # Copyright 2020-present, the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law o... | 5,086 | 37.24812 | 155 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/movement-pruning/masked_run_squad.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 47,622 | 41.444742 | 156 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/movement-pruning/emmental/modeling_bert_masked.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 46,960 | 45.130648 | 154 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/movement-pruning/emmental/modules/masked_nn.py | # coding=utf-8
# Copyright 2020-present, the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by a... | 4,532 | 40.972222 | 105 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/movement-pruning/emmental/modules/binarizer.py | # coding=utf-8
# Copyright 2020-present, AllenAI Authors, University of Illinois Urbana-Champaign,
# Intel Nervana Systems and the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the ... | 5,823 | 39.165517 | 175 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/test_seq2seq_examples.py | import argparse
import logging
import os
import sys
import tempfile
import unittest
from pathlib import Path
from unittest.mock import patch
import pytest
import torch
from torch.utils.data import DataLoader
from transformers import AutoTokenizer
from transformers.testing_utils import require_multigpu
from .distilla... | 9,237 | 35.513834 | 141 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/callbacks.py | import logging
import os
from pathlib import Path
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.utilities import rank_zero_only
def count_trainable_parameters(model):
model_parameters = filter(lambda p: p.requires_gra... | 3,529 | 36.956989 | 126 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/run_eval.py | import argparse
import json
from pathlib import Path
import torch
from tqdm import tqdm
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
try:
from .utils import calculate_rouge, use_task_specific_params, calculate_bleu_score, trim_batch
except ImportError:
from utils import calculate_rouge, use... | 3,919 | 37.058252 | 119 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/utils.py | import itertools
import json
import os
import pickle
from pathlib import Path
from typing import Callable, Dict, Iterable, List
import git
import numpy as np
import torch
from rouge_score import rouge_scorer, scoring
from sacrebleu import corpus_bleu
from torch import nn
from torch.utils.data import Dataset, Sampler
f... | 8,503 | 31.334601 | 119 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/finetune.py | import argparse
import glob
import logging
import os
import time
import warnings
from collections import defaultdict
from pathlib import Path
from typing import Dict, List, Tuple
import numpy as np
import pytorch_lightning as pl
import torch
from torch.utils.data import DataLoader
from lightning_base import BaseTrans... | 13,985 | 39.53913 | 131 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/initialization_utils.py | from typing import List
from torch import nn
def init_student(student, teacher):
teacher_state_dict = teacher.state_dict()
info = student.load_state_dict(teacher_state_dict, strict=False)
assert info.missing_keys == [], info.missing_keys
return student, info
def copy_decoder_layers(teacher, student... | 816 | 37.904762 | 108 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/distillation.py | import argparse
import gc
import os
from pathlib import Path
from typing import List
import pytorch_lightning as pl
import torch
from torch import nn
from torch.nn import functional as F
from lightning_base import generic_train
from transformers import AdamW, BartConfig, BartForConditionalGeneration, T5Config, T5ForC... | 19,485 | 42.015453 | 118 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/bertabs/modeling_bertabs.py | # MIT License
# Copyright (c) 2019 Yang Liu and the HuggingFace team
# 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, c... | 38,009 | 36.010711 | 118 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/bertabs/convert_bertabs_original_pytorch_checkpoint.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 6,452 | 35.457627 | 118 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/bertabs/utils_summarization.py | import os
from collections import deque
import torch
from torch.utils.data import Dataset
# ------------
# Data loading
# ------------
class CNNDMDataset(Dataset):
""" Abstracts the dataset used to train seq2seq models.
The class will process the documents that are located in the specified
folder. The... | 5,763 | 33.309524 | 106 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/bertabs/test_utils_summarization.py | # coding=utf-8
# Copyright 2019 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | 4,444 | 43.009901 | 99 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/seq2seq/bertabs/run_summarization.py | #! /usr/bin/python3
import argparse
import logging
import os
import sys
from collections import namedtuple
import torch
from torch.utils.data import DataLoader, SequentialSampler
from tqdm import tqdm
from modeling_bertabs import BertAbs, build_predictor
from transformers import BertTokenizer
from .utils_summarizati... | 10,015 | 29.818462 | 137 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/contrib/run_transfo_xl.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | 6,206 | 41.806897 | 116 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/contrib/run_swag.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 29,878 | 41.32153 | 150 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/contrib/run_openai_gpt.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | 14,226 | 43.880126 | 132 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/contrib/run_camembert.py | import torch
from transformers.modeling_camembert import CamembertForMaskedLM
from transformers.tokenization_camembert import CamembertTokenizer
def fill_mask(masked_input, model, tokenizer, topk=5):
# Adapted from https://github.com/pytorch/fairseq/blob/master/fairseq/models/roberta/hub_interface.py
assert ... | 1,901 | 42.227273 | 114 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/contrib/mm-imdb/run_mmimdb.py | # coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright (c) HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses... | 23,652 | 40.716049 | 123 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/contrib/mm-imdb/utils_mmimdb.py | # coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright (c) HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses... | 4,541 | 30.541667 | 119 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/distillation/grouped_batch_sampler.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team and Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... | 4,360 | 39.009174 | 125 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/distillation/utils.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team and Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... | 4,268 | 31.097744 | 90 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/distillation/lm_seqs_dataset.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team and Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... | 6,133 | 35.730539 | 111 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/distillation/run_squad_w_distillation.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 35,797 | 40.529002 | 162 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/distillation/train.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by a... | 12,975 | 39.173375 | 122 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/distillation/distiller.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team and Facebook, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... | 26,135 | 42.271523 | 143 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/distillation/scripts/extract.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by a... | 4,448 | 42.194175 | 128 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/distillation/scripts/extract_distilbert.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by a... | 4,314 | 45.397849 | 128 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/bert-loses-patience/run_glue_with_pabee.py | # coding=utf-8
# Copyright 2020 The Google AI Language Team Authors, The HuggingFace Inc. team and Microsoft Corporation.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.... | 29,833 | 41.74212 | 150 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/bert-loses-patience/pabee/modeling_pabee_bert.py | # coding=utf-8
# Copyright 2020 The Google AI Language Team Authors, The HuggingFace Inc. team and Microsoft Corporation.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.... | 15,265 | 43.507289 | 168 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/examples/bert-loses-patience/pabee/modeling_pabee_albert.py | # coding=utf-8
# Copyright 2020 Google AI, Google Brain, the HuggingFace Inc. team and Microsoft Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/lic... | 13,730 | 43.151125 | 168 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/src/transformers/modeling_encoder_decoder.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 17,175 | 53.182965 | 396 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/src/transformers/modeling_longformer.py | # coding=utf-8
# Copyright 2020 The Allen Institute for AI team and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2... | 76,779 | 47.935628 | 222 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/src/transformers/modeling_tf_albert.py | # coding=utf-8
# Copyright 2018 The OpenAI Team Authors and HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License... | 59,568 | 46.239492 | 221 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/src/transformers/optimization.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICEN... | 11,584 | 42.227612 | 119 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/src/transformers/modeling_mmbt.py | # coding=utf-8
# Copyright (c) Facebook, Inc. and its affiliates.
# Copyright (c) HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses... | 18,628 | 49.077957 | 151 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/src/transformers/modeling_marian.py | # coding=utf-8
# Copyright 2020 Marian Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... | 2,289 | 41.407407 | 119 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/src/transformers/configuration_utils.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 19,039 | 45.552567 | 193 | py |
TextSiM | TextSiM-main/MNLI_evaluation_scripts/transformers-3.0.2/src/transformers/convert_longformer_original_pytorch_lightning_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 3,037 | 33.91954 | 117 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.