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 |
|---|---|---|---|---|---|---|
CARLCS-CNN | CARLCS-CNN-master/CARLCS-CNN/models.py | from __future__ import print_function
from __future__ import absolute_import
import os
import tensorflow as tf
import keras.backend.tensorflow_backend as KTF
from keras.engine import Input
from keras.layers import Concatenate, Dot, Embedding, Dropout, Lambda, Activation, Dense,Reshape,Conv1D,MaxPooling1D,Flatten,Global... | 15,016 | 54.007326 | 181 | py |
CARLCS-CNN | CARLCS-CNN-master/CARLCS-CNN/attention_layer.py | from keras import backend as K
from keras.engine.topology import Layer
class AttentionLayer(Layer):
def __init__(self, **kwargs):
super(AttentionLayer, self).__init__(**kwargs)
def build(self, input_shape):
if not isinstance(input_shape, list) or len(input_shape) != 2:
raise Value... | 1,192 | 36.28125 | 92 | py |
efficient_densenet_pytorch | efficient_densenet_pytorch-master/demo.py | import fire
import os
import time
import torch
from torchvision import datasets, transforms
from models import DenseNet
class AverageMeter(object):
"""
Computes and stores the average and current value
Copied from: https://github.com/pytorch/examples/blob/master/imagenet/main.py
"""
def __init__(s... | 10,870 | 34.295455 | 117 | py |
efficient_densenet_pytorch | efficient_densenet_pytorch-master/models/densenet.py | # This implementation is based on the DenseNet-BC implementation in torchvision
# https://github.com/pytorch/vision/blob/master/torchvision/models/densenet.py
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as cp
from collections import OrderedDict
def _bn... | 7,076 | 44.076433 | 107 | py |
face-recognition | face-recognition-master/utils.py | # -----------------------------------------------------------------------------------------
# Code taken from https://github.com/iwantooxxoox/Keras-OpenFace (with minor modifications)
# -----------------------------------------------------------------------------------------
import tensorflow as tf
import numpy as np
... | 6,537 | 40.119497 | 101 | py |
face-recognition | face-recognition-master/model.py | # -----------------------------------------------------------------------------------------
# Code taken from https://github.com/iwantooxxoox/Keras-OpenFace (with minor modifications)
# -----------------------------------------------------------------------------------------
from keras.layers import Conv2D, ZeroPaddin... | 12,191 | 54.167421 | 115 | py |
PreservationSimulation | PreservationSimulation-master/shelf/bottle.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Bottle is a fast and simple micro-framework for small web applications. It
offers request dispatching (Routes) with url parameter support, templates,
a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and
template engines - all in a single file an... | 150,580 | 38.920732 | 103 | py |
Toxicity-Detection-in-Spoken-Utterances | Toxicity-Detection-in-Spoken-Utterances-main/two_step_approach/transcribe.py | #Importing libraries
import librosa
import os
import pandas as pd
import numpy as np
import torch
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
import warnings
warnings.filterwarnings("ignore")
#Setting source path
source='../DeToxy/Input/test_splits_audio/'
destination='../DeToxy/Transcribed_Transcripts/... | 1,643 | 25.095238 | 80 | py |
Toxicity-Detection-in-Spoken-Utterances | Toxicity-Detection-in-Spoken-Utterances-main/two_step_approach/DB/main.py | #Importing Libraries and modules
import torch
import transformers
from torch.utils.data import DataLoader as DL
from transformers import AutoTokenizer,AdamW,get_linear_schedule_with_warmup,AutoModelForSequenceClassification
import argparse
from engine import Engine
import pandas as pd
from sklearn.model_selection impo... | 4,714 | 41.098214 | 305 | py |
Toxicity-Detection-in-Spoken-Utterances | Toxicity-Detection-in-Spoken-Utterances-main/two_step_approach/DB/engine.py | #Importing Libraries
import time
import torch
from tqdm import tqdm
import torchnet as tnt
import torchmetrics
import sys
class Engine(object):
"""
A basic training engine to handle training , validation and testing
"""
def __init__(self,state = {}):
self.state = state
self.d... | 11,267 | 36.065789 | 157 | py |
Toxicity-Detection-in-Spoken-Utterances | Toxicity-Detection-in-Spoken-Utterances-main/two_step_approach/DB/model.py | from torch import nn
from transformers import AutoConfig, AutoModel
import sys
class Transformer(nn.Module):
def __init__(self, model, num_classes=2):
super().__init__()
self.name = model
#config = AutoConfig.from_pretrained(self.name)
#config.output_hidden_states = True
#... | 1,837 | 38.106383 | 210 | py |
Toxicity-Detection-in-Spoken-Utterances | Toxicity-Detection-in-Spoken-Utterances-main/two_step_approach/DB/create_torch_dataset.py | from torch.utils.data import Dataset
class CreateTweetsDataset(Dataset):
def __init__(self,data) -> None:
super().__init__()
self.data = [[data[key][i] for key in data] for i in range(len(data['label']))]
def __getitem__(self, index):
return self.data[index]
def __len__(self):
... | 353 | 31.181818 | 87 | py |
Toxicity-Detection-in-Spoken-Utterances | Toxicity-Detection-in-Spoken-Utterances-main/e2e/utils.py | import textgrid
import torch
from torch import nn
import re
from transformers import (Wav2Vec2CTCTokenizer,
Wav2Vec2FeatureExtractor,
Wav2Vec2Processor)
def parse_Interval(IntervalObject):
start_time = ""
end_time = ""
P_name = ""
ind = 0
str_interval = str(IntervalObject)
for ele in ... | 5,291 | 27.918033 | 79 | py |
Toxicity-Detection-in-Spoken-Utterances | Toxicity-Detection-in-Spoken-Utterances-main/e2e/model.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.modules.activation import MultiheadAttention
import numpy as np
class LSTMAttention(nn.Module):
def __init__(self, config, feature_type='acoustic'):
super().__init__()
assert feature_type in ['acoustic','semantic']
... | 51,150 | 46.626629 | 141 | py |
Toxicity-Detection-in-Spoken-Utterances | Toxicity-Detection-in-Spoken-Utterances-main/e2e/mmi_module_only_audio.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... | 85,919 | 48.636049 | 171 | py |
Toxicity-Detection-in-Spoken-Utterances | Toxicity-Detection-in-Spoken-Utterances-main/e2e/run_iemocap-ours-meld.py | #Importing Libraries
import re
import os
import time
import sys
import json
import yaml
import pickle
import argparse
import numpy as np
from tqdm import tqdm
import librosa
import pandas as pd
from functools import reduce
from sklearn.metrics import f1_score
import torch
import torchaudio
import torch.nn as nn
import... | 12,947 | 38.47561 | 149 | py |
AdaT | AdaT-main/approach/model_deployment/rendering_classifier.py | from __future__ import print_function, division
from torchvision import transforms
import time
import torch
from PIL import Image
from model.BinaryUI import BinaryUI
CLASS_NAMES = ['fullyrendered', 'partiallyrendered'] # make sure the order of class names
data_transforms = transforms.Compose([
transforms.... | 2,435 | 34.823529 | 123 | py |
AdaT | AdaT-main/approach/model_deployment/start.py | import random
import numpy as np
import time
import argparse
import cv2
from PIL import Image
import os
from apk import APK
from device import Device
from adapter import ADB
from rendering_classifier import Classifer
from minicap import Minicap
def get_args(description='Experiment for Performance of Throttledroid'):... | 3,786 | 34.064815 | 132 | py |
AdaT | AdaT-main/approach/model_deployment/model/BinaryUI.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import torch
from torch import nn
import torch.nn.functional as F
from torch.nn import CrossEntropyLoss, MSELoss
from .customvision import custom
from torchvision import models
class BinaryUI():
""" An ... | 2,138 | 38.611111 | 93 | py |
AdaT | AdaT-main/approach/model_deployment/model/customvision/custom.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class CNN(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(3, 64, (7,7))
self.pool = nn.MaxPool2d(kernel_size=3)
self.conv2 = nn.Conv2d(64, 512, (3,3))
self.avgpool = nn.AdaptiveAvgPo... | 728 | 23.3 | 51 | py |
AdaT | AdaT-main/approach/GUI_classification/inference.py |
from __future__ import print_function, division
import _init_paths
import random
import argparse
import torch
import numpy as np
from torchvision import transforms
import time
import os
from PIL import Image
import glob
from modules.BinaryUI import BinaryUI
CLASS_NAMES = ['stable', 'unstable'] # make sure the order... | 3,773 | 28.716535 | 109 | py |
AdaT | AdaT-main/approach/GUI_classification/util.py | import os
import torch
import torch.nn as nn
import threading
from torch._utils import ExceptionWrapper
import logging
def get_logger(filename=None):
logger = logging.getLogger('logger')
logger.setLevel(logging.DEBUG)
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',
... | 769 | 34 | 89 | py |
AdaT | AdaT-main/approach/GUI_classification/train.py |
from __future__ import print_function, division
import _init_paths
import random
import argparse
import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim import lr_scheduler
import numpy as np
import torchvision
from torchvision import datasets, transforms
import matplotlib.pyplot as plt
import... | 10,732 | 36.527972 | 129 | py |
AdaT | AdaT-main/approach/GUI_classification/modules/BinaryUI.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import torch
from torch import nn
import torch.nn.functional as F
from torch.nn import CrossEntropyLoss, MSELoss
from customvision.models import resnet, custom
from torchvision import models
class BinaryUI():... | 2,150 | 39.584906 | 93 | py |
AdaT | AdaT-main/approach/GUI_classification/customvision/_internally_replaced_utils.py | import importlib.machinery
import os
from torch.hub import _get_torch_home
_HOME = os.path.join(_get_torch_home(), "datasets", "vision")
_USE_SHARDED_DATASETS = False
def _download_file_from_remote_location(fpath: str, url: str) -> None:
pass
def _is_remote_location_available() -> bool:
return False
tr... | 1,742 | 29.051724 | 102 | py |
AdaT | AdaT-main/approach/GUI_classification/customvision/utils.py | import math
import pathlib
import warnings
from types import FunctionType
from typing import Any, Union, Optional, List, Tuple, BinaryIO
import numpy as np
import torch
from PIL import Image, ImageDraw, ImageFont, ImageColor
__all__ = ["make_grid", "save_image", "draw_bounding_boxes", "draw_segmentation_masks", "draw... | 16,013 | 39.439394 | 119 | py |
AdaT | AdaT-main/approach/GUI_classification/customvision/datasets.py | import torch
from torchvision import datasets, transforms
class ImageFolderWithPaths(datasets.ImageFolder):
"""Custom dataset that includes image file paths. Extends
torchvision.datasets.ImageFolder
"""
# override the __getitem__ method. this is the method that dataloader calls
def __getitem__(sel... | 1,087 | 34.096774 | 88 | py |
AdaT | AdaT-main/approach/GUI_classification/customvision/models/custom.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class CNN(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(3, 64, (7,7))
self.pool = nn.MaxPool2d(kernel_size=3)
self.conv2 = nn.Conv2d(64, 512, (3,3))
self.avgpool = nn.AdaptiveAvgPo... | 728 | 23.3 | 51 | py |
AdaT | AdaT-main/approach/GUI_classification/customvision/models/resnet.py | from typing import Type, Any, Callable, Union, List, Optional
import torch
import torch.nn as nn
from torch import Tensor
from .._internally_replaced_utils import load_state_dict_from_url
from ..utils import _log_api_usage_once
__all__ = [
"ResNet",
"resnet18",
"resnet34",
"resnet50",
"resnet101... | 15,380 | 36.242131 | 118 | py |
cross_domain_coherence | cross_domain_coherence-master/run_bigram_coherence.py | from models.coherence_models import BigramCoherence
from preprocess import get_infersent, get_average_glove, save_eval_perm, get_lm_hidden
from preprocess import get_s2s_hidden
from utils.data_utils import DataSet
from utils.lm_utils import Corpus, SentCorpus
from utils.logging_utils import _set_basic_logging
import lo... | 4,520 | 38.657895 | 98 | py |
cross_domain_coherence | cross_domain_coherence-master/run_lm_coherence.py | from models.language_models import LanguageModel, LMCoherence
from utils.lm_utils import Corpus
from utils.data_utils import DataSet
from utils.logging_utils import _set_basic_logging
import logging
import config
from torch.utils.data import DataLoader
import os
import argparse
import pickle
def run_lm_coherence(args... | 2,445 | 33.450704 | 94 | py |
cross_domain_coherence | cross_domain_coherence-master/preprocess.py | import os
import logging
import config
from utils.logging_utils import _set_basic_logging
from utils.data_utils import DataSet
from models.infersent_models import InferSent
from models.language_models import LanguageModel
import torch
import numpy as np
import random
import copy
import itertools
import pickle
from tqdm... | 13,832 | 35.595238 | 92 | py |
cross_domain_coherence | cross_domain_coherence-master/models/gan_models.py | import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
def _sequence_mask(sequence_length, max_len=None):
if max_len is None:
max_len = sequence_len... | 6,292 | 38.086957 | 92 | py |
cross_domain_coherence | cross_domain_coherence-master/models/infersent_models.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
"""
This file contains the definition of encoders used in https://arxiv.org/pdf/1705.02364.pdf
"""
import numpy as np
import t... | 33,127 | 36.688282 | 116 | py |
cross_domain_coherence | cross_domain_coherence-master/models/coherence_models.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.autograd import Variable
from .gan_models import MLP_Discriminator
import numpy as np
import pickle
from datetime import datetime
from utils.np_utils import generate_random_pmatrices
from tqdm import tqdm
import ut... | 12,629 | 38.46875 | 82 | py |
cross_domain_coherence | cross_domain_coherence-master/models/language_models.py | import torch
import torch.nn as nn
import torch.optim as optim
from torch.autograd import Variable
from .gan_models import RNN_LM
import numpy as np
import pickle
import time
from tqdm import tqdm
def repackage_hidden(h):
if isinstance(h, tuple):
return tuple(repackage_hidden(v) for v in h)
else:
... | 8,870 | 35.506173 | 95 | py |
cross_domain_coherence | cross_domain_coherence-master/utils/lm_utils.py | import torch
from collections import Counter
import config
import numpy as np
class Vocabulary(object):
OOV = 0
EOS = 1
def __init__(self):
self.word2idx = {"<oov>": 0, "<eos>": 1}
self.idx2word = ["<oov>", "<eos>"]
self.size = 2
def add_word(self, word):
if word not i... | 7,158 | 33.921951 | 93 | py |
cross_domain_coherence | cross_domain_coherence-master/utils/data_utils.py | import pandas as pd
import numpy as np
from torch.utils.data import Dataset
import os
class WSJ_Bigram_Dataset(Dataset):
def __init__(self, scr_path, portion=1.0, mode='train'):
self.data_path = scr_path
self.train_list = ['00', '01', '02', '03', '04', '05', '06',
'07', '... | 10,632 | 36.440141 | 81 | py |
FloorNet | FloorNet-master/RecordWriterTango.py | import sys
import numpy as np
import cv2
import random
import math
import os
import time
import zlib
import socket
import threading
import Queue
import sys
import cPickle as pickle
import PIL
import json
import glob
import torchfile
import math
import os.path
import zipfile
import lupa
#from drnseg import DRNSeg
from u... | 25,086 | 41.59253 | 229 | py |
pfsspy | pfsspy-main/examples/using_pfsspy/plot_hmi.py | """
HMI PFSS solutions
------------------
Calculating a PFSS solution from a HMI synoptic map.
This example shows how to calcualte a PFSS solution from a HMI synoptic map.
There are a couple of important things that this example shows:
- HMI maps have non-standard metadata, so this needs to be fixed
- HMI synoptic ma... | 2,709 | 32.875 | 79 | py |
pfsspy | pfsspy-main/examples/finding_data/plot_hmi.py | """
HMI data
--------
How to search for HMI data.
This example shows how to search for, download, and load HMI data, using the
`sunpy.net.Fido` interface. HMI data is available via. the Joint Stanford
Operations Center (`JSOC`_).
The polar filled radial magnetic field synoptic maps
are obtained using the 'hmi.synopti... | 2,581 | 36.970588 | 79 | py |
pfsspy | pfsspy-main/doc/source/conf.py | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... | 3,187 | 32.208333 | 79 | py |
muisc | muisc-main/muisc_inference.py | import torch
import torch.nn as nn
from transformers import AutoTokenizer, AutoConfig, GPT2LMHeadModel, TextGenerationPipeline, GPT2DoubleHeadsModel
from muisc_model import ImageEncoderModel, DS
#from training_paper_for_lang_v0_allcls_multitask import ImageEncoderModel, DS
import datasets
from datasets import load_dat... | 5,608 | 30.511236 | 113 | py |
muisc | muisc-main/muisc_model.py |
import logging
import math
import os
import sys
from typing import Optional
from collections import OrderedDict
import numpy as np
from dataclasses import dataclass, field
import torch
import torch.nn as nn
from torch.utils.data import Dataset, DataLoader
import datasets
from datasets import load_dataset
import tra... | 6,888 | 32.769608 | 120 | py |
muisc | muisc-main/transformers/setup.py | # Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 12,626 | 33.219512 | 259 | py |
muisc | muisc-main/transformers/hubconf.py | # Copyright 2020 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | 8,496 | 51.450617 | 189 | py |
muisc | muisc-main/transformers/examples/research_projects/longform-qa/eli5_app.py | import datasets
import numpy as np
import streamlit as st
import torch
from elasticsearch import Elasticsearch
import faiss
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 impor... | 13,474 | 37.28125 | 159 | py |
muisc | muisc-main/transformers/examples/research_projects/longform-qa/eli5_utils.py | import functools
import math
import os # noqa: F401
from random import choice, randint
from time import time
import datasets # 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 elasticsearch.helpers im... | 28,299 | 40.07402 | 119 | py |
muisc | muisc-main/transformers/examples/research_projects/bertology/run_prune_gpt.py | #!/usr/bin/env python3
""" This script is adapted from the Bertology pruning code (https://github.com/huggingface/transformers/blob/783d7d2629e97c5f0c5f9ef01b8c66410275c204/examples/research_projects/bertology/run_bertology.py)
to prune GPT-like models. The author is @altsoph.
"""
import argparse
import logging
import... | 15,469 | 38.666667 | 204 | py |
muisc | muisc-main/transformers/examples/research_projects/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,572 | 40.181818 | 118 | py |
muisc | muisc-main/transformers/examples/research_projects/rag/use_own_knowledge_dataset.py | import logging
import os
from dataclasses import dataclass, field
from functools import partial
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import List, Optional
import torch
from datasets import Features, Sequence, Value, load_dataset
import faiss
from transformers import (
DPRCo... | 8,174 | 38.878049 | 152 | py |
muisc | muisc-main/transformers/examples/research_projects/rag/utils_rag.py | import itertools
import json
import linecache
import os
import pickle
import re
import socket
import string
from collections import Counter
from logging import getLogger
from pathlib import Path
from typing import Callable, Dict, Iterable, List
import git
import torch
from torch.utils.data import Dataset
from transfo... | 8,114 | 32.122449 | 118 | py |
muisc | muisc-main/transformers/examples/research_projects/rag/finetune_rag.py | """Finetuning script for RAG models. Adapted from examples.seq2seq.finetune.py"""
import argparse
import logging
import os
import sys
import time
from collections import defaultdict
from pathlib import Path
from typing import Any, Dict, List, Tuple
import numpy as np
import pytorch_lightning as pl
import torch
import... | 25,597 | 40.420712 | 197 | py |
muisc | muisc-main/transformers/examples/research_projects/rag/distributed_pytorch_retriever.py | import logging
import os
from typing import List, Tuple
import numpy as np
import psutil
import torch
import torch.distributed as dist
from transformers import RagRetriever
logger = logging.getLogger(__name__)
class RagPyTorchDistributedRetriever(RagRetriever):
"""
A distributed retriever built on top of ... | 6,539 | 46.05036 | 155 | py |
muisc | muisc-main/transformers/examples/research_projects/rag/test_distributed_retriever.py | import json
import os
import shutil
import sys
import tempfile
import unittest
from unittest import TestCase
from unittest.mock import patch
import numpy as np
from datasets import Dataset
import faiss
from transformers import BartConfig, BartTokenizer, DPRConfig, DPRQuestionEncoderTokenizer, RagConfig
from transform... | 13,794 | 39.693215 | 118 | py |
muisc | muisc-main/transformers/examples/research_projects/rag/eval_rag.py | """ Evaluation script for RAG models."""
import argparse
import ast
import logging
import os
import sys
import pandas as pd
import torch
from tqdm import tqdm
from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration
from transformers import logging as trans... | 11,101 | 34.469649 | 132 | py |
muisc | muisc-main/transformers/examples/research_projects/rag/lightning_base.py | import argparse
import logging
import os
from pathlib import Path
from typing import Any, Dict
import pytorch_lightning as pl
from pytorch_lightning.utilities import rank_zero_info
from transformers import (
AdamW,
AutoConfig,
AutoModel,
AutoModelForPreTraining,
AutoModelForQuestionAnswering,
... | 15,005 | 37.280612 | 119 | py |
muisc | muisc-main/transformers/examples/research_projects/rag/callbacks_rag.py | import logging
from pathlib import Path
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint
from pytorch_lightning.utilities import rank_zero_only
from utils_rag import save_json
def count_trainable_parameters(model):
model_parame... | 4,420 | 36.786325 | 126 | py |
muisc | muisc-main/transformers/examples/research_projects/rag/_test_finetune_rag.py | import json
import logging
import os
import sys
from pathlib import Path
import finetune_rag
from transformers.file_utils import is_apex_available
from transformers.testing_utils import (
TestCasePlus,
execute_subprocess_async,
require_ray,
require_torch_gpu,
require_torch_multi_gpu,
)
logging.ba... | 3,969 | 34.765766 | 85 | py |
muisc | muisc-main/transformers/examples/research_projects/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,735 | 34.001218 | 182 | py |
muisc | muisc-main/transformers/examples/research_projects/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,788 | 34.92543 | 117 | py |
muisc | muisc-main/transformers/examples/research_projects/pplm/pplm_classification_head.py | from torch import nn
class ClassificationHead(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 = nn.Linear(embed_size, embed_size... | 651 | 31.6 | 68 | py |
muisc | muisc-main/transformers/examples/research_projects/deebert/test_glue_deebert.py | import argparse
import logging
import sys
from unittest.mock import patch
import run_glue_deebert
from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
def get_setup_file():
parser = argparse.... | 3,690 | 34.152381 | 109 | py |
muisc | muisc-main/transformers/examples/research_projects/deebert/run_glue_deebert.py | from __future__ import absolute_import, division, print_function
import argparse
import glob
import logging
import os
import random
import time
import numpy as np
import torch
from torch import nn
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset
from torch.utils.data.distribute... | 31,693 | 42.297814 | 150 | py |
muisc | muisc-main/transformers/examples/research_projects/deebert/src/modeling_highway_bert.py | import torch
from torch import nn
from torch.nn import CrossEntropyLoss, MSELoss
from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward
from transformers.models.bert.modeling_bert import (
BERT_INPUTS_DOCSTRING,
BERT_START_DOCSTRING,
BertEmbeddings,
BertLayer,
... | 17,668 | 43.506297 | 172 | py |
muisc | muisc-main/transformers/examples/research_projects/deebert/src/modeling_highway_roberta.py | from __future__ import absolute_import, division, print_function, unicode_literals
from torch import nn
from torch.nn import CrossEntropyLoss, MSELoss
from transformers import RobertaConfig
from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward
from transformers.models.roberta... | 6,791 | 42.261146 | 172 | py |
muisc | muisc-main/transformers/examples/research_projects/lxmert/modeling_frcnn.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2 && Huggingface Co.
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... | 73,730 | 37.361602 | 152 | py |
muisc | muisc-main/transformers/examples/research_projects/lxmert/extracting_data.py | import getopt
import json
import os
# import numpy as np
import sys
from collections import OrderedDict
import datasets
import numpy as np
import torch
from modeling_frcnn import GeneralizedRCNN
from processing_image import Preprocess
from utils import Config
"""
USAGE:
``python extracting_data.py -i <img_dir> -o ... | 5,254 | 34.033333 | 109 | py |
muisc | muisc-main/transformers/examples/research_projects/lxmert/utils.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal, Huggingface team :)
Adapted From Facebook Inc, Detectron2
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://w... | 18,199 | 31.5 | 143 | py |
muisc | muisc-main/transformers/examples/research_projects/lxmert/visualizing_image.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2
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/license... | 13,420 | 25.842 | 100 | py |
muisc | muisc-main/transformers/examples/research_projects/lxmert/processing_image.py | """
coding=utf-8
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
Adapted From Facebook Inc, Detectron2
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/license... | 5,678 | 36.86 | 114 | py |
muisc | muisc-main/transformers/examples/research_projects/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,263 | 35.1322 | 114 | py |
muisc | muisc-main/transformers/examples/research_projects/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,523 | 34.075269 | 117 | py |
muisc | muisc-main/transformers/examples/research_projects/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,753 | 33.25 | 106 | py |
muisc | muisc-main/transformers/examples/research_projects/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,419 | 43.646465 | 99 | py |
muisc | muisc-main/transformers/examples/research_projects/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,188 | 28.278736 | 137 | py |
muisc | muisc-main/transformers/examples/research_projects/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... | 8,213 | 33.225 | 133 | py |
muisc | muisc-main/transformers/examples/research_projects/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,775 | 33.533724 | 118 | py |
muisc | muisc-main/transformers/examples/research_projects/performer/run_mlm_performer.py | # coding=utf-8
# Copyright 2020 The HuggingFace Team All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... | 28,527 | 40.586006 | 119 | py |
muisc | muisc-main/transformers/examples/research_projects/performer/modeling_flax_performer.py | # coding=utf-8
# Copyright 2018 The Google Flax 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
... | 21,123 | 37.129964 | 120 | py |
muisc | muisc-main/transformers/examples/research_projects/performer/modeling_flax_performer_utils.py | # coding=utf-8
# Copyright 2020 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicab... | 25,683 | 37.856278 | 119 | py |
muisc | muisc-main/transformers/examples/research_projects/rag-end2end-retriever/use_own_knowledge_dataset.py | import logging
import os
from dataclasses import dataclass, field
from functools import partial
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import List, Optional
import torch
from datasets import Features, Sequence, Value, load_dataset
import faiss
from transformers import DPRContextE... | 6,909 | 39.174419 | 152 | py |
muisc | muisc-main/transformers/examples/research_projects/rag-end2end-retriever/utils_rag.py | import itertools
import json
import linecache
import os
import pickle
import re
import socket
import string
from collections import Counter
from logging import getLogger
from pathlib import Path
from typing import Callable, Dict, Iterable, List
import git
import torch
from torch.utils.data import Dataset
from transfo... | 8,114 | 32.122449 | 118 | py |
muisc | muisc-main/transformers/examples/research_projects/rag-end2end-retriever/finetune_rag.py | """Finetuning script for RAG models. Adapted from examples.seq2seq.finetune.py"""
import argparse
import copy
import json
import logging
import multiprocessing
import os
import random
import shutil
import sys
import time
from collections import defaultdict
from pathlib import Path
from typing import Any, Dict, List, T... | 33,046 | 40.831646 | 197 | py |
muisc | muisc-main/transformers/examples/research_projects/rag-end2end-retriever/eval_rag.py | """ Evaluation script for RAG models."""
import argparse
import ast
import logging
import os
import sys
import pandas as pd
import torch
from tqdm import tqdm
from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration
from transformers import logging as trans... | 11,101 | 34.469649 | 132 | py |
muisc | muisc-main/transformers/examples/research_projects/rag-end2end-retriever/lightning_base.py | import argparse
import logging
import os
from pathlib import Path
from typing import Any, Dict
import pytorch_lightning as pl
from pytorch_lightning.plugins.training_type import DDPPlugin
from pytorch_lightning.utilities import rank_zero_info
from transformers import (
AdamW,
AutoConfig,
AutoModel,
Au... | 16,400 | 38.425481 | 124 | py |
muisc | muisc-main/transformers/examples/research_projects/rag-end2end-retriever/callbacks_rag.py | import logging
from pathlib import Path
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint
from pytorch_lightning.utilities import rank_zero_only
from utils_rag import save_json
def count_trainable_parameters(model):
model_parame... | 4,463 | 36.2 | 126 | py |
muisc | muisc-main/transformers/examples/research_projects/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,395 | 35.516129 | 124 | py |
muisc | muisc-main/transformers/examples/research_projects/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,608 | 41.611752 | 156 | py |
muisc | muisc-main/transformers/examples/research_projects/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 |
muisc | muisc-main/transformers/examples/research_projects/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,733 | 41.130627 | 156 | py |
muisc | muisc-main/transformers/examples/research_projects/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... | 47,092 | 45.169608 | 152 | py |
muisc | muisc-main/transformers/examples/research_projects/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,506 | 41.121495 | 105 | py |
muisc | muisc-main/transformers/examples/research_projects/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,822 | 39.158621 | 175 | py |
muisc | muisc-main/transformers/examples/research_projects/zero-shot-distillation/distill_classifier.py | import logging
import os
import sys
from dataclasses import dataclass, field
from typing import List, Optional
import torch
from datasets import Dataset
from torch import nn
from tqdm.auto import tqdm
from transformers import (
AutoModelForSequenceClassification,
AutoTokenizer,
HfArgumentParser,
Train... | 12,205 | 35.0059 | 119 | py |
muisc | muisc-main/transformers/examples/research_projects/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,896 | 40.705061 | 123 | py |
muisc | muisc-main/transformers/examples/research_projects/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,586 | 30.204082 | 119 | py |
muisc | muisc-main/transformers/examples/research_projects/seq2seq-distillation/callbacks.py | import logging
from pathlib import Path
import numpy as np
import pytorch_lightning as pl
import torch
from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint
from pytorch_lightning.utilities import rank_zero_only
from utils import save_json
def count_trainable_parameters(model):
model_parameters... | 4,416 | 37.077586 | 132 | py |
muisc | muisc-main/transformers/examples/research_projects/seq2seq-distillation/run_eval.py | #!/usr/bin/env python
import argparse
import datetime
import json
import time
import warnings
from logging import getLogger
from pathlib import Path
from typing import Dict, List
import torch
from tqdm import tqdm
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
from utils import calculate_bleu, calcula... | 6,507 | 38.442424 | 189 | py |
muisc | muisc-main/transformers/examples/research_projects/seq2seq-distillation/_test_seq2seq_examples.py | import argparse
import logging
import os
import sys
import tempfile
from pathlib import Path
import pytest
import pytorch_lightning as pl
import torch
from torch import nn
import lightning_base
from convert_pl_checkpoint_to_hf import convert_pl_to_hf
from distillation import distill_main
from finetune import Summariz... | 16,566 | 36.229213 | 115 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.