python_code
stringlengths
0
679k
repo_name
stringlengths
9
41
file_path
stringlengths
6
149
# Copyright (c) 2018 NVIDIA Corporation ''' This file implements function to calcuate basic metrics. ''' import numpy as np import tensorflow as tf def true_positives(labels, preds): return np.sum(np.logical_and(labels, preds)) def accuracy(labels, preds): return np.sum(np.equal(labels, preds)) / len(preds) def...
OpenSeq2Seq-master
open_seq2seq/utils/metrics.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import math import os import time import tensorflow as tf from open_seq2seq.utils.utils import deco_print, log_summaries_from_dict, \ g...
OpenSeq2Seq-master
open_seq2seq/utils/hooks.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import copy import tempfile import numpy as np import numpy.testing as npt import tensorflow as tf from six.moves import range from open_seq2seq.test_utils.test_speech_conf...
OpenSeq2Seq-master
open_seq2seq/utils/utils_test.py
# Copyright (c) 2017 NVIDIA Corporation from .funcs import train, infer, evaluate
OpenSeq2Seq-master
open_seq2seq/utils/__init__.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import time import numpy as np import tensorflow as tf # pylint: disable=no-name-in-module from tensorflow.python import debug as tf_debug from six.moves import range from ...
OpenSeq2Seq-master
open_seq2seq/utils/funcs.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import argparse import ast import copy import datetime import os import pprint import runpy import shutil import subprocess import sys import time import numpy as np import...
OpenSeq2Seq-master
open_seq2seq/utils/utils.py
''' This file modifies standard TensorFlow modules necessary for transfer learning, such as MonitoredTrainingSession, ChiefSessionCreator, Scaffold, SessionManager ''' import re import time import tensorflow as tf from tensorflow.python.ops import resources from tensorflow.python.training import saver as training_save...
OpenSeq2Seq-master
open_seq2seq/utils/helpers.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import codecs import re import nltk import tensorflow as tf from six.moves import range from open_seq2seq.data.text2text.text2text import SpecialTextTokens from open_seq2se...
OpenSeq2Seq-master
open_seq2seq/models/text2text.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from open_seq2seq.models.model import Model from open_seq2seq.utils.utils import deco_print class EncoderDecoderModel(Model): """ Standard encod...
OpenSeq2Seq-master
open_seq2seq/models/encoder_decoder.py
import random import numpy as np import tensorflow as tf from .encoder_decoder import EncoderDecoderModel from open_seq2seq.data import WKTDataLayer from open_seq2seq.utils.utils import deco_print, array_to_string from open_seq2seq.utils import metrics class LSTMLM(EncoderDecoderModel): """ An example class imple...
OpenSeq2Seq-master
open_seq2seq/models/lstm_lm.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import copy import os import tempfile import numpy as np import numpy.testing as npt import pandas as pd import tensorflow as tf from six.moves import range from open_seq2s...
OpenSeq2Seq-master
open_seq2seq/models/speech2text_test.py
# Copyright (c) 2017 NVIDIA Corporation """All base models available in OpenSeq2Seq.""" from .model import Model from .text2text import Text2Text from .speech2text import Speech2Text from .image2label import Image2Label from .lstm_lm import LSTMLM from .text2speech_tacotron import Text2SpeechTacotron from .text2speech_...
OpenSeq2Seq-master
open_seq2seq/models/__init__.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from open_seq2seq.test_utils.test_speech_configs.ds2_test_config import \ base_params, train_params, eval_params, base_model from .speech2text_te...
OpenSeq2Seq-master
open_seq2seq/models/speech2text_ds2_test.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals from six.moves import range import abc import six import tensorflow as tf import numpy as np import copy import time import re try: from inspect import signature except Im...
OpenSeq2Seq-master
open_seq2seq/models/model.py
# Copyright (c) 2019 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import librosa import matplotlib as mpl import numpy as np from scipy.io.wavfile import write from six import BytesIO from six.moves import range mpl.use('Agg') import matpl...
OpenSeq2Seq-master
open_seq2seq/models/text2speech.py
# Copyright (c) 2019 NVIDIA Corporation from .text2speech import Text2Speech class Text2SpeechTacotron(Text2Speech): """ Text-to-speech data layer for Tacotron. """ def get_alignments(self, attention_mask): specs = [attention_mask] titles = ["alignments"] return specs, titles
OpenSeq2Seq-master
open_seq2seq/models/text2speech_tacotron.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import numpy as np import pandas as pd import tensorflow as tf from six.moves import range import matplotlib as mpl mpl.use('Agg') import matplotlib.pyplot as plt from io im...
OpenSeq2Seq-master
open_seq2seq/models/speech2text.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import runpy import tensorflow as tf from open_seq2seq.test_utils.create_reversed_examples import create_data, \ ...
OpenSeq2Seq-master
open_seq2seq/models/text2text_test.py
# Copyright (c) 2019 NVIDIA Corporation from six.moves import range from .text2speech import Text2Speech class Text2SpeechCentaur(Text2Speech): """ Text-to-speech data layer for Centaur. """ def get_alignments(self, attention_mask): alignments_name = ["dec_enc_alignment"] specs = [] titles = [...
OpenSeq2Seq-master
open_seq2seq/models/text2speech_centaur.py
# Copyright (c) 2018 NVIDIA Corporation import numpy as np from scipy.io.wavfile import write from .encoder_decoder import EncoderDecoderModel def save_audio(signal, logdir, step, sampling_rate, mode): signal = np.float32(signal) file_name = '{}/sample_step{}_{}.wav'.format(logdir, step, mode) if logdir[0] != '...
OpenSeq2Seq-master
open_seq2seq/models/text2speech_wavenet.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import numpy as np import tensorflow as tf from open_seq2seq.utils.utils import deco_print from .encoder_decoder import EncoderDecoderModel class Image2Label(EncoderDecod...
OpenSeq2Seq-master
open_seq2seq/models/image2label.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from open_seq2seq.test_utils.test_speech_configs.w2l_test_config import \ base_params, train_params, eval_params, base_model from .speech2text_te...
OpenSeq2Seq-master
open_seq2seq/models/speech2text_w2l_test.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import numpy as np import numpy.testing as npt import tensorflow as tf from six.moves import range from open_seq2seq.optimizers import optimize_loss from open_seq2seq.optimi...
OpenSeq2Seq-master
open_seq2seq/optimizers/mp_wrapper_test.py
# Copyright (c) 2017 NVIDIA Corporation """ Module containing various learning rate policies. Learning rate policy can be any function that takes arbitrary arguments from the config (with additional ``global_step`` variable provided automatically) and returns learning rate value for the current step. """ from __future_...
OpenSeq2Seq-master
open_seq2seq/optimizers/lr_policies.py
# Copyright (c) 2018 NVIDIA Corporation # # 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 i...
OpenSeq2Seq-master
open_seq2seq/optimizers/mp_wrapper.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import numpy as np import numpy.testing as npt import tensorflow as tf from six.moves import range from open_seq2seq.optimizers import optimize_loss from .lr_policies import...
OpenSeq2Seq-master
open_seq2seq/optimizers/optimizers_test.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import tensorflow as tf from open_seq2seq.utils.utils import check_params class AutomaticLossScaler(object): SUPPORTED_ALGOS =...
OpenSeq2Seq-master
open_seq2seq/optimizers/automatic_loss_scaler.py
# Copyright (c) 2017 NVIDIA Corporation from .optimizers import optimize_loss, get_regularization_loss
OpenSeq2Seq-master
open_seq2seq/optimizers/__init__.py
# Copyright 2015 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...
OpenSeq2Seq-master
open_seq2seq/optimizers/optimizers.py
# Copyright (c) 2019 NVIDIA Corporation # # 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 i...
OpenSeq2Seq-master
open_seq2seq/optimizers/novograd.py
# This code is heavily based on the code from MLPerf # https://github.com/mlperf/reference/tree/master/translation/tensorflow # /transformer from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from six.moves import range from open_seq2seq.en...
OpenSeq2Seq-master
open_seq2seq/encoders/transformer_encoder.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from .encoder import Encoder from open_seq2seq.data.speech2text.speech2text import Speech2TextDataLayer from open_seq2seq.parts.cnns.conv_blocks impo...
OpenSeq2Seq-master
open_seq2seq/encoders/tdnn_encoder.py
# Copyright (c) 2018 NVIDIA Corporation """ Conv-based encoder """ from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf import math from .encoder import Encoder from open_seq2seq.parts.transformer import embedding_layer from open_seq2seq.part...
OpenSeq2Seq-master
open_seq2seq/encoders/convs2s_encoder.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...
OpenSeq2Seq-master
open_seq2seq/encoders/resnet_blocks.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from .resnet_blocks import conv2d_fixed_padding, batch_norm, block_layer, \ bottleneck_block_v1, bottleneck_block_v2, \ ...
OpenSeq2Seq-master
open_seq2seq/encoders/resnet_encoder.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals from six.moves import range import inspect import tensorflow as tf from tensorflow.contrib.cudnn_rnn.python.ops import cudnn_rnn_ops from tensorflow.python.framework import ...
OpenSeq2Seq-master
open_seq2seq/encoders/tacotron2_encoder.py
# Copyright (c) 2018 NVIDIA Corporation """ This module contains classes and functions to build "general" convolutional neural networks from the description of arbitrary "layers". """ from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import copy import tensorflow...
OpenSeq2Seq-master
open_seq2seq/encoders/cnn_encoder.py
# Copyright (c) 2018 NVIDIA Corporation """ This package contains various encoders. An encoder typically takes data and produces representation. """ from .encoder import Encoder from .rnn_encoders import UnidirectionalRNNEncoderWithEmbedding, \ BidirectionalRNNEncoderWithEmbedding, \ ...
OpenSeq2Seq-master
open_seq2seq/encoders/__init__.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import abc import copy import six import tensorflow as tf from open_seq2seq.optimizers.mp_wrapper import mp_regularizer_wrapper from open_seq2seq.utils.utils import check_p...
OpenSeq2Seq-master
open_seq2seq/encoders/encoder.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from .encoder import Encoder from open_seq2seq.parts.cnns.conv_blocks import conv_actv, conv_bn_actv cells_dict = { "lstm": tf.nn.rnn_cell.Basic...
OpenSeq2Seq-master
open_seq2seq/encoders/las_encoder.py
# Copyright (c) 2018 NVIDIA Corporation """ RNN-based encoders """ from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from tensorflow.contrib.cudnn_rnn.python.ops import cudnn_rnn_ops from open_seq2seq.parts.rnns.utils import single_cell fr...
OpenSeq2Seq-master
open_seq2seq/encoders/rnn_encoders.py
# Copyright (c) 2018 NVIDIA Corporation """ RNN-based encoders """ from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import copy, inspect import tensorflow as tf from tensorflow.contrib.cudnn_rnn.python.ops import cudnn_rnn_ops from open_seq2seq.optimizers.mp_wrap...
OpenSeq2Seq-master
open_seq2seq/encoders/lm_encoders.py
import tensorflow as tf from open_seq2seq.encoders import Encoder from open_seq2seq.parts.centaur import ConvBlock from open_seq2seq.parts.transformer import embedding_layer from open_seq2seq.parts.transformer import utils class CentaurEncoder(Encoder): """ Centaur encoder that consists of convolutional layers. ...
OpenSeq2Seq-master
open_seq2seq/encoders/centaur_encoder.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from tensorflow.contrib.cudnn_rnn.python.ops import cudnn_rnn_ops from six.moves import range from open_seq2seq.parts.cnns.conv_blocks import conv_bn...
OpenSeq2Seq-master
open_seq2seq/encoders/ds2_encoder.py
# Copyright (c) 2018 NVIDIA Corporation import tensorflow as tf from math import ceil from open_seq2seq.parts.cnns.conv_blocks import conv_actv, conv_bn_actv from .encoder import Encoder def _get_receptive_field(kernel_size, blocks, layers_per_block): dilations = [2 ** i for i in range(layers_per_block)] return...
OpenSeq2Seq-master
open_seq2seq/encoders/wavenet_encoder.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import abc import copy import six import tensorflow as tf from open_seq2seq.optimizers.mp_wrapper import mp_regularizer_wrapper from open_seq2seq.utils.utils import check_p...
OpenSeq2Seq-master
open_seq2seq/decoders/decoder.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from open_seq2seq.parts.rnns.attention_wrapper import BahdanauAttention, \ LuongAttention, \ LocationSensitiveAttention, \ AttentionWrapp...
OpenSeq2Seq-master
open_seq2seq/decoders/las_decoder.py
# Copyright (c) 2018 NVIDIA Corporation """ Tacotron2 decoder """ from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from tensorflow.python.framework import ops from open_seq2seq.parts.rnns.utils import single_cell from open_seq2seq.parts.r...
OpenSeq2Seq-master
open_seq2seq/decoders/tacotron2_decoder.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from .decoder import Decoder class JointCTCAttentionDecoder(Decoder): """Joint CTC Attention like decoder. Combines CTC and Attention based dec...
OpenSeq2Seq-master
open_seq2seq/decoders/jca_decoder.py
from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf import math from .decoder import Decoder from open_seq2seq.parts.transformer import beam_search from open_seq2seq.parts.transformer import embedding_layer from open_seq2seq.parts.transform...
OpenSeq2Seq-master
open_seq2seq/decoders/convs2s_decoder.py
# Copyright (c) 2018 NVIDIA Corporation """ This package contains various decoder. A Decoder typically takes representation and produces data. """ from .decoder import Decoder from .fc_decoders import FullyConnectedCTCDecoder, FullyConnectedDecoder, FullyConnectedSCDecoder from .rnn_decoders import RNNDecoderWithAttent...
OpenSeq2Seq-master
open_seq2seq/decoders/__init__.py
# Copyright (c) 2018 NVIDIA Corporation """This module defines various fully-connected decoders (consisting of one fully connected layer). These classes are usually used for models that are not really sequence-to-sequence and thus should be artificially split into encoder and decoder by cutting, for example, on the la...
OpenSeq2Seq-master
open_seq2seq/decoders/fc_decoders.py
# This code is heavily based on the code from MLPerf # https://github.com/mlperf/reference/tree/master/translation/tensorflow/transformer from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf from six.moves import range from open_seq2seq.part...
OpenSeq2Seq-master
open_seq2seq/decoders/transformer_decoder.py
# Copyright (c) 2019 NVIDIA Corporation import tensorflow as tf from tensorflow.python.ops import math_ops from open_seq2seq.parts.centaur import AttentionBlock from open_seq2seq.parts.centaur import ConvBlock from open_seq2seq.parts.centaur import Prenet from open_seq2seq.parts.transformer import utils from open_seq2...
OpenSeq2Seq-master
open_seq2seq/decoders/centaur_decoder.py
# Copyright (c) 2018 NVIDIA Corporation """ RNN-based decoders. """ from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import copy import tensorflow as tf from open_seq2seq.parts.rnns.attention_wrapper import BahdanauAttention, \ ...
OpenSeq2Seq-master
open_seq2seq/decoders/rnn_decoders.py
# Copyright (c) 2018 NVIDIA Corporation """This module defines various fully-connected decoders (consisting of one fully connected layer). These classes are usually used for models that are not really sequence-to-sequence and thus should be artificially split into encoder and decoder by cutting, for example, on the la...
OpenSeq2Seq-master
open_seq2seq/decoders/lm_decoders.py
# Copyright (c) 2017 NVIDIA Corporation
OpenSeq2Seq-master
open_seq2seq/parts/__init__.py
# Copyright (c) 2019 NVIDIA Corporation import tensorflow as tf from open_seq2seq.parts.centaur import ConvBlock from open_seq2seq.parts.transformer import attention_layer from open_seq2seq.parts.transformer.common import PrePostProcessingWrapper from open_seq2seq.parts.transformer.ffn_layer import FeedFowardNetwork ...
OpenSeq2Seq-master
open_seq2seq/parts/centaur/attention.py
# Copyright (c) 2019 NVIDIA Corporation from .conv_block import ConvBlock from .attention import AttentionBlock from .batch_norm import BatchNorm1D from .prenet import Prenet
OpenSeq2Seq-master
open_seq2seq/parts/centaur/__init__.py
# Copyright (c) 2019 NVIDIA Corporation import tensorflow as tf from .batch_norm import BatchNorm1D class ConvBlock: """ Convolutional block for Centaur model. """ def __init__(self, name, conv, norm, activation_fn, dropout, ...
OpenSeq2Seq-master
open_seq2seq/parts/centaur/conv_block.py
# Copyright (c) 2019 NVIDIA Corporation import tensorflow as tf class BatchNorm1D: """ 1D batch normalization layer. """ def __init__(self, *args, **kwargs): super(BatchNorm1D, self).__init__() self.norm = tf.layers.BatchNormalization(*args, **kwargs) def __call__(self, x, training): with tf.v...
OpenSeq2Seq-master
open_seq2seq/parts/centaur/batch_norm.py
# Copyright (c) 2019 NVIDIA Corporation import tensorflow as tf class Prenet: """ Centaur decoder pre-net. """ def __init__(self, n_layers, hidden_size, activation_fn, dropout=0.5, regularizer=None, training=True, ...
OpenSeq2Seq-master
open_seq2seq/parts/centaur/prenet.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import tensorflow as tf class TemporalConvolutionalLayer(tf.layers.Conv1D): """Temporal Convolutional layer """ def __init__( self, filters, kernel...
OpenSeq2Seq-master
open_seq2seq/parts/cnns/tcn.py
# Copyright (c) 2018 NVIDIA Corporation
OpenSeq2Seq-master
open_seq2seq/parts/cnns/__init__.py
# Copyright (c) 2018 NVIDIA Corporation from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from six.moves import range import tensorflow as tf from .tcn import tcn layers_dict = { "conv1d": tf.layers.conv1d, "sep...
OpenSeq2Seq-master
open_seq2seq/parts/cnns/conv_blocks.py
# Copyright 2016 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...
OpenSeq2Seq-master
open_seq2seq/parts/tacotron/tacotron_decoder.py
OpenSeq2Seq-master
open_seq2seq/parts/tacotron/__init__.py
# Copyright 2016 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...
OpenSeq2Seq-master
open_seq2seq/parts/tacotron/tacotron_helper.py
# Copyright 2018 MLBenchmark Group. 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 applicable l...
OpenSeq2Seq-master
open_seq2seq/parts/transformer/ffn_layer.py
# Copyright 2018 MLBenchmark Group. 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 applicable l...
OpenSeq2Seq-master
open_seq2seq/parts/transformer/embedding_layer.py
# Copyright 2018 MLBenchmark Group. 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 applicable l...
OpenSeq2Seq-master
open_seq2seq/parts/transformer/utils_test.py
OpenSeq2Seq-master
open_seq2seq/parts/transformer/__init__.py
# Copyright 2018 MLBenchmark Group. 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 applicable l...
OpenSeq2Seq-master
open_seq2seq/parts/transformer/beam_search.py
# Copyright 2018 MLBenchmark Group. 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 applicable l...
OpenSeq2Seq-master
open_seq2seq/parts/transformer/beam_search_test.py
# This code is heavily based on the code from MLPerf # https://github.com/mlperf/reference/tree/master/translation/tensorflow/transformer from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf class Transformer_BatchNorm(tf.layers.Layer):...
OpenSeq2Seq-master
open_seq2seq/parts/transformer/common.py
# Copyright 2018 MLBenchmark Group. 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 applicable l...
OpenSeq2Seq-master
open_seq2seq/parts/transformer/utils.py
# Copyright 2018 MLBenchmark Group. 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 applicable l...
OpenSeq2Seq-master
open_seq2seq/parts/transformer/attention_layer.py
# Copyright 2017 Google Inc. 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 applicable law or a...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/gnmt.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...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/rnn_beam_search_decoder.py
"""Module for constructing RNN Cells.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from six.moves import range from tensorflow.contrib.rnn.python.ops import core_rnn_cell from tensorflow.python.ops import array_o...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/glstm.py
"""Implement https://arxiv.org/abs/1709.02755 Copy from LSTM, and make it functionally correct with minimum code change """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from six.moves import range import tensorflo...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/slstm.py
OpenSeq2Seq-master
open_seq2seq/parts/rnns/__init__.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import math from six.moves import range import tensorflow as tf from tensorflow.python.ops.rnn_cell import ResidualWrapper, DropoutWrapper from open_seq2seq.parts.rnns.weig...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/utils.py
from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from six.moves import range from tensorflow.python.ops import rnn_cell_impl from tensorflow.python.ops.nn_ops import dropout class ZoneoutWrapper(rnn_cell_impl.RNNCell)...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/zoneout.py
# Copyright 2016 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...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/helper.py
# pylint: skip-file # 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...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/attention_wrapper.py
import tensorflow as tf class WeightDropLayerNormBasicLSTMCell(tf.contrib.rnn.RNNCell): """LSTM unit with layer normalization, weight dropout, and recurrent dropout. This is based on LSTM's standard implementation of LayerNormBasicLSTMCell. This class adds layer normalization and recurrent dropout to a basic L...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/weight_drop.py
"""Module for constructing RNN Cells.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals from six.moves import range from tensorflow.contrib.rnn.python.ops import core_rnn_cell from tensorflow.python.ops import array_o...
OpenSeq2Seq-master
open_seq2seq/parts/rnns/flstm.py
"""Implementation of a 1d convolutional layer with weight normalization. Inspired from https://github.com/tobyyouup/conv_seq2seq""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import tensorflow as tf import math f...
OpenSeq2Seq-master
open_seq2seq/parts/convs2s/conv_wn_layer.py
"""Implementation of fully connected network with weight normalization. Inspired from https://github.com/tobyyouup/conv_seq2seq""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import tensorflow as tf import math fr...
OpenSeq2Seq-master
open_seq2seq/parts/convs2s/ffn_wn_layer.py
"""Implementation of the attention layer for convs2s. Inspired from https://github.com/tobyyouup/conv_seq2seq""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import tensorflow as tf import math from open_seq2seq.pa...
OpenSeq2Seq-master
open_seq2seq/parts/convs2s/attention_wn_layer.py
# Copyright (c) 2018 NVIDIA Corporation
OpenSeq2Seq-master
open_seq2seq/parts/convs2s/__init__.py
"""Implementation of a 1d convolutional layer with weight normalization. Inspired from https://github.com/tobyyouup/conv_seq2seq""" import tensorflow as tf def gated_linear_units(inputs): """Gated Linear Units (GLU) on x. Args: x: A float32 tensor with shape [batch_size, length, 2*out_dim] Returns: fl...
OpenSeq2Seq-master
open_seq2seq/parts/convs2s/utils.py
# Copyright (c) 2017 NVIDIA Corporation from .data_layer import DataLayer from .speech2text.speech2text import Speech2TextDataLayer from .speech2text.speech_commands import SpeechCommandsDataLayer from .image2label.image2label import ImagenetDataLayer from .lm.lmdata import WKTDataLayer, IMDBDataLayer, SSTDataLayer fro...
OpenSeq2Seq-master
open_seq2seq/data/__init__.py
# Copyright (c) 2017 NVIDIA Corporation from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import io from six.moves import range def pad_vocab_to_eight(vocab): """Pads vocabulary so that it is divisible by 8. Args: vocab (dict): vocabulary in the form t...
OpenSeq2Seq-master
open_seq2seq/data/utils.py
# Copyright (c) 2017 NVIDIA Corporation """Data layer classes""" from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import abc import copy import six import tensorflow as tf from open_seq2seq.utils.utils import check_params @six.add_metaclass(abc.ABCMeta) class...
OpenSeq2Seq-master
open_seq2seq/data/data_layer.py
OpenSeq2Seq-master
open_seq2seq/data/image2label/__init__.py
# Copyright 2016 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...
OpenSeq2Seq-master
open_seq2seq/data/image2label/imagenet_preprocessing.py
# Copyright 2015 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...
OpenSeq2Seq-master
open_seq2seq/data/image2label/cifar10_download_and_extract.py
# This code is heavily based on the code from TensorFlow official models # https://github.com/tensorflow/models/tree/master/official/resnet from __future__ import absolute_import, division, print_function from __future__ import unicode_literals import os import numpy as np import tensorflow as tf from six.moves impo...
OpenSeq2Seq-master
open_seq2seq/data/image2label/image2label.py