repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
RM-Tools | RM-Tools-master/RMtools_1D/mk_test_ascii_data.py | #!/usr/bin/env python
#=============================================================================#
# #
# NAME: mk_test_ascii_data.py #
# ... | 16,089 | 45.773256 | 86 | py |
RM-Tools | RM-Tools-master/RMtools_1D/models_ns/m4.py | #=============================================================================#
# MODEL DEFINITION FILE #
#=============================================================================#
import numpy as np
import bilby
from bilby.core.prior import PriorDict, Constrai... | 4,420 | 34.653226 | 99 | py |
RM-Tools | RM-Tools-master/RMtools_1D/models_ns/m2.py | #=============================================================================#
# MODEL DEFINITION FILE #
#=============================================================================#
import numpy as np
import bilby
#----------------------------------------------... | 2,365 | 39.101695 | 79 | py |
RM-Tools | RM-Tools-master/RMtools_1D/models_ns/m3.py | #=============================================================================#
# MODEL DEFINITION FILE #
#=============================================================================#
import numpy as np
import bilby
from bilby.core.prior import PriorDict, Constrai... | 4,069 | 34.391304 | 99 | py |
RM-Tools | RM-Tools-master/RMtools_1D/models_ns/m11.py | #=============================================================================#
# MODEL DEFINITION FILE #
#=============================================================================#
import numpy as np
import bilby
from bilby.core.prior import PriorDict, Constrai... | 3,854 | 34.694444 | 99 | py |
RM-Tools | RM-Tools-master/RMtools_1D/models_ns/m1.py | # =============================================================================#
# MODEL DEFINITION FILE #
# =============================================================================#
import numpy as np
import bilby
#--------------------------------------------... | 2,038 | 38.211538 | 80 | py |
RM-Tools | RM-Tools-master/RMtools_1D/models_ns/__init__.py | #! /usr/bin/env python
__all__ = ['']
| 38 | 12 | 22 | py |
kitti2bag | kitti2bag-master/setup.py | #!/usr/bin/env python
from setuptools import setup
setup(
name='kitti2bag',
version='1.5',
description='Convert KITTI dataset to ROS bag file the easy way!',
author='Tomas Krejci',
author_email='tomas@krej.ci',
url='https://github.com/tomas789/kitti2bag/',
download_url = 'https://github.co... | 558 | 28.421053 | 75 | py |
kitti2bag | kitti2bag-master/kitti2bag/__main__.py | from .kitti2bag import run_kitti2bag
def main():
run_kitti2bag()
if __name__ == '__main__':
main()
| 112 | 9.272727 | 36 | py |
kitti2bag | kitti2bag-master/kitti2bag/kitti2bag.py | #!env python
# -*- coding: utf-8 -*-
import sys
try:
import pykitti
except ImportError as e:
print('Could not load module \'pykitti\'. Please run `pip install pykitti`')
sys.exit(1)
import tf
import os
import cv2
import rospy
import rosbag
import progressbar
from tf2_msgs.msg import TFMessage
from dateti... | 16,650 | 41.477041 | 172 | py |
kitti2bag | kitti2bag-master/kitti2bag/__init__.py | 0 | 0 | 0 | py | |
covidmx | covidmx-master/setup.py | import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="covidmx",
version="0.3.1",
author="Federico Garza",
author_email="fede.garza.ramirez@gmail.com",
description="Python API to get information about COVID-19 in México.",
long_description... | 983 | 27.114286 | 74 | py |
covidmx | covidmx-master/covidmx/dge_plot.py | from mapsmx import MapsMX
import pandas as pd
import matplotlib.pyplot as plt
class DGEPlot:
"""
Class to plot dge information
"""
def __init__(self, dge_data, catalogue, description):
self.dge_data = self.prepare_data(dge_data)
self.dge_data['cve_ent'] = self.dge_data['cve_ent'].asty... | 5,865 | 36.363057 | 141 | py |
covidmx | covidmx-master/covidmx/serendipia.py | import pandas as pd
from itertools import product
from unidecode import unidecode
from covidmx.utils import translate_serendipia
pd.options.mode.chained_assignment = None
class Serendipia:
def __init__(
self,
date=None,
kind=None,
clean=True,
add_search... | 5,756 | 31.710227 | 169 | py |
covidmx | covidmx-master/covidmx/covidmx.py | from covidmx.serendipia import Serendipia
from covidmx.dge import DGE
def CovidMX(source="DGE", **kwargs):
"""
Returns COVID19 data from source.
Parameters
----------
Args:
source (str): Source of data. Allowed: DGE, Serendipia.
Kwargs (source="DGE"):
clean (bool): Whether dat... | 1,420 | 37.405405 | 96 | py |
covidmx | covidmx-master/covidmx/utils.py | #!/usr/bin/env python
# coding: utf-8
from pathlib import Path
from typing import Tuple, Union
import logging
import requests
import zipfile
import subprocess
from tqdm import tqdm
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def download_file(directory: Union[str, Path], source_url... | 2,213 | 25.047059 | 98 | py |
covidmx | covidmx-master/covidmx/__init__.py | from covidmx.covidmx import CovidMX
| 36 | 17.5 | 35 | py |
covidmx | covidmx-master/covidmx/dge.py | import logging
import wget
import os
import zipfile
import shutil
from io import BytesIO
import requests
from zipfile import ZipFile
import pandas as pd
from itertools import product
from unidecode import unidecode
from covidmx.utils import download_file, translate_serendipia
from covidmx.dge_plot import DGEPlot
pd.op... | 7,956 | 32.154167 | 110 | py |
covidmx | covidmx-master/covidmx/tests/test_plots.py | import pytest
from covidmx import CovidMX
def test_makes_plot():
try:
dge_plot = CovidMX().get_plot()
for st in dge_plot.available_status:
file_name = '{}.png'.format(st)
mx_map = dge_plot.plot_map(status=st, save_file_name=file_name)
mx_map_with_muns = dge_plot... | 1,336 | 57.130435 | 151 | py |
covidmx | covidmx-master/covidmx/tests/test_serendipia.py | import pytest
from covidmx import CovidMX
def test_returns_data():
try:
covid_data = CovidMX(source='Serendipia').get_data()
covid_data = CovidMX(source='Serendipia', date='18-04-2020').get_data()
raw_data = CovidMX(source='Serendipia', clean=False).get_data()
confirmed = CovidMX(s... | 518 | 36.071429 | 79 | py |
covidmx | covidmx-master/covidmx/tests/__init__.py | 0 | 0 | 0 | py | |
covidmx | covidmx-master/covidmx/tests/test_dge.py | import pytest
from covidmx import CovidMX
import shutil
def test_returns_data():
try:
covid_dge_data_saved = CovidMX(data_path="./database").get_data() #date='07-06-2020',
shutil.rmtree("./database")
covid_dge_data = CovidMX().get_data()
raw_dge_data = CovidMX(clean=False).get_... | 1,034 | 35.964286 | 123 | py |
TFOD | TFOD-main/demo/tfod_detectron2_data_demonstration.py | import os, IPython, _pickle as pickle, sys
from detectron2.data import DatasetCatalog, MetadataCatalog
# Few-shot object detection configuration.
k = 1 # 1, 2, or 4. Number of few-shot annotated examples per object.
tfod_directory = "./"
sys.path.insert(0, tfod_directory)
import tfod
# Load few-shot annotation data ... | 1,460 | 43.272727 | 81 | py |
TFOD | TFOD-main/demo/tfod_clickbot_baseline_demonstration.py | import os, IPython, _pickle as pickle, sys
from detectron2.data import DatasetCatalog, MetadataCatalog
# Few-shot object detection configuration.
k = 4 # 1, 2, or 4. Number of few-shot annotated examples per object.
tfod_directory = "./"
sys.path.insert(0, tfod_directory)
import tfod
# Load few-shot annotation data ... | 1,338 | 45.172414 | 81 | py |
TFOD | TFOD-main/demo/tfod_manual_data_demonstration.py | import os, IPython, _pickle as pickle
# Few-shot object detection configuration.
k = 1 # 1, 2, or 4. Number of few-shot annotated examples per object.
tfod_directory = "./"
def load_tfod_data(tfod_directory, n_shots=1, benchmark=False):
""" Load few-shot annotation or benchmark evaluation data.
Few-shot annotation... | 1,929 | 40.956522 | 87 | py |
TFOD | TFOD-main/tfod/tfod_utils.py | import os, _pickle as pickle
def load_tfod_data(tfod_directory, n_shots=1, benchmark=False):
""" Load few-shot annotation or benchmark evaluation data.
Few-shot annotation based on the number of examples per object. """
# Load few-shot annotation or evaluation data.
if benchmark:
print("Loading tfod benchmark... | 1,115 | 40.333333 | 76 | py |
TFOD | TFOD-main/tfod/clickbot_baseline.py | import os
from detectron2.config import get_cfg
from detectron2 import model_zoo
from detectron2.engine import DefaultTrainer
def clickbot_detectron2(fewshot_set, categories):
""" ClickBot Few-Shot Object Detection Model and TFOD Benchmark Baseline.
"""
# Configure ClickBot few-shot baseline using detectron2.
cfg... | 1,374 | 35.184211 | 74 | py |
TFOD | TFOD-main/tfod/__init__.py | from .tfod_utils import *
from .clickbot_baseline import * | 58 | 28.5 | 32 | py |
isoAR | isoAR-master/isoAR.py | from pylab import *
import scipy
from scipy import interpolate
from scipy import optimize
import emcee
import scipy.optimize as op
import corner
import pickle
import os
#import pymultinest
from astropy import constants
import matplotlib
import seaborn as sns
from matplotlib.patches import Ellipse
def get_mass(Ms, P, e... | 58,108 | 29.139523 | 167 | py |
ice_feature_impact | ice_feature_impact-main/header.py | import numpy as np
from datetime import datetime
def data_root(path):
return '../../data/'+path
def raw_root(path):
return data_root('raw/' + path)
def processed_root(path):
return data_root('processed/' + path)
def interim_root(path):
return data_root('interim/' + path)
def results_root(path):
return data_ro... | 611 | 23.48 | 52 | py |
ice_feature_impact | ice_feature_impact-main/scripts/shap_class.py | import shap
class SHAP_FI():
def __init__(self, model_type, n_samples = 3, seed_num = None, time = False, trace = False, max_display = 999):
'''
Instantiates the SHAP_FI class.
@param model_type: Determine which version of SHAP to use
@param seed_num : Random seed for reproducibili... | 3,324 | 32.928571 | 115 | py |
ice_feature_impact | ice_feature_impact-main/scripts/pfi_class.py | from sklearn.inspection import permutation_importance
class PFI_FI():
def __init__(self, y, seed_num = 42, time = True, trace = False, max_display = 999):
'''
Instantiates the SHAP_FI class.
@param seed_num : Random seed for reproducibility.
@param time: Set time functionality for ... | 2,621 | 30.214286 | 96 | py |
ice_feature_impact | ice_feature_impact-main/scripts/ice_class.py | from sklearn.linear_model import LogisticRegression
class ICE():
def __init__(self, model_type, frac_sample = 1, seed_num = None, time = False, trace = False):
'''
Instantiates the ICE class
@param model_type : "binary" or "continuous" y-variable
@param frac_sample : Fraction of data set to sample for ICE df.... | 15,474 | 28.143126 | 131 | py |
ice_feature_impact | ice_feature_impact-main/scripts/ice_class_save.py | from sklearn.linear_model import LogisticRegression
class ICE():
def __init__(self, model_type, frac_sample = 1, seed_num = None, time = False, trace = False):
'''
Instantiates the ICE class
@param model_type : "binary" or "continuous" y-variable
@param frac_sample : Fraction of data set to sample for ICE df.... | 15,239 | 29.118577 | 131 | py |
ice_feature_impact | ice_feature_impact-main/scripts/native_class.py | class Native_FI():
def __init__(self, seed_num = None, time = True, trace = False, max_display = 999):
'''
Instantiates the SHAP_FI class.
@param seed_num : Random seed for reproducibility.
@param time: Set time functionality for runtime.
@param trace : Turn on/off trace mes... | 2,666 | 34.56 | 89 | py |
ice_feature_impact | ice_feature_impact-main/scripts/fi_comparators.py | class Comparator():
def __init__(self, trace = False):
self.trace = trace
def fit(self, X, model, fi_classes):
'''
Purpose: Build a table to compare our feature importance/impact metrics
@X: Dataset with features as column names
@model: Model we're analyzing
@fi_... | 1,417 | 30.511111 | 79 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/test.py | import time
import os
from tqdm import tqdm
import torch
from torch import nn
from torch.utils.data import DataLoader
from datasets import load_data
from utils import AverageMeter, load_checkpoint, parse_opt
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
def test(model: nn.Module, model_name: ... | 2,873 | 37.837838 | 142 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/nlp_dl_bench_train.py | import os
os.environ['CUDA_VISIBLE_DEVICES'] = '1'
import torch
import torch.backends.cudnn as cudnn
from torch import optim, nn
import time
import random
import models
from trainer import Trainer
from datasets import load_data
from utils import load_embeddings, load_checkpoint, parse_opt
def set_trainer(config, ... | 6,811 | 31.438095 | 162 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/classify.py | import os
import json
from nltk.tokenize import PunktSentenceTokenizer, TreebankWordTokenizer
from typing import Tuple, Dict
import torch
from torch import nn
from datasets import get_clean_text, get_label_map, load_data
from utils import *
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# path... | 6,739 | 32.039216 | 172 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/preprocess.py | from datasets import run_doc_prepro, run_sent_prepro
from utils import parse_opt
if __name__ == '__main__':
# data_name = 'ag_news'
data_name = 'yelp_review_full'
#model_name = 'textcnn'
model_name = 'han'
config = parse_opt(data_name, model_name)
if config.model_name in ['han']:
run_... | 1,687 | 29.690909 | 115 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/trainer/__init__.py | from .trainer import Trainer
| 29 | 14 | 28 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/trainer/trainer.py | import time
from typing import Optional, Dict
import torch
from torch import nn, optim
from torch.utils.data import DataLoader
import os
import torch.backends.cudnn as cudnn
from tqdm import tqdm
from utils import TensorboardWriter, AverageMeter, save_checkpoint, \
clip_gradient, adjust_learning_rate
def get_cu... | 15,444 | 35.426887 | 146 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/__init__.py | import torch
from .HAN import HAN
from .fastText import fastText
from .AttBiLSTM import AttBiLSTM
from .TextCNN import TextCNN1D, TextCNN2D
from .Transformer import Transformer
from utils.opts import Config
def make(
config: Config,
n_classes: int,
vocab_size: int,
embeddings: torch.Tensor,
emb_si... | 3,745 | 31.293103 | 83 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/TextCNN/cnn2d.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import List
class TextCNN2D(nn.Module):
"""
Implementation of 2D version of TextCNN proposed in paper [1].
`Here <https://github.com/yoonkim/CNN_sentence>`_ is the official
implementation of TextCNN.
Parameters
---... | 4,764 | 29.544872 | 145 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/TextCNN/__init__.py | from .cnn1d import TextCNN1D
from .cnn2d import TextCNN2D
| 58 | 18.666667 | 28 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/TextCNN/cnn1d.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import List
class TextCNN1D(nn.Module):
"""
Implementation of 1D version of TextCNN proposed in paper [1].
`Here <https://github.com/yoonkim/CNN_sentence>`_ is the official
implementation of TextCNN.
Parameters
---... | 4,842 | 29.459119 | 134 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/Transformer/encoder_layer.py | import torch
import torch.nn as nn
from typing import Optional, Tuple
from .attention import MultiHeadAttention
from .ffn import PositionWiseFeedForward
class EncoderLayer(nn.Module):
"""
An encoder layer.
Parameters
----------
d_model : int
Size of word embeddings
n_heads : int
... | 1,824 | 29.416667 | 141 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/Transformer/ffn.py | import torch
import torch.nn as nn
class PositionWiseFeedForward(nn.Module):
"""
Position-Wise Feed-Forward Network
Parameters
----------
d_model : int
Size of word embeddings
hidden_size : int
Size of position-wise feed forward network
dropout : float
Dropout
... | 1,361 | 26.24 | 85 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/Transformer/transformer.py | import copy
import torch
from torch import nn
from .pe import PositionalEncoding
from .encoder_layer import EncoderLayer
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
def get_padding_mask(seq: torch.Tensor, pad_idx: int = 0) -> torch.Tensor:
"""
Mask tokens that are pads (not pad: 1, ... | 4,632 | 28.509554 | 105 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/Transformer/pe.py | import torch
import torch.nn as nn
import numpy as np
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
class PositionalEncoding(nn.Module):
"""
Positional Encoding
Parameters
----------
d_model : int
Size of word embeddings
word_pad_len : int
Length of th... | 1,596 | 29.132075 | 87 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/Transformer/__init__.py | from .transformer import Transformer
| 37 | 18 | 36 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/Transformer/attention.py | import torch
import torch.nn as nn
from typing import Optional, Tuple
class ScaledDotProductAttention(nn.Module):
"""
Scaled Dot-Product Attention
Parameters
----------
scale : float
Scale factor (sqrt(d_k))
dropout : float
Dropout
"""
def __init__(self, scale: float, ... | 4,635 | 29.906667 | 145 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/AttBiLSTM/att_bilstm.py | import torch
from torch import nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence, PackedSequence
from .attention import Attention
class AttBiLSTM(nn.Module):
"""
Implementation of Attention-based bidirectional LSTM proposed in paper [1].
Parameters
----------
n_classes :... | 4,575 | 31 | 137 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/AttBiLSTM/__init__.py | from .att_bilstm import AttBiLSTM
| 34 | 16.5 | 33 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/AttBiLSTM/attention.py | import torch
from torch import nn
from typing import Tuple
class Attention(nn.Module):
"""
Attention network
Parameters
----------
rnn_size : int
Size of Bi-LSTM
"""
def __init__(self, rnn_size: int) -> None:
super(Attention, self).__init__()
self.w = nn.Linear(rnn_... | 1,279 | 26.234043 | 76 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/HAN/word_encoder.py | import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence, PackedSequence
from typing import Tuple
class WordEncoder(nn.Module):
"""
Word-level attention module
Parameters
----------
vocab_size : int
Number of words in the vocabulary
e... | 5,016 | 33.363014 | 147 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/HAN/han.py | import torch
import torch.nn as nn
from typing import Tuple
from .sent_encoder import *
class HAN(nn.Module):
"""
Implementation of Hierarchial Attention Network (HAN) proposed in paper [1].
Parameters
----------
n_classes : int
Number of classes
vocab_size : int
Number of wo... | 3,401 | 26.885246 | 162 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/HAN/sent_encoder.py | import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence, PackedSequence
from typing import Tuple
from .word_encoder import WordEncoder
class SentenceEncoder(nn.Module):
"""
Sentence-level attention module
Parameters
----------
vocab_size : int
... | 6,680 | 35.508197 | 175 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/HAN/__init__.py | from .han import HAN
| 21 | 10 | 20 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/fastText/fasttext.py | import torch
from torch import nn
class fastText(nn.Module):
"""
Implementation of fastText proposed in paper [1].
`Here <https://github.com/facebookresearch/fastText>`_ is the official
implementation of fastText.
Parameters
----------
n_classes : int
Number of classes
vocab_... | 3,017 | 28.019231 | 92 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/models/fastText/__init__.py | from .fasttext import fastText
| 31 | 15 | 30 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/dataloader.py | """
Load data from manually preprocessed data (see ``datasets/prepocess/``).
"""
import os
import json
from typing import Dict, Tuple, Union
import torch
from torch.utils.data import Dataset, DataLoader
from utils import load_embeddings
from utils.opts import Config
from .info import get_label_map
import sys
sys.pa... | 12,615 | 33.659341 | 139 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/torchtext.py | '''
script for loading data for sentence classification using torchtext (never used)
I abandon this because torchtext loads all data in one go, which occupies
too much memory and slows down the training speed, expecially when the dataset
is big.
So I finally choose to preprocess data manually (see datasets/prepoces... | 4,413 | 34.596774 | 152 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/__init__.py | from .info import get_label_map
from .preprocess import get_clean_text, run_doc_prepro, run_sent_prepro
from .dataloader import load_data
| 138 | 33.75 | 71 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/preprocess/document.py | """
Preprocess data for document classification.
"""
import torch
from typing import Tuple, Dict
from collections import Counter
from nltk.tokenize import PunktSentenceTokenizer, TreebankWordTokenizer
from tqdm import tqdm
import pandas as pd
import os
import json
from .utils import get_clean_text
# tokenizers
sent_... | 6,873 | 30.972093 | 142 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/preprocess/utils.py | def get_clean_text(text: str) -> str:
"""
Preprocess text for being used in the model, including lower-casing,
standardizing newlines and removing junk.
Parameters
----------
text : str
A string to be cleaned
Returns
-------
clean_text : str
String after being clean... | 524 | 24 | 119 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/preprocess/sentence.py | """
Preprocess data for sentence classification.
"""
import torch
from typing import Tuple, Dict
from collections import Counter
from nltk.tokenize import PunktSentenceTokenizer, TreebankWordTokenizer
from tqdm import tqdm
import pandas as pd
import os
import json
from .utils import get_clean_text
# tokenizers
word_... | 5,431 | 29.516854 | 142 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/preprocess/__init__.py | from .utils import get_clean_text
from .document import run_prepro as run_doc_prepro
from .sentence import run_prepro as run_sent_prepro
| 137 | 33.5 | 51 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/info/dbpedia.py | classes = [
'Company',
'EducationalInstitution',
'Artist',
'Athlete',
'OfficeHolder',
'MeanOfTransportation',
'Building',
'NaturalPlace',
'Village',
'Animal',
'Plant',
'Album',
'Film',
'WrittenWork'
]
| 257 | 14.176471 | 29 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/info/yelp_full.py | classes = [
'Score: 0',
'Score: 1',
'Score: 2',
'Score: 3',
'Score: 4'
]
| 93 | 10.75 | 15 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/info/ag_news.py | classes = [
'World',
'Sports',
'Business',
'Sci / Tech'
]
| 74 | 9.714286 | 16 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/info/amazon_polarity.py | classes = [
'Negative polarity',
'Positive polarity'
]
| 63 | 11.8 | 24 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/info/__init__.py | from typing import Tuple, Dict
from . import ag_news, dbpedia, yelp_polarity, yelp_full, yahoo_answers, \
amazon_polarity, amazon_full
def get_label_map(dataset: str) -> Tuple[Dict[str, int], Dict[int, str]]:
if dataset == 'ag_news':
classes = ag_news.classes
elif dataset == 'dbpedia':
cla... | 1,083 | 37.714286 | 77 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/info/amazon_full.py | classes = [
'Score: 0',
'Score: 1',
'Score: 2',
'Score: 3',
'Score: 4'
]
| 93 | 10.75 | 15 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/info/yahoo_answers.py | classes = [
'Society & Culture',
'Science & Mathematics',
'Health',
'Education & Reference',
'Computers & Internet',
'Sports',
'Business & Finance',
'Entertainment & Music',
'Family & Relationships',
'Politics & Government'
]
| 266 | 19.538462 | 29 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/datasets/info/yelp_polarity.py | classes = [
'Negative polarity',
'Positive polarity'
]
| 63 | 11.8 | 24 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/utils/embedding.py | import os
from tqdm import tqdm
from typing import Dict, Tuple
import numpy as np
import torch
def init_embeddings(embeddings: torch.Tensor) -> None:
"""
Fill embedding tensor with values from the uniform distribution.
Parameters
----------
embeddings : torch.Tensor
Word embedding tensor
... | 2,499 | 28.411765 | 104 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/utils/opts.py | import argparse
import yaml
class Config:
"""Convert a ``dict`` into a ``Class``"""
def __init__(self, entries: dict = {}):
for k, v in entries.items():
if isinstance(v, dict):
self.__dict__[k] = Config(v)
else:
self.__dict__[k] = v
def load_conf... | 1,259 | 23.230769 | 58 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/utils/tensorboard.py | import importlib
from typing import Optional, Callable
from datetime import datetime
class TensorboardWriter:
"""
Log metrics into a directory for visualization within the TensorBoard.
Parameters
----------
log_dir : str, optional
Paht to the folder to save logs for TensorBoard
enable... | 2,982 | 35.82716 | 122 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/utils/common.py | import os
from typing import Tuple, Dict
import torch
from torch import nn, optim
def save_checkpoint(
epoch: int,
model: nn.Module,
model_name: str,
optimizer: optim.Optimizer,
dataset_name: str,
word_map: Dict[str, int],
checkpoint_path: str,
checkpoint_basename: str = 'checkpoint'
) ... | 4,047 | 24.459119 | 83 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlp_dl_bench/utils/__init__.py | from .common import AverageMeter, save_checkpoint, load_checkpoint, \
clip_gradient, adjust_learning_rate
from .embedding import init_embeddings, load_embeddings
from .opts import parse_opt
from .tensorboard import TensorboardWriter
| 237 | 38.666667 | 69 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/imagenet_dl_bench/pre_process/images_raw_to_tfrecord.py | import matplotlib.pyplot as plt
from PIL import Image
from torchvision import transforms
import numpy as np
import torch
import sys
import os
import datetime
sys.path.append("../shuffleformat/tfrecord")
sys.path.append("../shuffleformat/corgipile")
sys.path.append(".")
import shuffleformat.tfrecord as tfrecord
import... | 8,062 | 35.31982 | 138 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/imagenet_dl_bench/normal_node/imagenet_corgipile_raw_train.py | import argparse
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0, 1, 2, 3, 4, 5, 6, 7'
import random
import shutil
import time
import warnings
from enum import Enum
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
fr... | 30,945 | 35.025611 | 137 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/imagenet_dl_bench/euler/imagenet_corgipile_raw_train_on_euler.py | import argparse
import os
import random
import shutil
import time
import warnings
from enum import Enum
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
from torch.optim.lr_scheduler import StepLR
import torch.multiproc... | 30,880 | 35.075935 | 137 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/corgipile/dataset.py | import typing
import numpy as np
import datetime
import random
import time
import math
import torch.utils.data
import torch.distributed as dist
from shuffleformat.corgipile import block_reader_tfrecord
from shuffleformat.corgipile import block_iterator_utils
from shuffleformat.corgipile import seq_reader_tfrecord
... | 18,063 | 36.168724 | 152 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/corgipile/seq_reader_tfrecord.py | """Reader utils."""
import functools
import io
import os
import struct
import typing
import numpy as np
from shuffleformat.tfrecord import example_pb2
def tfrecord_seq_iterator(
data_path: str,
index_path: typing.Optional[str] = None,
shard: typing.Optional[typing.Tuple[int, int]] = None
) -> typing.It... | 10,090 | 35.298561 | 84 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/corgipile/block_iterator_utils.py | """Iterator utils."""
from __future__ import division
import typing
import warnings
import random
import datetime
import numpy as np
import torch.distributed as dist
def shuffle_iterator(iterator: typing.Iterator,
buffer_size: int) -> typing.Iterable[typing.Any]:
random.seed()
end_fil... | 687 | 18.111111 | 70 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/corgipile/__init__.py | from shuffleformat.corgipile import block_reader_tfrecord
from shuffleformat.corgipile import block_iterator_utils
from shuffleformat.corgipile import seq_reader_tfrecord
from shuffleformat.corgipile import dataset
from shuffleformat.corgipile.dataset import CorgiPileTFRecordDataset
from shuffleformat.corgipile.dataset... | 524 | 51.5 | 68 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/corgipile/block_reader_tfrecord.py | """Reader utils."""
import functools
import gzip
import io
import os
import struct
import typing
import numpy as np
from shuffleformat.tfrecord import example_pb2
def tfrecord_iterator(
data_path: str,
block_index_list: typing.List[typing.Tuple[int, int]],
start_block_index: int,
end_block_index: i... | 8,740 | 35.881857 | 111 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/tfrecord/writer.py | """Writer utils."""
import io
import struct
import typing
import numpy as np
try:
import crc32c
except ImportError:
crc32c = None
from shuffleformat.tfrecord import example_pb2
class TFRecordWriter:
"""Opens a TFRecord file for writing.
Params:
-------
data_path: str
Path to the tf... | 5,580 | 35.24026 | 118 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/tfrecord/reader.py | """Reader utils."""
import functools
import gzip
import io
import os
import struct
import typing
import numpy as np
from shuffleformat.tfrecord import example_pb2
from shuffleformat.tfrecord import iterator_utils
def tfrecord_iterator(
data_path: str,
index_path: typing.Optional[str] = None,
shard: typ... | 17,307 | 36.873085 | 118 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/tfrecord/iterator_utils.py | """Iterator utils."""
from __future__ import division
import typing
import warnings
import numpy as np
def cycle(iterator_fn: typing.Callable) -> typing.Iterable[typing.Any]:
"""Create a repeating iterator from an iterator generator."""
while True:
for element in iterator_fn():
yield el... | 2,632 | 27.311828 | 76 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/tfrecord/example_pb2.py | # Generated by the protocol buffer compiler. DO NOT EDIT!
# source: example.proto
import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _refle... | 17,910 | 32.922348 | 1,424 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/tfrecord/__init__.py | from shuffleformat.tfrecord import tools
from shuffleformat.tfrecord import torch
from shuffleformat.tfrecord import example_pb2
from shuffleformat.tfrecord import iterator_utils
from shuffleformat.tfrecord import reader
from shuffleformat.tfrecord import writer
from shuffleformat.tfrecord.iterator_utils import *
fro... | 405 | 32.833333 | 51 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/tfrecord/tools/__init__.py | from shuffleformat.tfrecord.tools import tfrecord2idx
from shuffleformat.tfrecord.tools.tfrecord2idx import create_index
| 122 | 29.75 | 66 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/tfrecord/tools/tfrecord2idx.py | from __future__ import print_function
import sys
import struct
def create_index(tfrecord_file: str, index_file: str) -> None:
"""Create index from the tfrecords file.
Stores starting location (byte) and length (in bytes) of each
serialized record.
Params:
-------
tfrecord_file: str
... | 1,210 | 22.288462 | 83 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/tfrecord/torch/dataset.py | """Load tfrecord files into torch datasets."""
import typing
import numpy as np
import torch.utils.data
from shuffleformat.tfrecord import reader
from shuffleformat.tfrecord import iterator_utils
class TFRecordDataset(torch.utils.data.IterableDataset):
"""Parse (generic) TFRecords dataset into `IterableDataset... | 7,917 | 42.505495 | 106 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/shuffleformat/tfrecord/torch/__init__.py | from shuffleformat.tfrecord.torch import dataset
from shuffleformat.tfrecord.torch.dataset import TFRecordDataset
from shuffleformat.tfrecord.torch.dataset import MultiTFRecordDataset
| 185 | 36.2 | 69 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlpformat/__init__.py | from nlpformat import in_mem_block
from nlpformat import in_mem_block_only
from nlpformat import in_mem_sliding_window
from nlpformat import in_mem_bismarck
from nlpformat import in_mem_once_fully_shuffle
# from nlpformat import in_mem_always_fully_shuffle
from nlpformat import in_mem_no_shuffle
from nlpformat import l... | 325 | 39.75 | 51 | py |
CorgiPile-PyTorch | CorgiPile-PyTorch-main/nlpformat/in_mem_sliding_window/dataset.py | import numpy as np
import warnings
import random
import time
import os
import torch.utils.data
from nlpformat.loader import nlp_format_dataloader
class InMemSlidingWindowDocDataset(torch.utils.data.IterableDataset):
def __init__(self,
data_folder: str,
split: str,
... | 6,152 | 32.622951 | 159 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.