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
baconian-project
baconian-project-master/baconian/algo/dynamics/__init__.py
0
0
0
py
baconian-project
baconian-project-master/baconian/algo/dynamics/gaussian_process_dynamiocs_model.py
from baconian.core.core import EnvSpec from baconian.algo.dynamics.dynamics_model import TrainableDyanmicsModel, LocalDyanmicsModel import gpflow import numpy as np from baconian.common.sampler.sample_data import TransitionData from baconian.algo.dynamics.third_party.mgpr import MGPR import tensorflow as tf from baconi...
3,282
48
117
py
baconian-project
baconian-project-master/baconian/algo/dynamics/third_party/mgpr.py
""" Code from https://github.com/nrontsis/PILCO """ import tensorflow as tf import gpflow import numpy as np from typeguard import typechecked float_type = gpflow.settings.dtypes.float_type def randomize(model): mean = 1 sigma = 0.01 model.kern.lengthscales.assign( mean + sigma * np.random.norm...
7,423
37.071795
105
py
baconian-project
baconian-project-master/baconian/algo/dynamics/third_party/gmm.py
""" This file defines a Gaussian mixture model class. """ import logging import numpy as np import scipy.linalg from copy import deepcopy LOGGER = logging.getLogger(__name__) def logsum(vec, axis=0, keepdims=True): # TODO: Add a docstring. maxv = np.max(vec, axis=axis, keepdims=keepdims) maxv[maxv == -f...
7,345
33.650943
104
py
baconian-project
baconian-project-master/baconian/algo/dynamics/third_party/__init__.py
# Date: 3/30/19 # Author: Luke # Project: baconian-internal
59
19
28
py
baconian-project
baconian-project-master/baconian/algo/dynamics/reward_func/__init__.py
0
0
0
py
baconian-project
baconian-project-master/baconian/algo/dynamics/reward_func/reward_func.py
from baconian.core.core import Basic import abc import numpy as np class RewardFunc(Basic): allow_duplicate_name = True def __init__(self, name='reward_func'): super().__init__(name=name) @abc.abstractmethod def __call__(self, state, action, new_state, **kwargs) -> float: raise NotIm...
2,146
27.25
98
py
baconian-project
baconian-project-master/baconian/algo/dynamics/terminal_func/terminal_func.py
from baconian.core.core import Basic import abc import numpy as np class TerminalFunc(Basic): allow_duplicate_name = True def __init__(self, name='terminal_func'): super().__init__(name=name) @abc.abstractmethod def __call__(self, state, action, new_state, **kwargs) -> bool: raise No...
1,189
25.444444
82
py
baconian-project
baconian-project-master/baconian/algo/dynamics/terminal_func/__init__.py
0
0
0
py
baconian-project
baconian-project-master/baconian/algo/distribution/mvn.py
""" Module that compute diagonal multivariate normal distribution operation with tensorflow tensor as parameters """ import tensorflow as tf import numpy as np def kl(mean_p, var_p, mean_q, var_q, dims): """ Compute the KL divergence of diagonal multivariate normal distribution q, and p, which is KL(P||Q) ...
1,439
29.638298
114
py
baconian-project
baconian-project-master/baconian/algo/distribution/__init__.py
0
0
0
py
baconian-project
baconian-project-master/baconian/algo/value_func/mlp_q_value.py
import typeguard as tg from baconian.core.core import EnvSpec import overrides import tensorflow as tf from baconian.tf.tf_parameters import ParametersWithTensorflowVariable from baconian.tf.mlp import MLP from baconian.common.special import * from baconian.core.util import init_func_arg_record_decorator from baconian....
5,335
41.349206
100
py
baconian-project
baconian-project-master/baconian/algo/value_func/__init__.py
from .value_func import ValueFunction, QValueFunction, VValueFunction from .mlp_q_value import MLPQValueFunction from .mlp_v_value import MLPVValueFunc
152
37.25
69
py
baconian-project
baconian-project-master/baconian/algo/value_func/value_func.py
from baconian.core.core import Basic, EnvSpec import typeguard as tg from baconian.core.parameters import Parameters import abc class ValueFunction(Basic): @tg.typechecked def __init__(self, env_spec: EnvSpec, parameters: Parameters = None, name='value_func'): super().__init__(name) self.env_...
1,733
29.421053
119
py
baconian-project
baconian-project-master/baconian/algo/value_func/mlp_v_value.py
import typeguard as tg from baconian.core.core import EnvSpec import overrides import tensorflow as tf from baconian.tf.tf_parameters import ParametersWithTensorflowVariable from baconian.tf.mlp import MLP from baconian.common.special import * from baconian.algo.utils import _get_copy_arg_with_tf_reuse from baconian.al...
4,350
37.848214
91
py
baconian-project
baconian-project-master/baconian/algo/misc/sample_processor.py
from baconian.common.sampler.sample_data import TransitionData, TrajectoryData from baconian.algo.value_func import ValueFunction import scipy.signal from baconian.common.special import * def discount(x, gamma): """code clip from pat-cody""" """ Calculate discounted forward sum of a sequence at each point """...
3,808
47.21519
120
py
baconian-project
baconian-project-master/baconian/algo/misc/epsilon_greedy.py
from baconian.common.spaces.base import Space import numpy as np from typeguard import typechecked from baconian.core.parameters import Parameters from baconian.common.schedules import Scheduler class ExplorationStrategy(object): def __init__(self): self.parameters = None def predict(self, **kwargs):...
1,158
32.114286
103
py
baconian-project
baconian-project-master/baconian/algo/misc/__init__.py
from .replay_buffer import BaseReplayBuffer, UniformRandomReplayBuffer from .epsilon_greedy import ExplorationStrategy, EpsilonGreedy from .placeholder_input import PlaceholderInput, MultiPlaceholderInput from .sample_processor import SampleProcessor
251
49.4
70
py
baconian-project
baconian-project-master/baconian/algo/misc/replay_buffer.py
import numpy as np from typeguard import typechecked from baconian.common.sampler.sample_data import TransitionData, TrajectoryData, SampleData from baconian.common.error import * class RingBuffer(object): @typechecked def __init__(self, maxlen: int, shape: (list, tuple), dtype='float32'): self.maxlen...
6,768
35.989071
102
py
baconian-project
baconian-project-master/baconian/algo/misc/placeholder_input.py
import tensorflow as tf import typeguard as tg import os from baconian.common.logging import ConsoleLogger from baconian.tf.tf_parameters import ParametersWithTensorflowVariable from baconian.core.core import Basic from baconian.config.global_config import GlobalConfig class PlaceholderInput(object): @tg.typeche...
4,758
48.061856
116
py
baconian-project
baconian-project-master/baconian/tf/tensor_utils.py
from collections import Iterable from collections import namedtuple import numpy as np import tensorflow as tf def compile_function(inputs, outputs, log_name=None): def run(*input_vals): sess = tf.get_default_session() return sess.run(outputs, feed_dict=dict(list(zip(inputs, input_vals)))) r...
7,669
31.362869
79
py
baconian-project
baconian-project-master/baconian/tf/tf_parameters.py
import tensorflow as tf from baconian.core.parameters import Parameters from baconian.config.global_config import GlobalConfig from overrides.overrides import overrides from typeguard import typechecked import os from baconian.common.schedules import Scheduler import numpy as np class ParametersWithTensorflowVariable...
9,734
44.27907
117
py
baconian-project
baconian-project-master/baconian/tf/mlp.py
from typeguard import typechecked from baconian.tf.util import MLPCreator import tensorflow as tf import numpy as np from baconian.tf.tf_parameters import ParametersWithTensorflowVariable class MLP(object): @typechecked def __init__(self, input_ph: tf.Tensor, name_scope: str...
2,861
46.7
114
py
baconian-project
baconian-project-master/baconian/tf/util.py
import os import tensorflow as tf from tensorflow.contrib.layers import variance_scaling_initializer as contrib_W_init from typeguard import typechecked import collections import multiprocessing import tensorflow.contrib as tf_contrib from baconian.common.error import * __all__ = ['get_tf_collection_var_list', 'MLPCr...
6,416
40.941176
132
py
baconian-project
baconian-project-master/baconian/tf/__init__.py
0
0
0
py
baconian-project
baconian-project-master/docs/conf.py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path setup ------------------------------------------------------------...
6,083
28.970443
101
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/run_slot_filling_evaluation.py
# coding:utf-8 import argparse import json from source.Evaluate.slot_filling import prepare_data_to_dukehan, prepare_data_to_conll_format from source.Evaluate.slot_filling_data_processor import cook_slot_filling_data from set_config import refresh_config_file import copy import subprocess # ============ Args Process =...
4,041
47.119048
188
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/run_clustering.py
# coding:utf-8 from source.Cluster import clustering from source.Cluster import conll_format_clustering # from source.Cluster.clustering import slot_clustering_and_dump_dict import argparse import json from set_config import refresh_config_file # ============ Args Process ========== parser = argparse.ArgumentParser()...
1,821
38.608696
144
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/run_onmt_generation.py
# coding:utf-8 import json import os import copy import subprocess import argparse from source.AuxiliaryTools.nlp_tool import low_case_tokenizer, sentence_edit_distance from source.ReFilling.re_filling import re_filling import math from collections import Counter import random from itertools import combinations from se...
14,067
48.886525
200
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/run_thesaurus.py
# coding: utf-8 import json import argparse from source.AuxiliaryTools.nlp_tool import low_case_tokenizer, sentence_edit_distance from source.ReFilling.re_filling import re_filling from set_config import refresh_config_file # ============ Description ========== # refill source file to test refill only # ============ ...
2,090
44.456522
189
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/run_aug_baseline_slot_filling_for.py
# coding:utf-8 import argparse import json from source.Evaluate.slot_filling import prepare_data_to_dukehan, prepare_data_to_conll_format from source.Evaluate.slot_filling_data_processor import cook_slot_filling_data from set_config import refresh_config_file import copy import subprocess # ============ Args Process =...
4,786
59.594937
188
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/run_gen_with_label.py
# coding:utf-8 import json import os import copy import subprocess import argparse from source.AuxiliaryTools.nlp_tool import low_case_tokenizer, sentence_edit_distance from source.ReFilling.re_filling import re_filling import math from collections import Counter import random from itertools import combinations from se...
8,920
46.452128
128
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/set_config.py
# coding:utf-8 from source.AuxiliaryTools.ConfigTool import update_config def refresh_config_file(config_path='./config.json'): print('Config Position:', config_path) # For my linux server setting update_config("/users4/ythou/Projects/TaskOrientedDialogue/data/", config_path=config_path) # For my wind...
486
33.785714
99
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/run_gen_evaluation.py
# coding: utf-8 import argparse import json from source.Evaluate.gen_eval import appearance_check from set_config import refresh_config_file import copy import subprocess from multiprocessing import Process, Queue, current_process, freeze_support, Manager N_THREAD = 20 # ============ Args Process ========== parser = ...
5,770
35.99359
177
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/setup.py
#!/usr/bin/env python from setuptools import setup setup(name='OpenNMT', description='A python implementation of OpenNMT', version='0.1', packages=['onmt', 'onmt.modules'])
193
20.555556
55
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/opts.py
import argparse from onmt.modules.SRU import CheckSRU def model_opts(parser): """ These options are passed to the construction of the model. Be careful with these as they will be used during translation. """ # Model options parser.add_argument('-model_type', default='text', ...
17,059
48.449275
84
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/translate.py
#!/usr/bin/env python from __future__ import division from builtins import bytes import os import argparse import math import codecs import torch import onmt import onmt.IO import opts from itertools import takewhile, count try: from itertools import zip_longest except ImportError: from itertools import izip_...
4,516
32.708955
79
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/train.py
#!/usr/bin/env python from __future__ import division import os import sys import argparse import torch import torch.nn as nn from torch import cuda import onmt import onmt.Models import onmt.ModelConstructor import onmt.modules from onmt.Utils import aeq, use_gpu import opts parser = argparse.ArgumentParser( d...
10,352
31.556604
120
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/preprocess.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import argparse import codecs import torch import onmt import onmt.IO import opts parser = argparse.ArgumentParser( description='preprocess.py', formatter_class=argparse.ArgumentDefaultsHelpFormatter) opts.add_md_help_argument(parser) # **Preprocess Options** p...
3,411
34.915789
77
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/tools/extract_embeddings.py
from __future__ import division import torch import argparse from onmt.ModelConstructor import make_embeddings, \ make_encoder, make_decoder parser = argparse.ArgumentParser(description='translate.py') parser.add_argument('-model', required=True, help='Path to model ....
1,987
30.0625
70
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/test/test_simple.py
import onmt def test_load(): onmt pass
49
6.142857
16
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/test/test_models.py
import argparse import copy import unittest import torch from torch.autograd import Variable import onmt import opts from onmt.ModelConstructor import make_embeddings, \ make_encoder, make_decoder parser = argparse.ArgumentParser(description='train.py') opts.model_opts(parser) opts.train_...
7,275
32.84186
79
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/test/test_preprocess.py
import argparse import copy import unittest import onmt import opts import torchtext from collections import Counter parser = argparse.ArgumentParser(description='preprocess.py') opts.preprocess_opts(parser) opt = parser.parse_known_args()[0] opt.train_src = 'data/src-train.txt' opt.train_tgt = 'data/tgt-train.txt...
3,317
30.009346
79
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/test/__init__.py
0
0
0
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/test/test_attention.py
""" Here come the tests for attention types and their compatibility """
72
17.25
63
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/Loss.py
""" This file handles the details of the loss function during training. This includes: LossComputeBase and the standard NMTLossCompute, and sharded loss compute stuff. """ from __future__ import division import torch import torch.nn as nn from torch.autograd import Variable import onmt class LossComp...
6,611
34.548387
78
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/Beam.py
from __future__ import division import torch import onmt """ Class for managing the internals of the beam search process. Takes care of beams, back pointers, and scores. """ class Beam(object): def __init__(self, size, n_best=1, cuda=False, vocab=None, global_scorer=None): self.size ...
5,428
32.512346
77
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/Translator.py
import torch from torch.autograd import Variable import onmt import onmt.Models import onmt.ModelConstructor import onmt.modules import onmt.IO from onmt.Utils import use_gpu NOISE_TRANSELATE = False class Translator(object): def __init__(self, opt, dummy_opt={}): # Add in default model arguments, poss...
8,875
36.610169
122
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/Utils.py
def aeq(*args): """ Assert all arguments have the same value """ arguments = (arg for arg in args) first = next(arguments) assert all(arg == first for arg in arguments), \ "Not all arguments have the same value: " + str(args) def use_gpu(opt): return (hasattr(opt, 'gpuid') and len(...
388
26.785714
62
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/IO.py
# -*- coding: utf-8 -*- import codecs from collections import Counter, defaultdict from itertools import chain, count import torch import torchtext.data import torchtext.vocab PAD_WORD = '<blank>' UNK = 0 BOS_WORD = '<s>' EOS_WORD = '</s>' def __getstate__(self): return dict(self.__dict__, stoi=dict(self.stoi)...
14,171
33.231884
78
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/ModelConstructor.py
""" This file is for models creation, which consults options and creates each encoder and decoder accordingly. """ import torch.nn as nn import onmt import onmt.Models import onmt.modules from onmt.Models import NMTModel, MeanEncoder, RNNEncoder, \ StdRNNDecoder, InputFeedRNNDecoder from onmt.m...
7,331
37.589474
76
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/__init__.py
import onmt.IO import onmt.Models import onmt.Loss from onmt.Trainer import Trainer, Statistics from onmt.Translator import Translator from onmt.Optim import Optim from onmt.Beam import Beam, GNMTGlobalScorer # For flake8 compatibility __all__ = [onmt.Loss, onmt.IO, onmt.Models, Trainer, Translator, Optim,...
357
26.538462
64
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/Trainer.py
from __future__ import division """ This is the loadable seq2seq trainer library that is in charge of training details, loss compute, and statistics. See train.py for a use case of this library. Note!!! To make this a general library, we implement *only* mechanism things here(i.e. what to do), and leave the strategy t...
6,823
33.994872
78
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/Optim.py
import torch.optim as optim from torch.nn.utils import clip_grad_norm class Optim(object): def set_parameters(self, params): self.params = [p for p in params if p.requires_grad] if self.method == 'sgd': self.optimizer = optim.SGD(self.params, lr=self.lr) elif self.method == 'a...
2,490
33.123288
76
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/Models.py
from __future__ import division import torch import torch.nn as nn from torch.autograd import Variable from torch.nn.utils.rnn import pack_padded_sequence as pack from torch.nn.utils.rnn import pad_packed_sequence as unpack import onmt from onmt.Utils import aeq class EncoderBase(nn.Module): """ EncoderBase ...
18,492
36.209256
79
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/ConvMultiStepAttention.py
import torch import torch.nn as nn import torch.nn.functional as F from onmt.Utils import aeq SCALE_WEIGHT = 0.5 ** 0.5 def seq_linear(linear, x): # linear transform for 3-d tensor batch, hidden_size, length, _ = x.size() h = linear(torch.transpose(x, 1, 2).contiguous().view( batch * length, hid...
2,610
34.767123
77
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/Transformer.py
""" Implementation of "Attention is All You Need" """ import torch import torch.nn as nn from torch.autograd import Variable import numpy as np import onmt from onmt.Models import EncoderBase from onmt.Models import DecoderState from onmt.Utils import aeq MAX_SIZE = 5000 class PositionwiseFeedForward(nn.Module): ...
11,553
36.391586
79
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/Embeddings.py
import torch import torch.nn as nn from torch.autograd import Variable from onmt.modules import BottleLinear, Elementwise from onmt.Utils import aeq class PositionalEncoding(nn.Module): def __init__(self, dropout, dim, max_len=5000): pe = torch.arange(0, max_len).unsqueeze(1).expand(max_len, dim) ...
5,928
39.609589
77
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/CopyGenerator.py
import torch.nn as nn import torch.nn.functional as F import torch import torch.cuda import onmt from onmt.Utils import aeq class CopyGenerator(nn.Module): """ Generator module that additionally considers copying words directly from the source. """ def __init__(self, opt, src_dict, tgt_dict): ...
5,090
34.852113
78
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/StackedRNN.py
import torch import torch.nn as nn class StackedLSTM(nn.Module): """ Our own implementation of stacked LSTM. Needed for the decoder, because we do input feeding. """ def __init__(self, num_layers, input_size, rnn_size, dropout): super(StackedLSTM, self).__init__() self.dropout = nn...
1,755
28.266667
66
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/MultiHeadedAttn.py
import math import torch import torch.nn as nn from torch.autograd import Variable from onmt.Utils import aeq from onmt.modules.UtilClass import BottleLinear, \ BottleLayerNorm, BottleSoftmax class MultiHeadedAttention(nn.Module): ''' Multi-Head Attention module from "Attention is All...
3,966
34.738739
74
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/Gate.py
""" Context gate is a decoder module that takes as input the previous word embedding, the current decoder state and the attention state, and produces a gate. The gate can be used to select the input from the target side context (decoder state), from the source context (attention state) or both. """ import torch import ...
3,596
38.527473
78
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/UtilClass.py
import torch import torch.nn as nn class Bottle(nn.Module): def forward(self, input): if len(input.size()) <= 2: return super(Bottle, self).forward(input) size = input.size()[:2] out = super(Bottle, self).forward(input.view(size[0]*size[1], -1)) ...
2,769
30.123596
78
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/StructuredAttention.py
import torch.nn as nn import torch import torch.cuda from torch.autograd import Variable class MatrixTree(nn.Module): """Implementation of the matrix-tree theorem for computing marginals of non-projective dependency parsing. This attention layer is used in the paper "Learning Structured Text Representatio...
1,556
33.6
77
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/Conv2Conv.py
""" Implementation of "Convolutional Sequence to Sequence Learning" """ import torch import torch.nn as nn import torch.nn.init as init import torch.nn.functional as F from torch.autograd import Variable import onmt.modules from onmt.modules.WeightNorm import WeightNormConv2d from onmt.Models import EncoderBase from o...
8,557
35.57265
79
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/GlobalAttention.py
import torch import torch.nn as nn from onmt.modules.UtilClass import BottleLinear from onmt.Utils import aeq class GlobalAttention(nn.Module): """ Luong Attention. Global attention takes a matrix and a query vector. It then computes a parameterized convex combination of the matrix based on the ...
6,419
32.968254
79
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/SRU.py
""" Implementation of "Training RNNs as Fast as CNNs". TODO: turn to pytorch's implementation when it is available. This implementation is adpoted from the author of the paper: https://github.com/taolei87/sru/blob/master/cuda_functional.py. """ import subprocess import platform import os import re import argparse impo...
23,318
36.672052
79
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/WeightNorm.py
""" Implementation of "Weight Normalization: A Simple Reparameterization to Accelerate Training of Deep Neural Networks" As a reparameterization method, weight normalization is same as BatchNormalization, but it doesn't depend on minibatch. """ import torch import torch.nn as nn import torch.nn.functional as F from tor...
9,574
39.231092
78
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/__init__.py
from onmt.modules.UtilClass import LayerNorm, Bottle, BottleLinear, \ BottleLayerNorm, BottleSoftmax, Elementwise from onmt.modules.Gate import ContextGateFactory from onmt.modules.GlobalAttention import GlobalAttention from onmt.modules.ConvMultiStepAttention import ConvMultiStepAttention from onmt.modules.ImageEn...
1,489
45.5625
79
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/OpenNMT/onmt/modules/ImageEncoder.py
import torch.nn as nn import torch.nn.functional as F import torch import torch.cuda from torch.autograd import Variable class ImageEncoder(nn.Module): """ Encoder recurrent neural network for Images. """ def __init__(self, num_layers, bidirectional, rnn_size, dropout): """ Args: ...
3,998
36.373832
76
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/__init__.py
0
0
0
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Cluster/clustering.py
# coding:utf-8 """ main code for clustering define clustering class and running this code to get clustering for stanford data """ import json from source.AuxiliaryTools.nlp_tool import low_case_tokenizer all_file = ['dev.json', 'test.json', 'train.json'] all_task = ["navigate", "schedule", "weather"] class Cluster:...
8,064
43.558011
121
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Cluster/conll_format_clustering.py
# coding:utf-8 """ main code for clustering define clustering class and running this code to get clustering for stanford data """ import json import os from source.AuxiliaryTools.nlp_tool import low_case_tokenizer CONTEXT_WINDOW_SIZE = 2 # 2 is used because it is empirical feature setting in slot filling task SENT_C...
19,236
48.836788
133
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Cluster/__init__.py
0
0
0
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Cluster/atis_clustering.py
# coding:utf-8 from source.Cluster.clustering import Cluster # wait to construct class AtisCluster(Cluster): def __init__(self, input_dir, output_dir): Cluster.__init__(self, input_dir, output_dir) def unpack_and_cook_raw_data(self, raw_data): pass if __name__ == "__main__": print("Hi, ...
330
19.6875
53
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Generation/seq2seq_translation_tutorial.py
# -*- coding: utf-8 -*- """ Translation with a Sequence to Sequence Network and Attention ************************************************************* **Author**: `Sean Robertson <https://github.com/spro/practical-pytorch>`_ In this project we will be teaching a neural network to translate from French to English. ::...
31,375
33.939866
133
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Generation/PrepareData.py
# coding: utf-8 from source.AuxiliaryTools.nlp_tool import low_case_tokenizer from itertools import combinations import pickle import json import os SOS_token = 0 EOS_token = 1 class WordTable: def __init__(self, name): self.name = name self.word2index = {} self.word2count = {} se...
4,127
33.689076
117
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Generation/Evaluation.py
# coding: utf-8 ###################################################################### # Evaluation # ========== # # Evaluation is mostly the same as training, but there are no targets so # we simply feed the decoder's predictions back to itself for each step. # Every time it predicts a word we add it to the output str...
4,187
34.794872
116
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Generation/Seq2SeqModel.py
# coding: utf-8 import torch import torch.nn as nn from torch.autograd import Variable import torch.nn.functional as F class EncoderRNN(nn.Module): def __init__(self, input_size, hidden_size, use_cuda, n_layers=1): super(EncoderRNN, self).__init__() self.n_layers = n_layers self.hidden_siz...
3,661
34.901961
112
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Generation/Training.py
import time import math import random import torch import torch.nn as nn from torch.autograd import Variable from torch import optim from source.AuxiliaryTools.nn_tool import show_plot, variables_from_pair SOS_token = 0 EOS_token = 1 teacher_forcing_ratio = 0.5 def train(input_variable, target_variable, encoder, de...
4,278
33.788618
109
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Generation/__init__.py
0
0
0
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/ReFilling/re_filling.py
# coding:utf-8 import re import json from source.AuxiliaryTools.nlp_tool import sentence_edit_distance import random from multiprocessing import Process, Queue, current_process, freeze_support, Manager import copy N_THREAD = 20 TASK_SIZE = 500 CONTEXT_WINDOW_SIZE = 2 FULL_SLOT_TABLE_AVAILABLE = True CONTEXT_REFILL_RATE...
14,997
44.72561
173
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/ReFilling/__init__.py
0
0
0
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Evaluate/gen_eval.py
import json import argparse import random import re # from nlp_tool import sentence_edit_distance # this is worked out of pycharm from source.AuxiliaryTools.nlp_tool import sentence_edit_distance # # ==== load config ===== # with open('../../config.json', 'r') as con_f: # CONFIG = json.load(con_f) # # # parser =...
6,950
40.622754
150
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Evaluate/__init__.py
0
0
0
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/Evaluate/slot_filling.py
# coding:utf-8 """ Tips: slot label format: B-slot_name, there is no < or > in slot_name """ import json import os from source.AuxiliaryTools.nlp_tool import low_case_tokenizer import re # VERBOSE = True VERBOSE = False # DEBUG = False DEBUG = True SENT_COUNT_SPLIT = True # def out_of_slot(i, j, tmp_word_lst,...
15,138
46.309375
182
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/AuxiliaryTools/eval_tool.py
# coding: utf-8 import json import os import re LOG_DIR = '../../log/' CONFIG_PATH = '../../config.json' with open(CONFIG_PATH, 'r') as reader: CONFIG = json.load(reader) RANDOM_SEED = 100 # EXTEND_SETTING = ['extend_'] EXTEND_SETTING = ['extend_', ''] RFO_SETTING = ['_refill-only', ''] TASK_SETTING = ['atis_labele...
7,655
43.254335
780
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/AuxiliaryTools/ConfigTool.py
# coding: utf-8 import json import os from collections import OrderedDict def create_dir(p_list): new_folder_num = 0 for p in p_list: if type(p) == dict: new_folder_num += create_dir(p.values()) elif not os.path.isdir(p): os.makedirs(p) new_folder_num += 1 ...
4,972
60.395062
619
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/AuxiliaryTools/data_split.py
# coding: utf-8 DATA_FORMAT = 'conll' INPUT_FILE = '/users4/ythou/Projects/TaskOrientedDialogue/data/AtisRaw/atis.train' OUTPUT_DIR = '/users4/ythou/Projects/TaskOrientedDialogue/data/Atis/' DATA_MARK = 'atis' TRAIN_DEV_RATE = [0.8, 0.2] TRAIN_DEV_COUNT = [None, 500] USE_RATE = False def split(): with open(INPUT...
1,072
36
82
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/AuxiliaryTools/slot_leak_check.py
# coding:utf-8 import json import os import re LOG_DIR = '../../log/' CONFIG_PATH = '../../config.json' with open(CONFIG_PATH, 'r') as reader: CONFIG = json.load(reader) test_slot_file_path = CONFIG['path']["ClusteringResult"] + 'test_atis_labeled_intent-slot1.json' origin_train_file_path = CONFIG['path']['RawDat...
1,696
38.465116
139
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/AuxiliaryTools/nn_tool.py
# coding: utf-8 from __future__ import unicode_literals, print_function, division import torch from torch.autograd import Variable import matplotlib.pyplot as plt import matplotlib.ticker as ticker SOS_token = 0 EOS_token = 1 teacher_forcing_ratio = 0.5 MAX_LENGTH = 10 def show_plot(points): plt.figure() fi...
1,083
26.794872
72
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/AuxiliaryTools/data_tool.py
# coding:utf-8 import json import argparse import random import re from nlp_tool import sentence_edit_distance # this is worked out of pycharm # from source.AuxiliaryTools.nlp_tool import sentence_edit_distance # ==== load config ===== with open('../../config.json', 'r') as con_f: CONFIG = json.load(con_f) def...
6,819
43
143
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/AuxiliaryTools/diverse_score_demo.py
# coding:utf-8 import math import editdistance def sentence_edit_distance(s1, s2): s1 = s1.split() if type(s1) is str else s1 s2 = s2.split() if type(s2) is str else s2 if type(s1) is list and type(s2) is list: return editdistance.eval(s1, s2) else: print("Error: Only str and list is s...
1,668
36.931818
92
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/AuxiliaryTools/__init__.py
0
0
0
py
Seq2SeqDataAugmentationForLU
Seq2SeqDataAugmentationForLU-master/source/AuxiliaryTools/nlp_tool.py
import string from nltk.tokenize import TweetTokenizer from nltk.tokenize.treebank import TreebankWordTokenizer, TreebankWordDetokenizer import editdistance def sentence_edit_distance(s1, s2): s1 = s1.split() if type(s1) is str else s1 s2 = s2.split() if type(s2) is str else s2 if type(s1) is list and typ...
2,444
30.753247
133
py
seq2seq
seq2seq-master/setup.py
# Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing,...
910
26.606061
74
py
seq2seq
seq2seq-master/bin/__init__.py
0
0
0
py
seq2seq
seq2seq-master/bin/infer.py
#! /usr/bin/env python # Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
4,428
33.069231
77
py
seq2seq
seq2seq-master/bin/train.py
#! /usr/bin/env python # Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
10,770
37.744604
80
py
seq2seq
seq2seq-master/bin/tools/generate_beam_viz.py
#! /usr/bin/env python # Copyright 2017 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
3,893
28.5
79
py