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 |
|---|---|---|---|---|---|---|
rankpredictor | rankpredictor-master/sub/gluonts/distribution/box_cox_tranform.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 9,282 | 29.536184 | 113 | py |
rankpredictor | rankpredictor-master/sub/gluonts/distribution/mixture.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 6,791 | 33.477157 | 95 | py |
rankpredictor | rankpredictor-master/sub/gluonts/distribution/lds.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 20,583 | 31.881789 | 109 | py |
rankpredictor | rankpredictor-master/sub/gluonts/distribution/distribution_output.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 5,021 | 29.253012 | 76 | py |
rankpredictor | rankpredictor-master/sub/gluonts/distribution/transformed_distribution_output.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 4,855 | 33.197183 | 81 | py |
rankpredictor | rankpredictor-master/sub/gluonts/distribution/piecewise_linear.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 12,984 | 31.873418 | 116 | py |
rankpredictor | rankpredictor-master/sub/gluonts/support/linalg_util.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 8,278 | 33.932489 | 116 | py |
rankpredictor | rankpredictor-master/sub/gluonts/support/util.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 15,017 | 26.255898 | 85 | py |
rankpredictor | rankpredictor-master/sub/gluonts/gp/gaussian_process.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 14,687 | 36.279188 | 117 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/forecast-raw.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 19,665 | 28.933029 | 99 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/predictor.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 23,995 | 30.994667 | 81 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/forecast_generator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 7,578 | 32.535398 | 105 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/forecast.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 19,676 | 28.949772 | 99 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/common.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 1,091 | 32.090909 | 75 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 7,061 | 30.526786 | 81 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/canonical/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 5,687 | 29.745946 | 79 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/canonical/_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 7,229 | 33.759615 | 79 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepar-original/predictor.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 23,995 | 30.994667 | 81 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepar-original/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 21,761 | 34.85173 | 116 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepar-original/_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 12,645 | 37.090361 | 94 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/simple_feedforward/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 6,491 | 32.989529 | 81 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/simple_feedforward/_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 7,852 | 37.684729 | 108 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepar-inuse/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 21,761 | 34.85173 | 116 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepar-inuse/_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 12,645 | 37.090361 | 94 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepar-savedata/predictor.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 24,040 | 30.969415 | 81 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepar-savedata/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 22,891 | 34.601866 | 116 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepar-savedata/_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 12,645 | 37.090361 | 94 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/wavenet/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 14,582 | 31.121145 | 96 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/wavenet/_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 15,319 | 35.563246 | 106 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepstate/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 9,652 | 33.723022 | 83 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deepstate/_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 14,462 | 38.408719 | 106 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deep_factor/RNNModel.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 1,462 | 28.26 | 75 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/deep_factor/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 6,153 | 30.88601 | 87 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/seq2seq/_seq2seq_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 10,621 | 34.644295 | 79 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/seq2seq/_forking_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 4,527 | 30.013699 | 75 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/seq2seq/_seq2seq_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 6,383 | 31.738462 | 78 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/transformer/trans_encoder.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 3,242 | 33.5 | 118 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/transformer/layers.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 15,991 | 27.506239 | 112 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/transformer/trans_decoder.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 4,259 | 32.543307 | 118 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/transformer/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 16,590 | 33.564583 | 116 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/transformer/_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 12,230 | 37.583596 | 100 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/gp_forecaster/_network.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 9,726 | 33.01049 | 102 | py |
rankpredictor | rankpredictor-master/sub/gluonts/model/gp_forecaster/_estimator.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 8,691 | 38.689498 | 114 | py |
rankpredictor | rankpredictor-master/sub/gluonts/kernels/_kernel_output.py | # Copyright 2018 Amazon.com, Inc. or its affiliates. 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.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license... | 3,541 | 27.111111 | 79 | py |
malware-uncertainty | malware-uncertainty-master/tools/utils.py | from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
import numpy as np
import tensorflow_probability as tfp
import os
import sys
import shutil
import hashlib
import warnings
import functools
from collections import namedtuple, defaultdic... | 17,663 | 32.904031 | 176 | py |
malware-uncertainty | malware-uncertainty-master/core/feature/feature_extraction.py | import os
import multiprocessing
import collections
import warnings
import tempfile
import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from sklearn.cluster import KMeans
from tools import utils
from tools import progressbar_wrapper
from core.ensemble.dataset_lib import build_dataset... | 44,809 | 43.322453 | 115 | py |
malware-uncertainty | malware-uncertainty-master/core/ensemble/deep_ensemble.py | from os import path
import time
import numpy as np
import tensorflow as tf
from core.ensemble.vanilla import Vanilla
from core.ensemble.model_hp import train_hparam
from core.ensemble.dataset_lib import build_dataset_from_numerical_data
from tools import utils
from config import logging, ErrorHandler
logger = loggin... | 11,862 | 44.98062 | 133 | py |
malware-uncertainty | malware-uncertainty-master/core/ensemble/anchor_ensemble.py | import os.path as path
import time
import tensorflow as tf
import numpy as np
from core.ensemble.vanilla import Vanilla
from core.ensemble.model_hp import train_hparam, anchor_hparam
from core.ensemble.model_lib import model_builder
from tools import utils
from config import logging
logger = logging.getLogger('ensem... | 5,238 | 42.658333 | 110 | py |
malware-uncertainty | malware-uncertainty-master/core/ensemble/vanilla.py | import os.path as path
import time
import tensorflow as tf
import numpy as np
from core.ensemble.ensemble import Ensemble
from core.ensemble.model_hp import train_hparam, finetuning_hparam
from core.ensemble.model_lib import model_builder
from tools import utils
from config import logging, ErrorHandler
logger = logg... | 17,864 | 46.387268 | 135 | py |
malware-uncertainty | malware-uncertainty-master/core/ensemble/bayesian_ensemble.py | import time
import tensorflow as tf
from core.ensemble.vanilla import model_builder
from core.ensemble.mc_dropout import MCDropout
from core.ensemble.model_hp import train_hparam, bayesian_ensemble_hparam
from config import logging, ErrorHandler
from tools import utils
logger = logging.getLogger('ensemble.bayesian_e... | 5,667 | 44.709677 | 110 | py |
malware-uncertainty | malware-uncertainty-master/core/ensemble/model_lib.py | """ This script is for building model graph"""
import tensorflow as tf
from tools import utils
from config import logging, ErrorHandler
logger = logging.getLogger('core.ensemble.model_lib')
logger.addHandler(ErrorHandler)
def model_builder(architecture_type='dnn'):
assert architecture_type in model_name_type_d... | 12,509 | 42.741259 | 115 | py |
diaparser | diaparser-master/setup.py | # -*- coding: utf-8 -*-
from setuptools import find_packages, setup
setup(
name='diaparser',
version='1.1.3',
author='Yu Zhang, Giuseppe Attardi',
author_email='yzhang.cs@outlook.com, attardi@di.unipi.it',
description='Direct Attentive Dependency Parser',
long_description=open('README.md', 'r'... | 1,148 | 31.828571 | 85 | py |
diaparser | diaparser-master/diaparser/modules/bert.py | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pad_sequence
from transformers import AutoModel, AutoConfig
from .scalar_mix import ScalarMix
from .dropout import TokenDropout
# from torch.cuda import memory_allocated
class BertEmbedding(nn.Module):
r"""
A module tha... | 8,608 | 46.563536 | 128 | py |
diaparser | diaparser-master/diaparser/modules/lstm.py | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
from .dropout import SharedDropout
from torch.nn.modules.rnn import apply_permutation
from torch.nn.utils.rnn import PackedSequence
class LSTM(nn.Module):
r"""
LSTM is an variant of the vanilla bidirectional LSTM adopted by Biaffine Parser
with t... | 7,586 | 39.790323 | 125 | py |
diaparser | diaparser-master/diaparser/modules/mlp.py | # -*- coding: utf-8 -*-
import torch.nn as nn
from ..modules.dropout import SharedDropout
class MLP(nn.Module):
r"""
Applies a linear transformation together with :class:`~torch.nn.LeakyReLU` activation to the incoming tensor:
:math:`y = \mathrm{LeakyReLU}(x A^T + b)`
Args:
n_in (~torch.Tens... | 1,581 | 26.275862 | 116 | py |
diaparser | diaparser-master/diaparser/modules/affine.py | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
class Biaffine(nn.Module):
def __init__(self, n_in, n_out=1, bias_x=True, bias_y=True):
super(Biaffine, self).__init__()
self.n_in = n_in
self.n_out = n_out
self.bias_x = bias_x
self.bias_y = bias_y
self.... | 1,220 | 26.75 | 64 | py |
diaparser | diaparser-master/diaparser/modules/char_lstm.py | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence
class CharLSTM(nn.Module):
r"""
CharLSTM aims to generate character-level embeddings for tokens.
It summerizes the information of characters in each token to an embedding using a LSTM layer.
... | 2,424 | 32.680556 | 123 | py |
diaparser | diaparser-master/diaparser/modules/dropout.py | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
class SharedDropout(nn.Module):
r"""
SharedDropout differs from the vanilla dropout strategy in that
the dropout mask is shared across one dimension.
Args:
p (float):
The probability of an element to be zeroed. Default: 0... | 3,804 | 26.977941 | 123 | py |
diaparser | diaparser-master/diaparser/modules/matrix_tree_theorem.py | # -*- coding: utf-8 -*-
import torch
import torch.autograd as autograd
import torch.nn as nn
class MatrixTreeTheorem(nn.Module):
def __init__(self, *args, **kwargs):
super(MatrixTreeTheorem, self).__init__(*args, **kwargs)
@torch.enable_grad()
def forward(self, scores, mask, target=None):
... | 1,329 | 33.102564 | 79 | py |
diaparser | diaparser-master/diaparser/modules/scalar_mix.py | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
class ScalarMix(nn.Module):
r"""
Computes a parameterised scalar mixture of :math:`N` tensors, :math:`mixture = \gamma * \sum_{k}(s_k * tensor_k)`
where :math:`s = \mathrm{softmax}(w)`, with :math:`w` and :math:`\gamma` scalar parameters.
Ar... | 1,679 | 30.698113 | 117 | py |
diaparser | diaparser-master/diaparser/models/dependency.py | # -*- coding: utf-8 -*-
import torch
import torch.nn as nn
from ..modules import MLP, BertEmbedding, Biaffine, LSTM, CharLSTM
from ..modules.dropout import IndependentDropout, SharedDropout
from ..utils.config import Config
from ..utils.alg import eisner, mst
from ..utils.transform import CoNLL
from torch.nn.utils.rnn... | 15,848 | 42.541209 | 117 | py |
diaparser | diaparser-master/diaparser/utils/embedding.py | # -*- coding: utf-8 -*-
import torch
class Embedding():
def __init__(self, tokens, vectors, unk=None):
self.tokens = tokens
self.vectors = torch.tensor(vectors)
self.pretrained = {w: v for w, v in zip(tokens, vectors)}
self.unk = unk
def __len__(self):
return len(sel... | 982 | 23.575 | 65 | py |
diaparser | diaparser-master/diaparser/utils/field.py | # -*- coding: utf-8 -*-
from collections import Counter
from ..utils.fn import pad
from ..utils.vocab import Vocab, FieldVocab
import torch
from typing import List
class RawField():
r"""
Defines a general datatype.
A :class:`RawField` object does not assume any property of the datatype and
it holds... | 15,427 | 35.733333 | 117 | py |
diaparser | diaparser-master/diaparser/utils/alg.py | # -*- coding: utf-8 -*-
import torch
from ..utils.fn import pad, stripe
def kmeans(x, k, max_it=32):
r"""
KMeans algorithm for clustering the sentences by length.
Args:
x (list[int]):
The list of sentence lengths.
k (int):
The number of clusters.
This ... | 24,571 | 39.150327 | 120 | py |
diaparser | diaparser-master/diaparser/utils/fn.py | # -*- coding: utf-8 -*-
import unicodedata
def ispunct(token):
return all(unicodedata.category(char).startswith('P')
for char in token)
def isfullwidth(token):
return all(unicodedata.east_asian_width(char) in ['W', 'F', 'A']
for char in token)
def islatin(token):
return ... | 3,344 | 29.135135 | 78 | py |
diaparser | diaparser-master/diaparser/utils/data.py | # -*- coding: utf-8 -*-
from collections import namedtuple
import torch
import torch.distributed as dist
from ..utils.alg import kmeans
class Dataset(torch.utils.data.Dataset):
r"""
Dataset that is compatible with :class:`torch.utils.data.Dataset`.
This serves as a wrapper for manipulating all data fiel... | 7,112 | 40.354651 | 120 | py |
diaparser | diaparser-master/diaparser/utils/parallel.py | # -*- coding: utf-8 -*-
import os
from random import Random
import torch
import torch.distributed as dist
import torch.nn as nn
class DistributedDataParallel(nn.parallel.DistributedDataParallel):
def __init__(self, module, **kwargs):
super().__init__(module, **kwargs)
def __getattr__(self, name):
... | 1,071 | 28.777778 | 90 | py |
diaparser | diaparser-master/diaparser/parsers/parser.py | # -*- coding: utf-8 -*-
import os
from datetime import datetime, timedelta
import torch
import torch.distributed as dist
from .. import parsers
from tokenizer.tokenizer import Tokenizer
from ..catalog import select
from ..utils import Config, Dataset
from ..utils.field import Field, BertField
from ..utils.logging imp... | 11,478 | 38.582759 | 125 | py |
diaparser | diaparser-master/diaparser/parsers/biaffine_dependency.py | # -*- coding: utf-8 -*-
import os
import torch
import torch.nn as nn
from ..models import BiaffineDependencyModel
from .parser import Parser
from ..utils import Config, Dataset, Embedding
from ..utils.common import bos, pad, unk
from ..utils.field import Field, SubwordField, BertField
from ..utils.fn import ispunct
f... | 11,647 | 40.6 | 117 | py |
diaparser | diaparser-master/diaparser/cmds/cmd.py | # -*- coding: utf-8 -*-
import torch
from ..utils import Config
from ..utils.logging import init_logger, logger
from ..utils.parallel import init_device
from ..parsers.biaffine_dependency import BiaffineDependencyParser as Parser
def parse(argparser):
argparser.add_argument('--conf', '-c', help='path to config f... | 1,727 | 43.307692 | 107 | py |
diaparser | diaparser-master/tokenizer/tokenizer.py |
import stanza
import torch
import json
import os
from contextlib import contextmanager
from diaparser.catalog import available_processors, download_processors
# reference https://github.com/stanfordnlp/stanza/blob/master/stanza/utils/prepare_tokenizer_data.py
class Tokenizer:
"""
Interface to Stanza tokenize... | 3,617 | 37.084211 | 100 | py |
diaparser | diaparser-master/docs/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 3,158 | 33.336957 | 79 | py |
EditNTS | EditNTS-master/main.py | #!/usr/bin/env python
# coding:utf8
from __future__ import print_function
import argparse
import collections
import logging
import numpy as np
import torch
import torch.nn as nn
import data
from checkpoint import Checkpoint
from editnts import EditNTS
from evaluator import Evaluator
PAD = 'PAD' # This has a vocab... | 10,186 | 38.792969 | 135 | py |
EditNTS | EditNTS-master/checkpoint.py | from __future__ import print_function
import os
import time
import shutil
import torch
class Checkpoint(object):
"""
The Checkpoint class manages the saving and loading of a model during training. It allows training to be suspended
and resumed at a later time (e.g. when running on a cluster using sequenti... | 6,074 | 42.705036 | 129 | py |
EditNTS | EditNTS-master/data.py | from collections import Counter
import glob
import random
import struct
import csv
import pandas as pd
import numpy as np
import os
import torch
from torch.autograd import Variable
import random
import pickle
# <s> and </s> are used in the vocab_data files to segment the abstracts into sentences. They don't receive vo... | 9,193 | 38.459227 | 160 | py |
EditNTS | EditNTS-master/evaluator.py | import numpy as np
import torch
from nltk.translate.bleu_score import *
smooth = SmoothingFunction()
from SARI import SARIsent
import nltk
import data
nltk.data.path.append("/media/nvme/nltk_data")
from label_edits import edit2sent
def sort_by_lens(seq, seq_lengths):
seq_lengths_sorted, sort_order = seq_lengths.... | 5,720 | 45.893443 | 154 | py |
EditNTS | EditNTS-master/editnts.py | from __future__ import unicode_literals, print_function, division
import random
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
use_cuda = torch.cuda.is_available()
import data
from torch.nn.utils.rnn import pack_padded_sequence as pack
from t... | 21,683 | 46.344978 | 156 | py |
patchNR | patchNR-master/train_patchNR.py | # This code belongs to the paper
#
# F. Altekrüger, A. Denker, P. Hagemann, J. Hertrich, P. Maass and G. Steidl (2023).
# PatchNR: Learning from Very Few Images by Patch Normalizing Flow Regularization.
# Inverse Problems, vol. 39, no. 6.
#
# Please cite the paper, if you use the code.
# The script trains the patchNR
... | 3,300 | 36.089888 | 137 | py |
patchNR | patchNR-master/patchNR_CT.py | # This code belongs to the paper
#
# F. Altekrüger, A. Denker, P. Hagemann, J. Hertrich, P. Maass and G. Steidl (2023).
# PatchNR: Learning from Very Few Images by Patch Normalizing Flow Regularization.
# Inverse Problems, vol. 39, no. 6.
#
# Please cite the paper, if you use the code.
#
# The script reproduces the num... | 4,204 | 32.110236 | 94 | py |
patchNR | patchNR-master/utils.py | # This code belongs to the paper
#
# F. Altekrüger, A. Denker, P. Hagemann, J. Hertrich, P. Maass and G. Steidl (2023).
# PatchNR: Learning from Very Few Images by Patch Normalizing Flow Regularization.
# Inverse Problems, vol. 39, no. 6.
#
# Please cite the paper, if you use the code.
# The functions are adapted from ... | 3,773 | 33.623853 | 117 | py |
patchNR | patchNR-master/model.py | # This code belongs to the paper
#
# F. Altekrüger, A. Denker, P. Hagemann, J. Hertrich, P. Maass and G. Steidl (2023).
# PatchNR: Learning from Very Few Images by Patch Normalizing Flow Regularization.
# Inverse Problems, vol. 39, no. 6.
#
# Please cite the paper, if you use the code.
import torch
from torch import n... | 1,431 | 33.926829 | 84 | py |
patchNR | patchNR-master/patchNR_zeroshot_material.py | # This code belongs to the paper
#
# F. Altekrüger, A. Denker, P. Hagemann, J. Hertrich, P. Maass and G. Steidl (2023).
# PatchNR: Learning from Very Few Images by Patch Normalizing Flow Regularization.
# Inverse Problems, vol. 39, no. 6.
#
# Please cite the paper, if you use the code.
#
# The script reproduces the zer... | 4,456 | 32.261194 | 102 | py |
patchNR | patchNR-master/patchNR_deblurring.py | # This code belongs to the paper
#
# F. Altekrüger, A. Denker, P. Hagemann, J. Hertrich, P. Maass and G. Steidl (2023).
# PatchNR: Learning from Very Few Images by Patch Normalizing Flow Regularization.
# Inverse Problems, vol. 39, no. 6.
#
# Please cite the paper, if you use the code.
#
# The script reproduces the num... | 3,142 | 29.813725 | 108 | py |
patchNR | patchNR-master/patchNR_zeroshot.py | # This code belongs to the paper
#
# F. Altekrüger, A. Denker, P. Hagemann, J. Hertrich, P. Maass and G. Steidl (2023).
# PatchNR: Learning from Very Few Images by Patch Normalizing Flow Regularization.
# Inverse Problems, vol. 39, no. 6.
#
# Please cite the paper, if you use the code.
#
# The script reproduces the zer... | 4,439 | 31.888889 | 102 | py |
patchNR | patchNR-master/patchNR_superres.py | # This code belongs to the paper
#
# F. Altekrüger, A. Denker, P. Hagemann, J. Hertrich, P. Maass and G. Steidl (2023).
# PatchNR: Learning from Very Few Images by Patch Normalizing Flow Regularization.
# Inverse Problems, vol. 39, no. 6.
#
# Please cite the paper, if you use the code.
#
# The script reproduces the num... | 2,928 | 28.887755 | 132 | py |
AxiCLASS | AxiCLASS-master/external_fz/sphinx-documentation/conf.py | # -*- coding: utf-8 -*-
#
# DarkAges documentation build configuration file, created by
# sphinx-quickstart on Tue Jun 20 22:50:36 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# ... | 6,269 | 29.585366 | 82 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/blue_strip_model.py | """
Usage:
blue_strip_model <src> <dest>
"""
import logging
import os
import docopt
import torch
def main():
args = docopt.docopt(__doc__)
print(args)
if not os.path.exists(args['<src>']):
logging.error('%s: Cannot find the model', args['<src>'])
map_location = 'cpu' if not torch.cuda.i... | 1,149 | 29.263158 | 117 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/blue_prepro_std.py | """
Preprocessing BLUE dataset.
Usage:
blue_prepro_std [options] --vocab=<file> --root_dir=<dir> --task_def=<file> --datasets=<str>
Options:
--do_lower_case
--max_seq_len=<int> [default: 128]
--overwrite
"""
# Copyright (c) Microsoft. All rights reserved.
# Modified by Yifan Peng
import json
imp... | 17,889 | 41.901679 | 119 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/blue_train.py | # Copyright (c) Microsoft. All rights reserved.
# Modified by Yifan Peng
import argparse
import copy
import json
import os
import random
from datetime import datetime
import numpy as np
import torch
from pytorch_pretrained_bert.modeling import BertConfig
from tensorboardX import SummaryWriter
# from experiments.glue.... | 19,152 | 42.332579 | 111 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/mt_dnn/batcher.py | # coding=utf-8
# Copyright (c) Microsoft. All rights reserved.
import sys
import json
import torch
import random
from shutil import copyfile
from mt_bluebert.data_utils.task_def import TaskType, DataFormat
from mt_bluebert.data_utils.task_def import EncoderModelType
UNK_ID=100
BOS_ID=101
class BatchGen:
def __ini... | 9,667 | 42.54955 | 136 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/mt_dnn/matcher.py | # coding=utf-8
# Copyright (c) Microsoft. All rights reserved.
import torch.nn as nn
from pytorch_pretrained_bert.modeling import BertConfig, BertLayerNorm, BertModel
from mt_bluebert.module.dropout_wrapper import DropoutWrapper
from mt_bluebert.module.san import SANClassifier
from mt_bluebert.data_utils.task_def impo... | 5,873 | 44.890625 | 119 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/mt_dnn/model.py | # coding=utf-8
# Copyright (c) Microsoft. All rights reserved.
import logging
import sys
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.optim.lr_scheduler import *
from mt_bluebert.data_utils.utils import AverageMeter
from pytorch_pretrained... | 14,345 | 43.006135 | 133 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/module/my_optim.py | # Copyright (c) Microsoft. All rights reserved.
from copy import deepcopy
import torch
from torch.nn import Parameter
from functools import wraps
class EMA:
def __init__(self, gamma, model):
super(EMA, self).__init__()
self.gamma = gamma
self.shadow = {}
self.model = model
s... | 3,836 | 33.258929 | 94 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/module/bert_optim.py | # Copyright (c) Microsoft. All rights reserved.
import math
import torch
from torch.optim import Optimizer
from torch.nn.utils import clip_grad_norm_
from pytorch_pretrained_bert.optimization import warmup_constant, warmup_cosine, warmup_linear
def warmup_linear_xdl(x, warmup=0.002):
if x < warmup:
return ... | 11,825 | 41.847826 | 190 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/module/similarity.py | # Copyright (c) Microsoft. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy
from torch.nn.utils import weight_norm
from torch.nn.parameter import Parameter
from .common import activation, init_wrapper
from .dropout_wrapper import DropoutWrapper
class DotProduct(nn.Mo... | 23,222 | 40.030035 | 135 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/module/dropout_wrapper.py | # Copyright (c) Microsoft. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
class DropoutWrapper(nn.Module):
"""
This is a dropout wrapper which supports the fix mask dropout
"""
def __init__(self, dropout_p=0, enable_vbp=True):
super(DropoutWrapper, self)... | 1,074 | 33.677419 | 130 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/module/common.py | # Copyright (c) Microsoft. All rights reserved.
import torch
import math
from torch.nn.functional import tanh, relu, prelu, leaky_relu, sigmoid, elu, selu
from torch.nn.init import uniform, normal, eye, xavier_uniform, xavier_normal, kaiming_uniform, kaiming_normal, orthogonal
def linear(x):
return x
def swish(x)... | 782 | 22.727273 | 122 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/module/sub_layers.py | # Copyright (c) Microsoft. All rights reserved.
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
class LayerNorm(nn.Module):
#ref: https://github.com/pytorch/pytorch/issues/1959
# :https://arxiv.org/pdf/1607.06450.pdf
def __init__(self, hidden_si... | 905 | 32.555556 | 95 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/module/san.py | # Copyright (c) Microsoft. All rights reserved.
import torch
import random
import torch.nn as nn
from torch.nn.utils import weight_norm
from torch.nn.parameter import Parameter
import torch.nn.functional as F
from mt_bluebert.module.dropout_wrapper import DropoutWrapper
from mt_bluebert.module.similarity import FlatSim... | 4,721 | 41.540541 | 134 | py |
bluebert | bluebert-master/mt-bluebert/mt_bluebert/experiments/squad/verify_calc_span.py | from pytorch_pretrained_bert import BertTokenizer
from data_utils.task_def import EncoderModelType
from experiments.squad.squad_utils import calc_tokenized_span_range, parse_squad_label
model = "bert-base-uncased"
do_lower_case = True
tokenizer = BertTokenizer.from_pretrained(model, do_lower_case=do_lower_case)
for n... | 751 | 46 | 116 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.