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 |
|---|---|---|---|---|---|---|
P-STMO | P-STMO-main/in_the_wild/videopose_PSTMO.py | import os
import time
from common.arguments import parse_args
from common.camera import *
from common.generators import *
from common.loss import *
from common.model import *
from common.utils import Timer, evaluate, add_path
from common.inference_3d import *
from model.block.refine import refine
from model.stmo impo... | 7,170 | 35.217172 | 139 | py |
P-STMO | P-STMO-main/in_the_wild/inference_3d.py | # Copyright (c) 2018-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.
#
import hashlib
import os
import pathlib
import shutil
import sys
import time
import cv2
import numpy as np
import torch
from to... | 3,586 | 32.523364 | 128 | py |
P-STMO | P-STMO-main/model/stmo.py | import torch
import torch.nn as nn
from model.block.vanilla_transformer_encoder import Transformer
from model.block.strided_transformer_encoder import Transformer as Transformer_reduce
class Linear(nn.Module):
def __init__(self, linear_size, p_dropout=0.25):
super(Linear, self).__init__()
self.l_si... | 4,047 | 30.874016 | 92 | py |
P-STMO | P-STMO-main/model/stmo_pretrain.py | import torch
import torch.nn as nn
from model.block.vanilla_transformer_encoder_pretrain import Transformer, Transformer_dec
from model.block.strided_transformer_encoder import Transformer as Transformer_reduce
import numpy as np
class LayerNorm(nn.Module):
def __init__(self, features, eps=1e-6):
super(Lay... | 5,518 | 32.652439 | 119 | py |
P-STMO | P-STMO-main/model/block/refine.py | import torch
import torch.nn as nn
from torch.autograd import Variable
fc_out = 256
fc_unit = 1024
class refine(nn.Module):
def __init__(self, opt):
super().__init__()
out_seqlen = 1
fc_in = opt.out_channels*2*out_seqlen*opt.n_joints
fc_out = opt.in_channels * opt.n_joints
... | 948 | 24.648649 | 89 | py |
P-STMO | P-STMO-main/model/block/vanilla_transformer_encoder_pretrain.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import math
import os
import copy
def clones(module, N):
return nn.ModuleList([copy.deepcopy(module) for _ in range(N)])
class Encoder(nn.Module):
def __init__(self, layer, N):
sup... | 5,115 | 31.176101 | 98 | py |
P-STMO | P-STMO-main/model/block/strided_transformer_encoder.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import math
import os
import copy
def clones(module, N):
return nn.ModuleList([copy.deepcopy(module) for _ in range(N)])
class Encoder(nn.Module):
def __init__(self, layer, N, length, d_mo... | 5,685 | 32.05814 | 120 | py |
P-STMO | P-STMO-main/model/block/vanilla_transformer_encoder.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import numpy as np
import math
import os
import copy
def clones(module, N):
return nn.ModuleList([copy.deepcopy(module) for _ in range(N)])
class Encoder(nn.Module):
def __init__(self, layer, N):
sup... | 4,191 | 30.283582 | 98 | py |
Namaste | Namaste-master/__init__.py | from namaste.namaste import *
| 30 | 14.5 | 29 | py |
Namaste | Namaste-master/namaste/Crossfield_transit.py | """
-------------------------------------------------------
The Mandel & Agol (2002) transit light curve equations.
-------------------------------------------------------
:FUNCTIONS:
:func:`occultuniform` -- uniform-disk transit light curve
:func:`occultquad` -- quadratic limb-darkening
:func:`occultnonlin... | 85,453 | 32.696372 | 289 | py |
Namaste | Namaste-master/namaste/namaste.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
:py:mod:`Namaste.py` - Single transit fitting code
-------------------------------------
'''
import autograd.numpy as np2
import matplotlib
#matplotlib.use('Agg')
import pylab as plt
plt.ioff()
import scipy.optimize as optimize
from os import sys, path
import datetime
i... | 85,233 | 53.013942 | 252 | py |
Namaste | Namaste-master/namaste/planetlib.py | import numpy as np
import glob
import os
from os import path
import matplotlib
#matplotlib.use('Agg')
import pylab as plt
import logging
import astropy.io.fits as fits
import astropy.units as u
import astropy.coordinates as co
import pandas as pd
'''
Assorted scripts used by Namaste
'''
Namwd = path.dirname(path.realp... | 83,024 | 44.743802 | 340 | py |
Namaste | Namaste-master/namaste/run.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
:py:mod:`Namaste.py` - Single transit fitting code
-------------------------------------
'''
import numpy as np
import pylab as plt
import scipy.optimize as optimize
from os import sys, path
import datetime
import logging
import pandas as pd
import click
import emcee... | 66,119 | 50.495327 | 252 | py |
Namaste | Namaste-master/namaste/k2flatten.py | import numpy as np
#import pyfits
#import hpo.planetlib as pl
def dopolyfit(win,d,ni,sigclip):
base = np.polyfit(win[:,0],win[:,1],w=1.0/np.power(win[:,2],2),deg=d)
#for n iterations, clip 3(?) sigma, redo polyfit
for iter in range(ni):
#winsigma = np.std(win[:,1]-np.polyval(base,win[:,0]))
... | 3,881 | 44.670588 | 165 | py |
Namaste | Namaste-master/namaste/__init__.py | __all__=["namaste", "planetlib","Crossfield_transit"]
from . import namaste
from . import planetlib
#from . import k2flatten
from . import Crossfield_transit
| 158 | 25.5 | 53 | py |
InvariantRuleAD | InvariantRuleAD-main/core/__init__.py | 0 | 0 | 0 | py | |
InvariantRuleAD | InvariantRuleAD-main/core/learning/__init__.py | 0 | 0 | 0 | py | |
InvariantRuleAD | InvariantRuleAD-main/core/learning/hp_optimization/Hyperparameter.py | from abc import ABC,abstractmethod
import random
from enum import Enum
class HyperparameterType(Enum):
UniformInteger = 301
UniformFloat = 302
Categorical = 303
Const = 304
class baseHyperparameter(ABC):
'''
The base class for Hyperparameters
Parameters
----------
name : strin... | 5,276 | 21.172269 | 83 | py |
InvariantRuleAD | InvariantRuleAD-main/core/learning/hp_optimization/HPOptimizers.py | import itertools,collections
from .Hyperparameter import HyperparameterType
class RandomizedGridSearch(object):
'''
The utility class for hyperparameters tuning of ML models based on Randomized Grid Search.
Parameters
----------
model : BaseModel
The model, should be an object extends... | 3,373 | 31.757282 | 111 | py |
InvariantRuleAD | InvariantRuleAD-main/core/learning/hp_optimization/__init__.py | 0 | 0 | 0 | py | |
InvariantRuleAD | InvariantRuleAD-main/core/utils/metrics.py | from sklearn.metrics import confusion_matrix
def calc_detection_performance(y_true, y_pred):
"""
calculate anomaly detection performance
Parameters
----------
y_true : ndarray or list
The ground truth labels
y_pred : ndarray or list
The predicted labels
Returns
---... | 660 | 23.481481 | 64 | py |
InvariantRuleAD | InvariantRuleAD-main/core/utils/__init__.py | def override(f):
return f | 29 | 14 | 16 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/base.py | from abc import ABC, abstractmethod
import tempfile
import os
import warnings
class BaseModel(ABC):
"""
The base class
"""
@abstractmethod
def train(self, train_data, val_data=None, **params):
"""
Create a model based on the give hyperparameters and train the model
... | 3,945 | 23.81761 | 78 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/__init__.py | from .base import BaseModel,AnomalyDetector
from enum import Enum
__all__ = ['BaseModel','AnomalyDetector'] | 108 | 26.25 | 43 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/reconstruction_models/DeepSVDD.py | import numpy as np
import tensorflow as tf
from tensorflow import keras
import tempfile
from .. import BaseModel
import random
def oneclass_loss(z,radius,nu):
dist = tf.reduce_sum(tf.square(z), axis=-1)
loss = tf.maximum(dist - radius ** 2, tf.zeros_like(dist))
loss = radius**2+(1/nu)*tf.reduce_mean(loss)... | 4,639 | 32.623188 | 113 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/reconstruction_models/vanilla_autoencoder.py | from tensorflow import keras
import tensorflow as tf
import numpy as np
import tempfile
import random
from .. import BaseModel,AnomalyDetector
from ...preprocessing.signals import ContinuousSignal,CategoricalSignal
from ...learning.hp_optimization.Hyperparameter import ConstHyperparameter,UniformIntegerHyperparameter
f... | 10,613 | 35.854167 | 153 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/reconstruction_models/__init__.py | from .vanilla_autoencoder import Autoencoder
__all__ = ['Autoencoder'] | 72 | 17.25 | 44 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/anomaly_explanation.py | class AnomalyExplanation(object):
'''
Explanation of reported anomaly
'''
def __init__(self):
'''
Constructor
'''
self._records = {}
self._rule_feats_dict = {}
def add_record(self, feat, location, score, rule, rule_feats):
if sel... | 2,241 | 31.492754 | 116 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/rule.py | # import math
from . import helper
class Rule(object):
'''
An Associative Predicate Rule
Parameters
----------
antec : list
list of predicates in the antecedent set
conseq : list
list of predicates in the consequent set
conf : float in [0,1]
the confidence of th... | 2,396 | 25.054348 | 92 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/helper.py | import numpy as np
from ...preprocessing.signals import ContinuousSignal
def search_insert_position(vals, val2insert):
pos = None
for i in range(len(vals)):
if val2insert <= vals[i]:
pos = i
if pos is None:
pos = len(vals)
return pos
def reset_cutoffs(cutoffs,df,min_sa... | 8,594 | 35.574468 | 124 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/__init__.py | 0 | 0 | 0 | py | |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/invariant_model.py | from .. import BaseModel,AnomalyDetector
from ...utils import override
import random,pickle
from .rule_mining import RuleMiner
from sklearn.tree import DecisionTreeClassifier,DecisionTreeRegressor
from sklearn.preprocessing import KBinsDiscretizer
from ...preprocessing.signals import ContinuousSignal
import numpy as np... | 21,250 | 38.353704 | 148 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/rule_mining/MISTree.py |
from .Element import TreeNode, TableEntry
# the structure of a node (item_name, item_count, child-links, node-link)
def count_items(dataset):
"count items in the dataset."
item_count_dict = {}
for transaction in dataset:
for item in transaction:
if item in item_count_dict:
... | 10,081 | 37.776923 | 170 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/rule_mining/RuleMiner.py | from . import MISTree
import pandas as pd
from . import RuleGenerator
from mlxtend.preprocessing import TransactionEncoder
from mlxtend.frequent_patterns import fpgrowth
from mlxtend.frequent_patterns import association_rules
import multiprocessing
from ..rule import Rule
# import time
def _mining(data,gamma, max_k, t... | 6,684 | 42.69281 | 157 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/rule_mining/Element.py | class TreeNode(object):
'''
TreeNode
'''
def __init__(self, item, count, parent_link, child_links, node_link):
'''
Constructor
'''
self.item = item
self.count = count
self.parent_link = parent_link
self.child_links = child_links
self.node... | 860 | 20.525 | 73 | py |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/rule_mining/__init__.py | 0 | 0 | 0 | py | |
InvariantRuleAD | InvariantRuleAD-main/core/model/rule_models/rule_mining/RuleGenerator.py | from ..rule import Rule
def arrangePatterns(freq_patterns, support_data, item_count_dict, max_k, MIN):
"""arrange frequent patterns
"""
L = []
for _ in range(max_k+1):
L.append([])
for item in item_count_dict:
if item_count_dict[item] >= MIN:
key =frozenset([item])
... | 4,660 | 37.520661 | 123 | py |
InvariantRuleAD | InvariantRuleAD-main/core/preprocessing/signals.py | class BaseSignal(object):
'''
The base signal class
Parameters
----------
name : string
the name of the signal
isInput : bool
whether it is an input of the model
isOutput : bool
whether it is an output of the model
'''
def __init__(self, name, i... | 3,594 | 26.868217 | 147 | py |
InvariantRuleAD | InvariantRuleAD-main/core/preprocessing/data_loader.py | import pandas as pd
import numpy as np
from .signals import ContinuousSignal,CategoricalSignal
import zipfile
from enum import Enum
class DATASET(Enum):
SWAT = 101
BATADAL = 102
KDDCup99 = 103
GasPipeline = 104
Annthyroid = 105
Cardio = 106
def load_dataset(ds):
if ds == DATASET.SWAT:... | 12,294 | 36.484756 | 147 | py |
InvariantRuleAD | InvariantRuleAD-main/core/preprocessing/data_util.py | from .signals import CategoricalSignal,ContinuousSignal
import json
import warnings
def signals2dfcolumns(signals):
"""
get df column names given signals
Parameters
----------
signals : list
the list of signals
Returns
-------
list of strings
the dataframe ... | 6,930 | 34.54359 | 139 | py |
InvariantRuleAD | InvariantRuleAD-main/core/preprocessing/__init__.py | from .data_util import DataUtil
__all__ = ['DataUtil']
def train_val_split(df,val_ratio):
"""
split the dataframe into a train part and a validation part
Parameters
----------
df : DataFrame
The dataset
val_ratio : float
the proportion of the validation part
R... | 652 | 22.321429 | 63 | py |
InvariantRuleAD | InvariantRuleAD-main/core/preprocessing/data_handler.py | import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
import warnings
from builtins import isinstance
class TSAEDataHandler():
'''
Data Handler for time-series autoencoders
Parameters
----------
sequence_length : int
the length of sequence
feats : list of stri... | 11,215 | 34.381703 | 120 | py |
InvariantRuleAD | InvariantRuleAD-main/experiments/main_if.py | import sys,getopt
sys.path.insert(0, "../")
from core.preprocessing.data_loader import load_dataset,DATASET
from sklearn.ensemble import IsolationForest
from core.preprocessing import DataUtil
from sklearn.metrics import roc_auc_score
if __name__ == "__main__":
argv = sys.argv[1:]
try:
opts, args... | 1,862 | 27.661538 | 63 | py |
InvariantRuleAD | InvariantRuleAD-main/experiments/main_ir.py | import sys,getopt
sys.path.insert(0, "../")
from core.preprocessing.data_loader import load_dataset,DATASET
from core.preprocessing import DataUtil
from core.model.rule_models.invariant_model import InvariantRuleModel,PredicateMode
from sklearn.metrics import roc_auc_score
from core.preprocessing.signals import Contin... | 5,500 | 35.919463 | 178 | py |
InvariantRuleAD | InvariantRuleAD-main/experiments/main_ae.py | import sys,getopt
sys.path.insert(0, "../")
from core.model.reconstruction_models import Autoencoder
from core.preprocessing.data_loader import DATASET,load_dataset
from core.learning.hp_optimization.Hyperparameter import UniformIntegerHyperparameter,ConstHyperparameter,CategoricalHyperparameter
from core.learning.hp_o... | 2,836 | 35.371795 | 131 | py |
InvariantRuleAD | InvariantRuleAD-main/experiments/main_deepsvdd.py | '''
Created on Nov 9, 2022
@author: z003w5we
'''
import sys,getopt
sys.path.insert(0, "../")
from core.preprocessing.data_loader import DATASET,load_dataset
from core.preprocessing import DataUtil
from sklearn.metrics import roc_auc_score
from core.model.reconstruction_models.DeepSVDD import DeepSVDD
if __name__ ==... | 1,983 | 27.342857 | 142 | py |
InvariantRuleAD | InvariantRuleAD-main/experiments/main_lof.py | import sys,getopt
sys.path.insert(0, "../")
from core.preprocessing.data_loader import load_dataset,DATASET
from sklearn.neighbors import LocalOutlierFactor
from core.preprocessing import DataUtil
from sklearn.metrics import roc_auc_score
if __name__ == "__main__":
argv = sys.argv[1:]
try:
opts, ... | 1,876 | 27.876923 | 63 | py |
InvariantRuleAD | InvariantRuleAD-main/experiments/__init__.py | 0 | 0 | 0 | py | |
CLUE | CLUE-master/baselines/paddlenlp/classification/run_clue_classifier.py | # Copyright (c) 2022 PaddlePaddle Authors. 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 appli... | 20,966 | 37.260949 | 119 | py |
CLUE | CLUE-master/baselines/paddlenlp/classification/run_clue_classifier_trainer.py | # Copyright (c) 2022 PaddlePaddle Authors. 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 appli... | 12,065 | 35.125749 | 134 | py |
CLUE | CLUE-master/baselines/paddlenlp/mrc/run_chid.py | # coding: utf-8
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
# 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.... | 24,584 | 39.975 | 153 | py |
CLUE | CLUE-master/baselines/paddlenlp/mrc/run_c3.py | # coding: utf-8
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
# 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.... | 19,140 | 39.987152 | 123 | py |
CLUE | CLUE-master/baselines/paddlenlp/mrc/run_cmrc2018.py | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
# 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/licen... | 24,357 | 41.733333 | 118 | py |
CLUE | CLUE-master/baselines/paddlenlp/grid_search_tools/warmup_dataset_and_model.py | # Copyright (c) 2022 PaddlePaddle Authors. 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 appli... | 2,253 | 40.740741 | 150 | py |
CLUE | CLUE-master/baselines/paddlenlp/grid_search_tools/grid_search.py | # Copyright (c) 2022 PaddlePaddle Authors. 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 appli... | 6,743 | 32.889447 | 125 | py |
CLUE | CLUE-master/baselines/models/classifier_utils.py | # -*- coding: utf-8 -*-
# @Author: bo.shi
# @Date: 2019-12-01 22:28:41
# @Last Modified by: bo.shi
# @Last Modified time: 2019-12-02 18:36:50
# coding=utf-8
# Copyright 2019 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in complia... | 31,044 | 32.707926 | 100 | py |
CLUE | CLUE-master/baselines/models/xlnet/cmrc2018_evaluate_drcd.py | # -*- coding: utf-8 -*-
'''
Evaluation script for CMRC 2018
version: v5
Note:
v5 formatted output, add usage description
v4 fixed segmentation issues
'''
from __future__ import print_function
from collections import Counter, OrderedDict
import string
import re
import argparse
import json
import sys
reload(sys)
sys.set... | 4,169 | 26.434211 | 80 | py |
CLUE | CLUE-master/baselines/models/xlnet/run_classifier.py | # -*- coding: utf-8 -*-
# @Author: bo.shi
# @Date: 2019-11-04 09:56:36
# @Last Modified by: bo.shi
# @Last Modified time: 2019-12-04 14:39:31
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from os.path import join
from absl import flags
import os
import... | 35,361 | 35.912317 | 94 | py |
CLUE | CLUE-master/baselines/models/xlnet/squad_utils.py | """Official evaluation script for SQuAD version 2.0.
In addition to basic functionality, we also compute additional statistics and
plot precision-recall curves if an additional na_prob.json file is provided.
This file is expected to map question ID's to the model's predicted probability
that a question is unanswerable... | 12,252 | 36.356707 | 107 | py |
CLUE | CLUE-master/baselines/models/xlnet/function_builder.py | """doc."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import functools
import os
import tensorflow as tf
import modeling
import xlnet
def construct_scalar_host_call(
monitor_dict,
model_dir,
prefix="",
reduce_fn=None):
"""
Construc... | 12,303 | 32.895317 | 79 | py |
CLUE | CLUE-master/baselines/models/xlnet/model_utils.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import collections
import os
import re
import numpy as np
import six
from os.path import join
from six.moves import zip
from absl import flags
import tensorflow as tf
def configure_tpu(FLAGS):
if FLAGS.us... | 14,078 | 34.1975 | 82 | py |
CLUE | CLUE-master/baselines/models/xlnet/prepro_utils.py | # coding=utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import unicodedata
import six
from functools import partial
SPIECE_UNDERLINE = '▁'
def printable_text(text):
"""Returns text encoded in a way suitable for print or `tf.logging`."""
# The... | 4,528 | 31.582734 | 94 | py |
CLUE | CLUE-master/baselines/models/xlnet/modeling.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import tensorflow as tf
def gelu(x):
"""Gaussian Error Linear Unit.
This is a smoother version of the RELU.
Original paper: https://arxiv.org/abs/1606.08415
Args:
x: float Tens... | 28,460 | 35.302296 | 80 | py |
CLUE | CLUE-master/baselines/models/xlnet/data_utils.py | # -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import json
import os
import random
from absl import flags
import absl.logging as _logging # pylint: disable=unused-import
import numpy as np
import tensorflow as tf
from prepro_u... | 29,915 | 31.659389 | 97 | py |
CLUE | CLUE-master/baselines/models/xlnet/run_cmrc_drcd.py | # coding=utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from absl import flags
import absl.logging as _logging # pylint: disable=unused-import
import collections
import os
import time
import math
import json
import six
import random
import gc
impor... | 45,164 | 33.9034 | 84 | py |
CLUE | CLUE-master/baselines/models/xlnet/xlnet.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import json
import os
import tensorflow as tf
import modeling
def _get_initializer(FLAGS):
"""Get variable intializer."""
if FLAGS.init == "uniform":
initializer = tf.initializers.random_uniform(
... | 9,838 | 32.580205 | 82 | py |
CLUE | CLUE-master/baselines/models/xlnet/gpu_utils.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import tensorflow as tf
def assign_to_gpu(gpu=0, ps_dev="/device:CPU:0"):
def _assign(op):
node_def = op if isinstance(op, tf.NodeDef) else op.node_def
if node_def.op == "Variable... | 2,358 | 32.7 | 81 | py |
CLUE | CLUE-master/baselines/models/xlnet/tpu_estimator.py | # Copyright 2017 The TensorFlow Authors. 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 applica... | 138,978 | 38.449049 | 112 | py |
CLUE | CLUE-master/baselines/models/xlnet/__init__.py | 0 | 0 | 0 | py | |
CLUE | CLUE-master/baselines/models/xlnet/summary.py | # -*- coding: utf-8 -*-
'''
print summary
'''
from __future__ import print_function
from collections import Counter, OrderedDict
import string
import re
import argparse
import json
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import pdb
import os
import math
import numpy as np
import collections
from prettyta... | 4,252 | 31.968992 | 147 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/run_classifier_with_tfhub.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 11,426 | 35.27619 | 82 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/optimization.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 6,258 | 34.765714 | 80 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/run_squad.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 46,532 | 35.240654 | 82 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/run_classifier.py | # -*- coding: utf-8 -*-
# @Author: bo.shi
# @Date: 2019-11-04 09:56:36
# @Last Modified by: bo.shi
# @Last Modified time: 2019-12-04 14:30:38
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in... | 36,163 | 36.282474 | 123 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/tf_metrics.py | """
Multiclass
from:
https://github.com/guillaumegenthial/tf_metrics/blob/master/tf_metrics/__init__.py
"""
__author__ = "Guillaume Genthial"
import numpy as np
import tensorflow as tf
from tensorflow.python.ops.metrics_impl import _streaming_confusion_matrix
def precision(labels, predictions, num_classes, pos_in... | 8,188 | 37.088372 | 82 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/tokenization.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 12,257 | 29.645 | 80 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/modeling.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 37,922 | 37.422492 | 93 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/extract_features.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 13,898 | 32.092857 | 82 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/modeling_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 9,191 | 32.064748 | 78 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/conlleval.py | # Python version of the evaluation script from CoNLL'00-
# Originates from: https://github.com/spyysalo/conlleval.py
# Intentional differences:
# - accept any space as delimiter by default
# - optional file argument (default STDIN)
# - option to set boundary (-b argument)
# - LaTeX output (-l argument) not supported
... | 10,196 | 32.99 | 83 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/optimization_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 1,721 | 34.142857 | 76 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/run_ner.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 33,814 | 39.017751 | 227 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/tokenization_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 4,589 | 32.26087 | 80 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/run_pretraining.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 18,667 | 36.789474 | 82 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/__init__.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 616 | 37.5625 | 74 | py |
CLUE | CLUE-master/baselines/models/roberta_wwm_ext/create_pretraining_data.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 16,475 | 34.055319 | 80 | py |
CLUE | CLUE-master/baselines/models/ernie/run_classifier_with_tfhub.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 11,426 | 35.27619 | 82 | py |
CLUE | CLUE-master/baselines/models/ernie/optimization.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 6,258 | 34.765714 | 80 | py |
CLUE | CLUE-master/baselines/models/ernie/run_squad.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 46,532 | 35.240654 | 82 | py |
CLUE | CLUE-master/baselines/models/ernie/run_classifier.py | # -*- coding: utf-8 -*-
# @Author: bo.shi
# @Date: 2019-11-04 09:56:36
# @Last Modified by: bo.shi
# @Last Modified time: 2019-12-04 14:30:20
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in... | 36,142 | 36.299278 | 123 | py |
CLUE | CLUE-master/baselines/models/ernie/tf_metrics.py | """
Multiclass
from:
https://github.com/guillaumegenthial/tf_metrics/blob/master/tf_metrics/__init__.py
"""
__author__ = "Guillaume Genthial"
import numpy as np
import tensorflow as tf
from tensorflow.python.ops.metrics_impl import _streaming_confusion_matrix
def precision(labels, predictions, num_classes, pos_in... | 8,188 | 37.088372 | 82 | py |
CLUE | CLUE-master/baselines/models/ernie/tokenization.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 12,257 | 29.645 | 80 | py |
CLUE | CLUE-master/baselines/models/ernie/modeling.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 37,922 | 37.422492 | 93 | py |
CLUE | CLUE-master/baselines/models/ernie/extract_features.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 13,898 | 32.092857 | 82 | py |
CLUE | CLUE-master/baselines/models/ernie/modeling_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 9,191 | 32.064748 | 78 | py |
CLUE | CLUE-master/baselines/models/ernie/conlleval.py | # Python version of the evaluation script from CoNLL'00-
# Originates from: https://github.com/spyysalo/conlleval.py
# Intentional differences:
# - accept any space as delimiter by default
# - optional file argument (default STDIN)
# - option to set boundary (-b argument)
# - LaTeX output (-l argument) not supported
... | 10,196 | 32.99 | 83 | py |
CLUE | CLUE-master/baselines/models/ernie/optimization_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 1,721 | 34.142857 | 76 | py |
CLUE | CLUE-master/baselines/models/ernie/run_ner.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 33,809 | 39.011834 | 227 | py |
CLUE | CLUE-master/baselines/models/ernie/tokenization_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 4,589 | 32.26087 | 80 | py |
CLUE | CLUE-master/baselines/models/ernie/run_pretraining.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team 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 ... | 18,667 | 36.789474 | 82 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.