instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Annotate my code with docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Residual Shuffle-Exchange Network. + +Implementation of +"Residual Shuffle-Exchange Networks for Fast Processing of Long Sequences" +paper by A.Draguns, E.Ozolins, A.Sostaks, M.Apinis...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/residual_shuffle_exchange.py
Add docstrings to improve collaboration
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Reversible Residual Transformer.""" from __future__ import absolute_import from __future__ import division @@ -29,6 +30,16 @@ @registry.register_model class TransformerRevnet(tr...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/transformer_revnet.py
Add missing documentation to my Python functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Experiments with Adafactor. +""" from __future__ import absolute_import from __future__ import division @@ -23,6 +25,13 @@ def mimic_adam_with_adafactor(hparams): + """Switch ...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/adafactor_experiments.py
Add docstrings for utility scripts
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Reinforcement learning models and parameters.""" import collections import functools @@ -45,6 +46,7 @@ @registry.register_hparams def ppo_base_v1(): + """Set of hyperparameters...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/rl.py
Create Google-style docstrings for my code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Transformer model from "Attention Is All You Need". + +The Transformer model consists of an encoder and a decoder. Both are stacks +of self-attention layers followed by feed-forward l...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/transformer.py
Write documentation strings for class attributes
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Stacks and Queues implemented as encoder-decoder models. + +Based off of the following research: + +Learning to Transduce with Unbounded Memory +Edward Grefenstette, Karl Moritz Herma...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/neural_stack.py
Write documentation strings for class attributes
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""SliceNet.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -31,6 +32,7 @@ # pylint: disable=unused-argument def ...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/slicenet.py
Create docstrings for reusable components
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Experiments for Multiquery-Attention Paper. +""" from __future__ import absolute_import from __future__ import division @@ -150,6 +152,7 @@ @registry.register_hparams def mqp_lm...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/multiquery_paper.py
Create structured documentation for my script
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Basic models for testing simple tasks.""" from __future__ import absolute_import from __future__ import division @@ -38,6 +39,7 @@ def pixels_from_softmax(frame_logits, pure_samp...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/video/base.py
Add docstrings for better understanding
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for En-Vi translation.""" from __future__ import absolute_import from __future__ import division @@ -46,6 +47,7 @@ @registry.register_problem class TranslateEnvi...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/translate_envi.py
Generate descriptive docstrings automatically
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utils for audio.""" from __future__ import absolute_import from __future__ import division @@ -25,6 +26,15 @@ def add_delta_deltas(filterbanks, name=None): + """Compute time f...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/common_audio.py
Create docstrings for all classes and functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Base class for envs that store their history. + +EnvProblem subclasses Problem and also implements the Gym interface (step, +reset, render, close, seed) +""" from __future__ import...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/envs/env_problem.py
Add docstrings to existing functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utils for latent variable models.""" from __future__ import absolute_import from __future__ import division @@ -33,6 +34,7 @@ def compress_self_attention_layer(x, hparams, name...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/latent_layers.py
Expand my code with proper documentation strings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Transformer model.""" from __future__ import absolute_import from __future__ import division @@ -33,6 +34,7 @@ @registry.register_model class MtfTransformer(mtf_model.MtfModel):...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/mtf_transformer.py
Document all endpoints with docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Transformer model.""" from __future__ import absolute_import from __future__ import division @@ -33,6 +34,11 @@ @registry.register_model class MtfUnitransformer(mtf_model.MtfMod...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/mtf_transformer2.py
Add minimal docstrings for each function
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""image generation with transformer (attention). + +encoder: [Self-Attention, Feed-forward] x n +decoder: [Self-Attention, Source-Target-Attention, Feed-forward] x n + +""" from __fu...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/image_transformer_2d.py
Add verbose docstrings with examples
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Hyperparameters and ranges common to multiple models.""" from __future__ import absolute_import from __future__ import division @@ -26,6 +27,7 @@ @registry.register_hparams("basi...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/common_hparams.py
Document all endpoints with docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Evolved Transformer model. + +This implements the model described in arxiv.org/abs/1901.11117 . +""" from __future__ import absolute_import from __future__ import division @@ -44,...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/evolved_transformer.py
Add professional docstrings to my codebase
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Discretization bottlenecks used to train discrete latent variables.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/discretization.py
Generate docstrings for each module
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Hook to run glow initialization on a larger batch.""" from __future__ import absolute_import from __future__ import division @@ -22,6 +23,12 @@ class GlowInitHook(tf.train.Sess...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/glow_init_hook.py
Please document this code using docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Mixture-of-experts code. + +Interfaces and algorithms are under development and subject to rapid change +without notice. +""" from __future__ import absolute_import from __future_...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/moe.py
Replace inline comments with docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""image generation with transformer (attention). + +encoder: [Self-Attention, Feed-forward] x n +decoder: [Self-Attention, Source-Target-Attention, Feed-forward] x n + +""" from __fu...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/image_transformer.py
Fill in missing docstrings in my code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Various reversible ops for the glow generative model.""" from __future__ import absolute_import from __future__ import division @@ -33,6 +34,17 @@ def linear_interpolate(tensor...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/glow_ops.py
Write proper docstrings for these functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""ResNet model with model and data parallelism using MTF. + +Integration of Mesh tensorflow with ResNet to do model parallelism. +""" from __future__ import absolute_import from __f...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/mtf_resnet.py
Add docstrings that explain inputs and outputs
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Basic models for testing simple tasks.""" from __future__ import absolute_import from __future__ import division @@ -25,11 +26,28 @@ class NextFrameBaseVae(object): + """Basic...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/video/base_vae.py
Generate documentation strings for clarity
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Bank of layers for Translation NAS searches. + +All encoder layers are registered in the global LayerRegistry ENCODER_LAYERS. +All decoder layers are registered on the global LayerReg...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/neural_architecture_search/nas_layers.py
Can you add docstrings to this Python file?
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""NasSeq2Seq class which can be configured to produce a variety of models. + +This was the class used in the Evolved Transformer paper +(https://arxiv.org/abs/1901.11117) to create conf...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/neural_architecture_search/nas_model.py
Add docstrings to make code maintainable
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generator for Wikipedia title to article dataset.""" from __future__ import absolute_import from __future__ import division @@ -33,8 +34,21 @@ @registry.register_problem cl...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/wiki.py
Document this code for team use
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""ByteNet.""" from __future__ import absolute_import from __future__ import division @@ -28,6 +29,7 @@ def residual_dilated_conv(x, repeat, padding, name, hparams): + """A stack...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/bytenet.py
Add docstrings to incomplete code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Models for gene expression from DNA.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -29,6 +30,21 @@ @registry.r...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/gene_expression.py
Write docstrings for utility functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""TicTacToeEnvProblem wraps the TicTacToeEnv in an EnvProblem.""" from __future__ import absolute_import from __future__ import division @@ -25,6 +26,7 @@ @registry.register_env_pr...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/envs/tic_tac_toe_env_problem.py
Create structured documentation for my script
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Fetch reference URLs for a single group_id within a single shard_id. + +See get_references_web.py to fetch URLs for all groups in within a single +shard_id. + +Requires Python 3.5 +pi...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/wikisum/get_references_web_single_group.py
Add docstrings with type hints explained
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Image Transformer model with model and data parallelism using MTF. + +Integration of Mesh tensorflow with Image Transformer to do model parallelism. +Currently, this supports uncondit...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/mtf_image_transformer.py
Add docstrings to improve collaboration
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""RNN LSTM models.""" from __future__ import absolute_import from __future__ import division @@ -37,6 +38,25 @@ def lstm(inputs, sequence_length, hparams, train, name, initial_st...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/lstm.py
Add professional docstrings to my codebase
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Traditional Student-Teacher Distillation.""" from __future__ import absolute_import from __future__ import division @@ -27,6 +28,20 @@ @registry.register_model class Distillatio...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/distillation.py
Generate consistent docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,25 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Experiments with Language Models. + +Train languagemodel_lm1b32k_packed and measure log-ppl/token (dev). +These numbers need to be multiplied by 1.107893 to get log-ppl/word + for com...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/lm_experiments.py
Write Python docstrings for this snippet
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Glow generative model.""" from __future__ import absolute_import from __future__ import division @@ -38,6 +39,7 @@ @registry.register_hparams def glow_hparams(): + """Glow Hpar...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/glow.py
Add docstrings to existing functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utilities for area attention.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -24,6 +25,15 @@ def lengths_to_a...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/area_attention.py
Add verbose docstrings with examples
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Autoencoders.""" from __future__ import absolute_import from __future__ import division @@ -36,6 +37,7 @@ def time_to_channels(embedded_video): + """Put time dimension on chan...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/autoencoders.py
Add detailed docstrings explaining each function
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for untokenized wikipedia LM dataset.""" from __future__ import absolute_import from __future__ import division @@ -30,6 +31,7 @@ def concat_generator(filename,...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/wiki_lm.py
Write docstrings for backend logic
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Neural Assistant.""" from __future__ import absolute_import from __future__ import division @@ -28,6 +29,7 @@ @registry.register_model class NeuralAssistant(transformer.Transfor...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/neural_assistant.py
Create Google-style docstrings for my code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Using Transformer Networks for String similarities.""" from tensor2tensor.data_generators import problem from tensor2tensor.layers import common_layers from tensor2tensor.models imp...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/similarity_transformer.py
Add detailed docstrings explaining each function
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""The Neural GPU model and its variants.""" from __future__ import absolute_import from __future__ import division @@ -28,6 +29,7 @@ def neural_gpu_body(inputs, hparams, name=Non...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/neural_gpu.py
Add clean documentation to messy code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Self attention models for VQA.""" from __future__ import absolute_import from __future__ import division @@ -36,6 +37,7 @@ @registry.register_model class VqaSelfAttention(vqa_at...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/vqa_self_attention.py
Add docstrings for better understanding
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Transformer Sketch for im2sketch problems. +""" from __future__ import absolute_import from __future__ import division @@ -27,8 +29,10 @@ @registry.register_model class Transfor...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/transformer_sketch.py
Write proper docstrings for these functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Single stack of transformations with no masking. + +Produces output aligned with inputs. + +Configurable using hyperparameters to use some combination of convolutions, +attention, mix...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/aligned.py
Add docstrings for utility scripts
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""NAT Transformer from https://arxiv.org/abs/1805.11063.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -29,6 +30,7...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/transformer_nat.py
Generate docstrings with parameter types
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Recurrent self attention models for VQA.""" from __future__ import absolute_import from __future__ import division @@ -37,6 +38,7 @@ @registry.register_model class VqaRecurrentS...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/vqa_recurrent_self_attention.py
Write docstrings that follow conventions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Base class for envs that store their history. + +EnvProblem subclasses Problem and also implements the Gym interface (step, +reset, render, close, seed) +""" from __future__ import...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/envs/gym_env_problem.py
Can you add docstrings to this Python file?
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utilities for linear interpolation over the next_frame_glow latent space.""" from __future__ import absolute_import from __future__ import division @@ -53,6 +54,7 @@ def decode...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/video/nfg_interpolate.py
Add docstrings explaining edge cases
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""A QueryProcessor using the Transformer framework.""" from __future__ import absolute_import from __future__ import division @@ -44,6 +45,15 @@ def topk_watch_fn(feeds, fetches)...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/insights/transformer_model.py
Improve documentation using docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Base class for env problems with RGB array as observation space.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/envs/rendered_env_problem.py
Generate helpful docstrings for debugging
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for translation data-sets.""" from __future__ import absolute_import from __future__ import division @@ -67,9 +68,11 @@ @registry.register_problem class Translat...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/translate_ende.py
Write clean docstrings for readability
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generator for the timeseries problem.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -21,6 +22,30 @@ def...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/timeseries_data_generator.py
Insert docstrings into my code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for translation data-sets.""" from __future__ import absolute_import from __future__ import division @@ -55,6 +56,7 @@ @registry.register_problem class Translate...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/translate_encs.py
Add return value explanations in docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for English-Czech backtranslation NMT data-sets. + +To use this problem you need to provide backtranslated (synthetic) data to +tmp_dir (cs_mono_{en,cs}.txt{0,1,2} - e...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/translate_encs_cubbitt.py
Write documentation strings for class attributes
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Layers common to multiple models.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -38,6 +39,7 @@ # TODO(lukaszka...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/common_layers.py
Generate consistent documentation across files
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utils for attention mechanism for images.""" from __future__ import absolute_import from __future__ import division @@ -30,6 +31,7 @@ class AttentionType(object): + """Types o...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/common_image_attention.py
Generate docstrings for exported functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for translation data-sets.""" from __future__ import absolute_import from __future__ import division @@ -35,6 +36,7 @@ class TranslateProblem(text_problems.Text...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/translate.py
Add docstrings that explain logic
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Various ops for TransformerVaeFlowPrior.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -31,12 +32,14 @@ def ...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/transformer_vae_flow_prior_ops.py
Help me document legacy Python code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utilities for video.""" from __future__ import absolute_import from __future__ import division @@ -37,11 +38,13 @@ def swap_time_and_batch_axes(inputs): + """Swaps time and ba...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/common_video.py
Document all public functions with docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Stochastic Adversarial Video Prediction model. + +Reference: https://arxiv.org/abs/1804.01523 +""" from __future__ import absolute_import from __future__ import division @@ -36,8 ...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/video/savp.py
Write reusable docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,30 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""TimeStep is a simple class that holds the information seen at a time-step. + +Let: +r_t = Reward(s_{t-1}, a_{t-1}, s_t) - reward for getting into a state. +d_t = Done(s_t) ...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/envs/time_step.py
Generate helpful docstrings for debugging
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""A GUnicorn + Flask Debug Frontend for Transformer models.""" import json from flask import Flask @@ -45,6 +46,7 @@ class NumpySerializationFix(JSONEncoder): + """json module c...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/insights/server.py
Create docstrings for reusable components
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utilities for attention.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -42,6 +43,45 @@ ...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/message_passing_attention.py
Generate helpful docstrings for debugging
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""SV2P: Stochastic Variational Video Prediction. + + based on the following paper: + https://arxiv.org/abs/1710.11252 + by Mohammad Babaeizadeh, Chelsea Finn, Dumitru Erhan, + ...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/video/sv2p.py
Add docstrings to my Python code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Glow operations for text. + +Adapted glow operations from tensor2tensor.models.research.glow_ops to be used +as a prior in Text VAEs (specifically for MT). Supports: +1. Log determina...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/transformer_glow_layers.py
Generate documentation strings for clarity
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for En-Et translation.""" from __future__ import absolute_import from __future__ import division @@ -53,6 +54,7 @@ @registry.register_problem class TranslateEnet...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/translate_enet.py
Create structured documentation for my script
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for translation data-sets.""" from __future__ import absolute_import from __future__ import division @@ -55,9 +56,11 @@ @registry.register_problem class Translat...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/translate_enes.py
Add detailed documentation for each class
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,18 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""A suite of sequence transduction problems. + +Each problem generates pairs of tokenized input and output sequences which +represent the effect of the transduction algorithm which must...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/transduction_problems.py
Add docstrings including usage examples
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Basic models for testing simple tasks.""" from __future__ import absolute_import from __future__ import division @@ -28,6 +29,7 @@ @registry.register_model class BasicFcRelu(t2t...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/basic.py
Add docstrings to existing functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Trajectory manages a sequence of TimeSteps. + +BatchTrajectory manages a batch of trajectories, also keeping account of +completed trajectories. +""" from __future__ import absolut...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/envs/trajectory.py
Add docstrings that explain purpose and usage
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,10 +13,28 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""A base class for all query processing classes.""" class QueryProcessor(object): + """Base class for any class that wants to process sequence queries. + + QueryProcessor classe...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/insights/query_processor.py
Add docstrings for better understanding
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""N-gram layer.""" from __future__ import absolute_import from __future__ import division @@ -23,8 +24,30 @@ class NGram(tf.keras.layers.Layer): + r"""N-gram layer. + + The lay...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/ngram.py
Add detailed docstrings explaining each function
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,16 +13,35 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Graph representation for building decoding graph visualizations.""" class Vertex(object): + """Vertex stores in and out edge connections to other Vertex instances. + + The Ver...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/insights/graph.py
Generate docstrings for each module
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""AE Transformer.""" from __future__ import absolute_import from __future__ import division @@ -44,6 +45,7 @@ def residual_conv(x, repeat, k, hparams, name, reuse=None): + """A ...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/transformer_vae.py
Add docstrings to existing functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Modalities, which specify a feature's domain. + +T2TModel applies a default transformation to each feature according to its +modality. Override them by specifying a model's +hparams.{...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/modalities.py
Provide clean and structured docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Transformer VAE with Flow Priors for Non-Autoregressive MT.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -40,6 ...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/transformer_vae_flow_prior.py
Document this code for team use
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Self-attention based language model. + +DEPRECATED. Use Transformer which supports running the decoder only. + +Like transformer.py, but no encoder + +decoder: [Self-Attention, Feed-f...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/attention_lm.py
Add docstrings that explain inputs and outputs
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Additional operations for transformer_glow_layers.py.""" from __future__ import absolute_import from __future__ import division @@ -28,6 +29,7 @@ def dense(name, x, n_out, dtyp...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/transformer_glow_layers_ops.py
Generate docstrings for each module
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for video problems with artificially generated frames.""" from __future__ import absolute_import from __future__ import division @@ -39,9 +40,11 @@ @registry.regi...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/video_generated.py
Document this code for team use
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Data generators for translation data-sets.""" from __future__ import absolute_import from __future__ import division @@ -157,6 +158,23 @@ @registry.register_problem class Transl...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/data_generators/translate_enzh.py
Document classes and their methods
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Conditional FVD metric on video. + +FVD - Frechet Video Distance + +This is the metric that is inspired by FID, but applied to +video rather than to images. +""" from __future__ im...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/metrics/video_conditional_fvd.py
Help me add docstrings to my project
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Some customization of common_attention.""" from __future__ import absolute_import from __future__ import division @@ -31,6 +32,12 @@ def summarize_tensors(tensor_dict, tag=None...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/vqa_layers.py
Add professional docstrings to my codebase
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""The memory unit for Transformer.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -22,17 +23,48 @@ class Recurr...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/layers/transformer_memory.py
Generate docstrings for this script
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Batch of environments inside the TensorFlow graph.""" # The code was based on Danijar Hafner's code from tf.agents: # https://github.com/tensorflow/agents/blob/master/agents/tools/...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/rl/envs/in_graph_batch_env.py
Write docstrings for this repository
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Universal Transformers. + +Universal Transformer is described in https://arxiv.org/abs/1807.03819. + +Universal Transformer is recurrent in depth while employing self-attention +to co...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/universal_transformer.py
Write docstrings that follow conventions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Batch of environments inside the TensorFlow graph.""" # The code was based on Danijar Hafner's code from tf.agents: # https://github.com/tensorflow/agents/blob/master/agents/tools/...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/rl/envs/simulated_batch_env.py
Add docstrings to improve code quality
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""SimulatedBatchEnv in a Gym-like interface.""" from __future__ import absolute_import from __future__ import division @@ -28,6 +29,7 @@ class FlatBatchEnv(Env): + """Gym enviro...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/rl/envs/simulated_batch_gym_env.py
Document all public functions with docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Batch of environments inside the TensorFlow graph.""" from __future__ import absolute_import from __future__ import division @@ -26,6 +27,7 @@ class WrapperBase(InGraphBatchEnv...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/rl/envs/tf_atari_wrappers.py
Expand my code with proper documentation strings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,40 @@ # See the License for the specific language governing permissions and # limitations under the License. +r"""Play with a world model. + +Controls: + WSAD and SPACE to control the agent. + R key to reset env. + C key to toggle WAIT mode. + N to perform NOOP action under WAIT mode. + X t...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/rl/player.py
Add professional docstrings to my codebase
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Self-attention based language model. + +Like transformer.py, but no encoder + +decoder: [Self-Attention, Feed-forward] x n + +""" from __future__ import absolute_import from __fut...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/attention_lm_moe.py
Help me document legacy Python code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Batch of environments inside the TensorFlow graph.""" # The code was based on Danijar Hafner's code from tf.agents: # https://github.com/tensorflow/agents/blob/master/agents/tools/...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/rl/envs/py_func_batch_env.py
Insert docstrings into my code
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Optimization.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -24,6 +25,83 @@ class AdafactorOptimizer(tf.trai...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/utils/adafactor.py
Auto-generate documentation strings for this file
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Training restarter.""" import contextlib import os @@ -21,6 +22,29 @@ class Restarter(object): + """Handles training restarts. + + Particularly useful when sharing parameters...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/rl/restarter.py
Create docstrings for reusable components
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Shake-shake model for CIFAR.""" from __future__ import absolute_import from __future__ import division @@ -28,6 +29,7 @@ def shake_shake_skip_connection(x, output_filters, stri...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/shake_shake.py
Add detailed documentation for each class
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Basic models for testing simple tasks.""" from __future__ import absolute_import from __future__ import division @@ -31,6 +32,7 @@ @registry.register_model class NextFrameBasicD...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/video/basic_deterministic.py
Create documentation strings for testing functions
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,25 @@ # See the License for the specific language governing permissions and # limitations under the License. +r"""Training of RL agent with PPO algorithm. + +Example invocation: + +python -m tensor2tensor.rl.trainer_model_free \ + --output_dir=$HOME/t2t/rl_v1 \ + --hparams_set=pong_model_f...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/rl/trainer_model_free.py
Generate descriptive docstrings automatically
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,34 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Utilities for Universal Transformer. + +The Universal Transformer is based on the popular encoder-decoder architecture. +However, as opposed to a fixed stack of distinct layers (as is...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/research/universal_transformer_util.py
Improve documentation using docstrings
# coding=utf-8 # Copyright 2023 The Tensor2Tensor Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
--- +++ @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Param sets for SV2P model.""" from __future__ import division from __future__ import print_function @@ -24,6 +25,7 @@ @registry.register_hparams def next_frame_sv2p(): + """SV2...
https://raw.githubusercontent.com/tensorflow/tensor2tensor/HEAD/tensor2tensor/models/video/sv2p_params.py