repo
stringclasses
85 values
path
stringlengths
8
121
func_name
stringlengths
1
82
original_string
stringlengths
112
65.5k
language
stringclasses
1 value
code
stringlengths
112
65.5k
code_tokens
listlengths
20
4.09k
docstring
stringlengths
3
46.3k
docstring_tokens
listlengths
1
564
sha
stringclasses
85 values
url
stringlengths
93
218
partition
stringclasses
1 value
tensorflow/tensor2tensor
tensor2tensor/data_generators/wiki.py
_page_to_title
def _page_to_title(page): """Extract the title from a page. Args: page: a unicode string Returns: a unicode string """ # print("page=%s" % page) start_tag = u"<title>" end_tag = u"</title>" start_pos = page.find(start_tag) end_pos = page.find(end_tag) assert start_pos != -1 assert end_pos...
python
def _page_to_title(page): """Extract the title from a page. Args: page: a unicode string Returns: a unicode string """ # print("page=%s" % page) start_tag = u"<title>" end_tag = u"</title>" start_pos = page.find(start_tag) end_pos = page.find(end_tag) assert start_pos != -1 assert end_pos...
[ "def", "_page_to_title", "(", "page", ")", ":", "# print(\"page=%s\" % page)", "start_tag", "=", "u\"<title>\"", "end_tag", "=", "u\"</title>\"", "start_pos", "=", "page", ".", "find", "(", "start_tag", ")", "end_pos", "=", "page", ".", "find", "(", "end_tag", ...
Extract the title from a page. Args: page: a unicode string Returns: a unicode string
[ "Extract", "the", "title", "from", "a", "page", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/wiki.py#L270-L286
train
tensorflow/tensor2tensor
tensor2tensor/data_generators/wiki.py
_page_to_text
def _page_to_text(page): """Extract the text from a page. Args: page: a unicode string Returns: a unicode string """ # text start tag looks like "<text ..otherstuff>" start_pos = page.find(u"<text") assert start_pos != -1 end_tag_pos = page.find(u">", start_pos) assert end_tag_pos != -1 end...
python
def _page_to_text(page): """Extract the text from a page. Args: page: a unicode string Returns: a unicode string """ # text start tag looks like "<text ..otherstuff>" start_pos = page.find(u"<text") assert start_pos != -1 end_tag_pos = page.find(u">", start_pos) assert end_tag_pos != -1 end...
[ "def", "_page_to_text", "(", "page", ")", ":", "# text start tag looks like \"<text ..otherstuff>\"", "start_pos", "=", "page", ".", "find", "(", "u\"<text\"", ")", "assert", "start_pos", "!=", "-", "1", "end_tag_pos", "=", "page", ".", "find", "(", "u\">\"", ",...
Extract the text from a page. Args: page: a unicode string Returns: a unicode string
[ "Extract", "the", "text", "from", "a", "page", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/wiki.py#L289-L306
train
tensorflow/tensor2tensor
tensor2tensor/data_generators/wiki.py
_find_and_replace
def _find_and_replace(text, start_string, end_string, replace_fn): """Remove everything found between instances of start_string and end_string. Replace each such instance with replace_fn(removed_text) e.g. _find_and_replace(u"the [[fat]] cat [[sat]]", u"[[", u"]]", lambda x: x) = u"the fat cat sat" Args:...
python
def _find_and_replace(text, start_string, end_string, replace_fn): """Remove everything found between instances of start_string and end_string. Replace each such instance with replace_fn(removed_text) e.g. _find_and_replace(u"the [[fat]] cat [[sat]]", u"[[", u"]]", lambda x: x) = u"the fat cat sat" Args:...
[ "def", "_find_and_replace", "(", "text", ",", "start_string", ",", "end_string", ",", "replace_fn", ")", ":", "ret", "=", "u\"\"", "current_pos", "=", "0", "while", "True", ":", "start_pos", "=", "text", ".", "find", "(", "start_string", ",", "current_pos", ...
Remove everything found between instances of start_string and end_string. Replace each such instance with replace_fn(removed_text) e.g. _find_and_replace(u"the [[fat]] cat [[sat]]", u"[[", u"]]", lambda x: x) = u"the fat cat sat" Args: text: a unicode string start_string: a unicode string end_s...
[ "Remove", "everything", "found", "between", "instances", "of", "start_string", "and", "end_string", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/wiki.py#L309-L339
train
tensorflow/tensor2tensor
tensor2tensor/data_generators/wiki.py
_remove_double_brackets
def _remove_double_brackets(text): """Remove double brackets (internal links) but leave the viewable text. Args: text: a unicode string Returns: a unicode string """ def replacement_fn(s): if u":" in s: # this is probably a category or something like that. return "" # keep the par...
python
def _remove_double_brackets(text): """Remove double brackets (internal links) but leave the viewable text. Args: text: a unicode string Returns: a unicode string """ def replacement_fn(s): if u":" in s: # this is probably a category or something like that. return "" # keep the par...
[ "def", "_remove_double_brackets", "(", "text", ")", ":", "def", "replacement_fn", "(", "s", ")", ":", "if", "u\":\"", "in", "s", ":", "# this is probably a category or something like that.", "return", "\"\"", "# keep the part after the bar.", "bar_pos", "=", "s", ".",...
Remove double brackets (internal links) but leave the viewable text. Args: text: a unicode string Returns: a unicode string
[ "Remove", "double", "brackets", "(", "internal", "links", ")", "but", "leave", "the", "viewable", "text", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/wiki.py#L352-L369
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
image_encoder
def image_encoder(image_feat, hparams, name="image_encoder", save_weights_to=None, make_image_summary=True): """A stack of self attention layers.""" x = image_feat image_hidden_size = hparams.image_hidden_size or hparams.hidden_size image_...
python
def image_encoder(image_feat, hparams, name="image_encoder", save_weights_to=None, make_image_summary=True): """A stack of self attention layers.""" x = image_feat image_hidden_size = hparams.image_hidden_size or hparams.hidden_size image_...
[ "def", "image_encoder", "(", "image_feat", ",", "hparams", ",", "name", "=", "\"image_encoder\"", ",", "save_weights_to", "=", "None", ",", "make_image_summary", "=", "True", ")", ":", "x", "=", "image_feat", "image_hidden_size", "=", "hparams", ".", "image_hidd...
A stack of self attention layers.
[ "A", "stack", "of", "self", "attention", "layers", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L262-L313
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
prepare_question_encoder
def prepare_question_encoder(inputs, hparams): """Prepare question encoder. Args: inputs: a Tensor. hparams: run hyperparameters Returns: encoder_input: a Tensor, bottom of encoder stack encoder_self_attention_bias: a bias tensor for use in encoder self-attention """ encoder_input = inputs ...
python
def prepare_question_encoder(inputs, hparams): """Prepare question encoder. Args: inputs: a Tensor. hparams: run hyperparameters Returns: encoder_input: a Tensor, bottom of encoder stack encoder_self_attention_bias: a bias tensor for use in encoder self-attention """ encoder_input = inputs ...
[ "def", "prepare_question_encoder", "(", "inputs", ",", "hparams", ")", ":", "encoder_input", "=", "inputs", "# Usual case - not a packed dataset.", "encoder_padding", "=", "common_attention", ".", "embedding_to_padding", "(", "encoder_input", ")", "ignore_padding", "=", "...
Prepare question encoder. Args: inputs: a Tensor. hparams: run hyperparameters Returns: encoder_input: a Tensor, bottom of encoder stack encoder_self_attention_bias: a bias tensor for use in encoder self-attention
[ "Prepare", "question", "encoder", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L316-L339
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
question_encoder
def question_encoder(question, question_self_attention_bias, hparams, name="question_encoder", save_weights_to=None, make_image_summary=True): """A stack of self attention layers.""" x = question with tf.varia...
python
def question_encoder(question, question_self_attention_bias, hparams, name="question_encoder", save_weights_to=None, make_image_summary=True): """A stack of self attention layers.""" x = question with tf.varia...
[ "def", "question_encoder", "(", "question", ",", "question_self_attention_bias", ",", "hparams", ",", "name", "=", "\"question_encoder\"", ",", "save_weights_to", "=", "None", ",", "make_image_summary", "=", "True", ")", ":", "x", "=", "question", "with", "tf", ...
A stack of self attention layers.
[ "A", "stack", "of", "self", "attention", "layers", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L342-L392
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
attn
def attn(image_feat, query, hparams, name="attn", save_weights_to=None, make_image_summary=True): """Attention on image feature with question as query.""" with tf.variable_scope(name, "attn", values=[image_feat, query]): total_key_depth = hparams.attention_key_channe...
python
def attn(image_feat, query, hparams, name="attn", save_weights_to=None, make_image_summary=True): """Attention on image feature with question as query.""" with tf.variable_scope(name, "attn", values=[image_feat, query]): total_key_depth = hparams.attention_key_channe...
[ "def", "attn", "(", "image_feat", ",", "query", ",", "hparams", ",", "name", "=", "\"attn\"", ",", "save_weights_to", "=", "None", ",", "make_image_summary", "=", "True", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "\"attn\"", ",", "...
Attention on image feature with question as query.
[ "Attention", "on", "image", "feature", "with", "question", "as", "query", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L395-L430
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
mlp
def mlp(feature, hparams, name="mlp"): """Multi layer perceptron with dropout and relu activation.""" with tf.variable_scope(name, "mlp", values=[feature]): num_mlp_layers = hparams.num_mlp_layers mlp_size = hparams.mlp_size for _ in range(num_mlp_layers): feature = common_layers.dense(feature, ml...
python
def mlp(feature, hparams, name="mlp"): """Multi layer perceptron with dropout and relu activation.""" with tf.variable_scope(name, "mlp", values=[feature]): num_mlp_layers = hparams.num_mlp_layers mlp_size = hparams.mlp_size for _ in range(num_mlp_layers): feature = common_layers.dense(feature, ml...
[ "def", "mlp", "(", "feature", ",", "hparams", ",", "name", "=", "\"mlp\"", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "\"mlp\"", ",", "values", "=", "[", "feature", "]", ")", ":", "num_mlp_layers", "=", "hparams", ".", "num_mlp_la...
Multi layer perceptron with dropout and relu activation.
[ "Multi", "layer", "perceptron", "with", "dropout", "and", "relu", "activation", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L433-L445
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
prepare_image_question_encoder
def prepare_image_question_encoder(image_feat, question, hparams): """Prepare encoder. Args: image_feat: a Tensor. question: a Tensor. hparams: run hyperparameters Returns: encoder_input: a Tensor, bottom of encoder stack encoder_self_attention_bias: a bias tensor for use in encoder self-att...
python
def prepare_image_question_encoder(image_feat, question, hparams): """Prepare encoder. Args: image_feat: a Tensor. question: a Tensor. hparams: run hyperparameters Returns: encoder_input: a Tensor, bottom of encoder stack encoder_self_attention_bias: a bias tensor for use in encoder self-att...
[ "def", "prepare_image_question_encoder", "(", "image_feat", ",", "question", ",", "hparams", ")", ":", "encoder_input", "=", "tf", ".", "concat", "(", "[", "image_feat", ",", "question", "]", ",", "axis", "=", "1", ")", "encoder_padding", "=", "common_attentio...
Prepare encoder. Args: image_feat: a Tensor. question: a Tensor. hparams: run hyperparameters Returns: encoder_input: a Tensor, bottom of encoder stack encoder_self_attention_bias: a bias tensor for use in encoder self-attention
[ "Prepare", "encoder", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L448-L477
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
image_question_encoder
def image_question_encoder(encoder_inputs, encoder_self_attention_bias, hparams, query=None, name="image_question_encoder", save_weights_to=None, make_image_s...
python
def image_question_encoder(encoder_inputs, encoder_self_attention_bias, hparams, query=None, name="image_question_encoder", save_weights_to=None, make_image_s...
[ "def", "image_question_encoder", "(", "encoder_inputs", ",", "encoder_self_attention_bias", ",", "hparams", ",", "query", "=", "None", ",", "name", "=", "\"image_question_encoder\"", ",", "save_weights_to", "=", "None", ",", "make_image_summary", "=", "True", ")", "...
A stack of self attention layers.
[ "A", "stack", "of", "self", "attention", "layers", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L480-L557
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
decoder
def decoder(decoder_input, encoder_output, decoder_self_attention_bias, encoder_decoder_attention_bias, hparams, name="decoder", save_weights_to=None, make_image_summary=True,): """A stack of transformer layers. Args: decoder_i...
python
def decoder(decoder_input, encoder_output, decoder_self_attention_bias, encoder_decoder_attention_bias, hparams, name="decoder", save_weights_to=None, make_image_summary=True,): """A stack of transformer layers. Args: decoder_i...
[ "def", "decoder", "(", "decoder_input", ",", "encoder_output", ",", "decoder_self_attention_bias", ",", "encoder_decoder_attention_bias", ",", "hparams", ",", "name", "=", "\"decoder\"", ",", "save_weights_to", "=", "None", ",", "make_image_summary", "=", "True", ",",...
A stack of transformer layers. Args: decoder_input: a Tensor encoder_output: a Tensor decoder_self_attention_bias: bias Tensor for self-attention (see common_attention.attention_bias()) encoder_decoder_attention_bias: bias Tensor for encoder-decoder attention (see common_attention.attenti...
[ "A", "stack", "of", "transformer", "layers", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L560-L651
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
iterative_encoder_decoder
def iterative_encoder_decoder(encoder_input, encoder_self_attention_bias, encoder_decoder_attention_bias, query, hparams): """Iterative encoder decoder.""" for _ in range(hparams.num_rec_steps): ...
python
def iterative_encoder_decoder(encoder_input, encoder_self_attention_bias, encoder_decoder_attention_bias, query, hparams): """Iterative encoder decoder.""" for _ in range(hparams.num_rec_steps): ...
[ "def", "iterative_encoder_decoder", "(", "encoder_input", ",", "encoder_self_attention_bias", ",", "encoder_decoder_attention_bias", ",", "query", ",", "hparams", ")", ":", "for", "_", "in", "range", "(", "hparams", ".", "num_rec_steps", ")", ":", "with", "tf", "....
Iterative encoder decoder.
[ "Iterative", "encoder", "decoder", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L654-L678
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
vqa_self_attention_base
def vqa_self_attention_base(): """VQA attention baseline hparams.""" hparams = common_hparams.basic_params1() hparams.batch_size = 128 hparams.use_fixed_batch_size = True, hparams.optimizer = "adam" hparams.optimizer_adam_beta1 = 0.9 hparams.optimizer_adam_beta2 = 0.997 hparams.optimizer_adam_epsilon = ...
python
def vqa_self_attention_base(): """VQA attention baseline hparams.""" hparams = common_hparams.basic_params1() hparams.batch_size = 128 hparams.use_fixed_batch_size = True, hparams.optimizer = "adam" hparams.optimizer_adam_beta1 = 0.9 hparams.optimizer_adam_beta2 = 0.997 hparams.optimizer_adam_epsilon = ...
[ "def", "vqa_self_attention_base", "(", ")", ":", "hparams", "=", "common_hparams", ".", "basic_params1", "(", ")", "hparams", ".", "batch_size", "=", "128", "hparams", ".", "use_fixed_batch_size", "=", "True", ",", "hparams", ".", "optimizer", "=", "\"adam\"", ...
VQA attention baseline hparams.
[ "VQA", "attention", "baseline", "hparams", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L682-L756
train
tensorflow/tensor2tensor
tensor2tensor/models/research/vqa_self_attention.py
vqa_self_attention_feature_batch1024_big
def vqa_self_attention_feature_batch1024_big(): """Big model.""" hparams = vqa_self_attention_feature_batch1024() hparams.learning_rate_constant = 7e-4 hparams.batch_size = 256 hparams.hidden_size = 1024 hparams.filter_size = 4096 hparams.num_heads = 16 hparams.layer_prepostprocess_dropout = 0.3 hpara...
python
def vqa_self_attention_feature_batch1024_big(): """Big model.""" hparams = vqa_self_attention_feature_batch1024() hparams.learning_rate_constant = 7e-4 hparams.batch_size = 256 hparams.hidden_size = 1024 hparams.filter_size = 4096 hparams.num_heads = 16 hparams.layer_prepostprocess_dropout = 0.3 hpara...
[ "def", "vqa_self_attention_feature_batch1024_big", "(", ")", ":", "hparams", "=", "vqa_self_attention_feature_batch1024", "(", ")", "hparams", ".", "learning_rate_constant", "=", "7e-4", "hparams", ".", "batch_size", "=", "256", "hparams", ".", "hidden_size", "=", "10...
Big model.
[ "Big", "model", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_self_attention.py#L774-L785
train
tensorflow/tensor2tensor
tensor2tensor/utils/data_reader.py
_bucket_boundaries
def _bucket_boundaries(max_length, min_length=8, length_bucket_step=1.1): """A default set of length-bucket boundaries.""" assert length_bucket_step > 1.0 x = min_length boundaries = [] while x < max_length: boundaries.append(x) x = max(x + 1, int(x * length_bucket_step)) return boundaries
python
def _bucket_boundaries(max_length, min_length=8, length_bucket_step=1.1): """A default set of length-bucket boundaries.""" assert length_bucket_step > 1.0 x = min_length boundaries = [] while x < max_length: boundaries.append(x) x = max(x + 1, int(x * length_bucket_step)) return boundaries
[ "def", "_bucket_boundaries", "(", "max_length", ",", "min_length", "=", "8", ",", "length_bucket_step", "=", "1.1", ")", ":", "assert", "length_bucket_step", ">", "1.0", "x", "=", "min_length", "boundaries", "=", "[", "]", "while", "x", "<", "max_length", ":...
A default set of length-bucket boundaries.
[ "A", "default", "set", "of", "length", "-", "bucket", "boundaries", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/data_reader.py#L69-L77
train
tensorflow/tensor2tensor
tensor2tensor/utils/data_reader.py
batching_scheme
def batching_scheme(batch_size, max_length, min_length_bucket, length_bucket_step, drop_long_sequences=False, shard_multiplier=1, length_multiplier=1, min_length=0): """A batchin...
python
def batching_scheme(batch_size, max_length, min_length_bucket, length_bucket_step, drop_long_sequences=False, shard_multiplier=1, length_multiplier=1, min_length=0): """A batchin...
[ "def", "batching_scheme", "(", "batch_size", ",", "max_length", ",", "min_length_bucket", ",", "length_bucket_step", ",", "drop_long_sequences", "=", "False", ",", "shard_multiplier", "=", "1", ",", "length_multiplier", "=", "1", ",", "min_length", "=", "0", ")", ...
A batching scheme based on model hyperparameters. Every batch contains a number of sequences divisible by `shard_multiplier`. Args: batch_size: int, total number of tokens in a batch. max_length: int, sequences longer than this will be skipped. Defaults to batch_size. min_length_bucket: int ...
[ "A", "batching", "scheme", "based", "on", "model", "hyperparameters", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/data_reader.py#L80-L164
train
tensorflow/tensor2tensor
tensor2tensor/utils/data_reader.py
hparams_to_batching_scheme
def hparams_to_batching_scheme(hparams, drop_long_sequences=False, shard_multiplier=1, length_multiplier=1): """Wrapper around _batching_scheme with hparams.""" return batching_scheme( batch_size=hparams.batch_size, ...
python
def hparams_to_batching_scheme(hparams, drop_long_sequences=False, shard_multiplier=1, length_multiplier=1): """Wrapper around _batching_scheme with hparams.""" return batching_scheme( batch_size=hparams.batch_size, ...
[ "def", "hparams_to_batching_scheme", "(", "hparams", ",", "drop_long_sequences", "=", "False", ",", "shard_multiplier", "=", "1", ",", "length_multiplier", "=", "1", ")", ":", "return", "batching_scheme", "(", "batch_size", "=", "hparams", ".", "batch_size", ",", ...
Wrapper around _batching_scheme with hparams.
[ "Wrapper", "around", "_batching_scheme", "with", "hparams", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/data_reader.py#L167-L180
train
tensorflow/tensor2tensor
tensor2tensor/utils/data_reader.py
pad_for_tpu
def pad_for_tpu(shapes_dict, hparams, max_length): """Pads unknown features' dimensions for TPU.""" padded_shapes = {} def get_filler(specified_max_length): if not specified_max_length: return max_length return min(specified_max_length, max_length) inputs_none_filler = get_filler(hparams.max_inp...
python
def pad_for_tpu(shapes_dict, hparams, max_length): """Pads unknown features' dimensions for TPU.""" padded_shapes = {} def get_filler(specified_max_length): if not specified_max_length: return max_length return min(specified_max_length, max_length) inputs_none_filler = get_filler(hparams.max_inp...
[ "def", "pad_for_tpu", "(", "shapes_dict", ",", "hparams", ",", "max_length", ")", ":", "padded_shapes", "=", "{", "}", "def", "get_filler", "(", "specified_max_length", ")", ":", "if", "not", "specified_max_length", ":", "return", "max_length", "return", "min", ...
Pads unknown features' dimensions for TPU.
[ "Pads", "unknown", "features", "dimensions", "for", "TPU", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/data_reader.py#L194-L218
train
tensorflow/tensor2tensor
tensor2tensor/utils/data_reader.py
standardize_shapes
def standardize_shapes(features, batch_size=None): """Set the right shapes for the features.""" for fname in ["inputs", "targets"]: if fname not in features: continue f = features[fname] while len(f.get_shape()) < 4: f = tf.expand_dims(f, axis=-1) features[fname] = f if batch_size: ...
python
def standardize_shapes(features, batch_size=None): """Set the right shapes for the features.""" for fname in ["inputs", "targets"]: if fname not in features: continue f = features[fname] while len(f.get_shape()) < 4: f = tf.expand_dims(f, axis=-1) features[fname] = f if batch_size: ...
[ "def", "standardize_shapes", "(", "features", ",", "batch_size", "=", "None", ")", ":", "for", "fname", "in", "[", "\"inputs\"", ",", "\"targets\"", "]", ":", "if", "fname", "not", "in", "features", ":", "continue", "f", "=", "features", "[", "fname", "]...
Set the right shapes for the features.
[ "Set", "the", "right", "shapes", "for", "the", "features", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/data_reader.py#L240-L259
train
tensorflow/tensor2tensor
tensor2tensor/utils/data_reader.py
_file_num_records_cached
def _file_num_records_cached(filename): """Return the number of TFRecords in a file.""" # Cache the result, as this is expensive to compute if filename in _file_num_records_cache: return _file_num_records_cache[filename] ret = 0 for _ in tf.python_io.tf_record_iterator(filename): ret += 1 _file_num_...
python
def _file_num_records_cached(filename): """Return the number of TFRecords in a file.""" # Cache the result, as this is expensive to compute if filename in _file_num_records_cache: return _file_num_records_cache[filename] ret = 0 for _ in tf.python_io.tf_record_iterator(filename): ret += 1 _file_num_...
[ "def", "_file_num_records_cached", "(", "filename", ")", ":", "# Cache the result, as this is expensive to compute", "if", "filename", "in", "_file_num_records_cache", ":", "return", "_file_num_records_cache", "[", "filename", "]", "ret", "=", "0", "for", "_", "in", "tf...
Return the number of TFRecords in a file.
[ "Return", "the", "number", "of", "TFRecords", "in", "a", "file", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/data_reader.py#L269-L278
train
tensorflow/tensor2tensor
tensor2tensor/utils/data_reader.py
pad_batch
def pad_batch(features, batch_multiple): """Pad batch dim of features to nearest multiple of batch_multiple.""" feature = list(features.items())[0][1] batch_size = tf.shape(feature)[0] mod = batch_size % batch_multiple has_mod = tf.cast(tf.cast(mod, tf.bool), tf.int32) batch_padding = batch_multiple * has_m...
python
def pad_batch(features, batch_multiple): """Pad batch dim of features to nearest multiple of batch_multiple.""" feature = list(features.items())[0][1] batch_size = tf.shape(feature)[0] mod = batch_size % batch_multiple has_mod = tf.cast(tf.cast(mod, tf.bool), tf.int32) batch_padding = batch_multiple * has_m...
[ "def", "pad_batch", "(", "features", ",", "batch_multiple", ")", ":", "feature", "=", "list", "(", "features", ".", "items", "(", ")", ")", "[", "0", "]", "[", "1", "]", "batch_size", "=", "tf", ".", "shape", "(", "feature", ")", "[", "0", "]", "...
Pad batch dim of features to nearest multiple of batch_multiple.
[ "Pad", "batch", "dim", "of", "features", "to", "nearest", "multiple", "of", "batch_multiple", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/data_reader.py#L292-L307
train
tensorflow/tensor2tensor
tensor2tensor/utils/data_reader.py
input_fn
def input_fn(dataset, filepattern, skip_random_fraction_when_training, batch_size_means_tokens_param, batch_size_multiplier, max_length, mode, hparams, data_dir=None, params=None, config=Non...
python
def input_fn(dataset, filepattern, skip_random_fraction_when_training, batch_size_means_tokens_param, batch_size_multiplier, max_length, mode, hparams, data_dir=None, params=None, config=Non...
[ "def", "input_fn", "(", "dataset", ",", "filepattern", ",", "skip_random_fraction_when_training", ",", "batch_size_means_tokens_param", ",", "batch_size_multiplier", ",", "max_length", ",", "mode", ",", "hparams", ",", "data_dir", "=", "None", ",", "params", "=", "N...
Builds input pipeline for problem. Args: dataset: the dataset to make input function from. filepattern: the pattern of files to read from. skip_random_fraction_when_training: whether to skip randomly when training. batch_size_means_tokens_param: whether batch size should mean tokens. batch_size_m...
[ "Builds", "input", "pipeline", "for", "problem", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/data_reader.py#L312-L572
train
tensorflow/tensor2tensor
tensor2tensor/data_generators/gene_expression.py
generate_shard_args
def generate_shard_args(outfiles, num_examples): """Generate start and end indices per outfile.""" num_shards = len(outfiles) num_examples_per_shard = num_examples // num_shards start_idxs = [i * num_examples_per_shard for i in range(num_shards)] end_idxs = list(start_idxs) end_idxs.pop(0) end_idxs.append...
python
def generate_shard_args(outfiles, num_examples): """Generate start and end indices per outfile.""" num_shards = len(outfiles) num_examples_per_shard = num_examples // num_shards start_idxs = [i * num_examples_per_shard for i in range(num_shards)] end_idxs = list(start_idxs) end_idxs.pop(0) end_idxs.append...
[ "def", "generate_shard_args", "(", "outfiles", ",", "num_examples", ")", ":", "num_shards", "=", "len", "(", "outfiles", ")", "num_examples_per_shard", "=", "num_examples", "//", "num_shards", "start_idxs", "=", "[", "i", "*", "num_examples_per_shard", "for", "i",...
Generate start and end indices per outfile.
[ "Generate", "start", "and", "end", "indices", "per", "outfile", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/gene_expression.py#L208-L216
train
tensorflow/tensor2tensor
tensor2tensor/data_generators/gene_expression.py
dataset_generator
def dataset_generator(filepath, dataset, chunk_size=1, start_idx=None, end_idx=None): """Generate example dicts.""" encoder = dna_encoder.DNAEncoder(chunk_size=chunk_size) with h5py.File(filepath, "r") as h5_file: # Get in...
python
def dataset_generator(filepath, dataset, chunk_size=1, start_idx=None, end_idx=None): """Generate example dicts.""" encoder = dna_encoder.DNAEncoder(chunk_size=chunk_size) with h5py.File(filepath, "r") as h5_file: # Get in...
[ "def", "dataset_generator", "(", "filepath", ",", "dataset", ",", "chunk_size", "=", "1", ",", "start_idx", "=", "None", ",", "end_idx", "=", "None", ")", ":", "encoder", "=", "dna_encoder", ".", "DNAEncoder", "(", "chunk_size", "=", "chunk_size", ")", "wi...
Generate example dicts.
[ "Generate", "example", "dicts", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/gene_expression.py#L232-L260
train
tensorflow/tensor2tensor
tensor2tensor/data_generators/gene_expression.py
to_example_dict
def to_example_dict(encoder, inputs, mask, outputs): """Convert single h5 record to an example dict.""" # Inputs bases = [] input_ids = [] last_idx = -1 for row in np.argwhere(inputs): idx, base_id = row idx, base_id = int(idx), int(base_id) assert idx > last_idx # if not, means 2 True values i...
python
def to_example_dict(encoder, inputs, mask, outputs): """Convert single h5 record to an example dict.""" # Inputs bases = [] input_ids = [] last_idx = -1 for row in np.argwhere(inputs): idx, base_id = row idx, base_id = int(idx), int(base_id) assert idx > last_idx # if not, means 2 True values i...
[ "def", "to_example_dict", "(", "encoder", ",", "inputs", ",", "mask", ",", "outputs", ")", ":", "# Inputs", "bases", "=", "[", "]", "input_ids", "=", "[", "]", "last_idx", "=", "-", "1", "for", "row", "in", "np", ".", "argwhere", "(", "inputs", ")", ...
Convert single h5 record to an example dict.
[ "Convert", "single", "h5", "record", "to", "an", "example", "dict", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/gene_expression.py#L263-L295
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
linear_interpolate
def linear_interpolate(tensor1, tensor2, coeffs): """Linearly interpolate between two tensors at coeff. Args: tensor1: 4-D Tensor, shape=(NHWC) tensor2: 4-D Tensor, shape=(NHWC) coeffs: list of floats. Returns: interp_latents: 5-D Tensor, with interp_latents[i] representing in...
python
def linear_interpolate(tensor1, tensor2, coeffs): """Linearly interpolate between two tensors at coeff. Args: tensor1: 4-D Tensor, shape=(NHWC) tensor2: 4-D Tensor, shape=(NHWC) coeffs: list of floats. Returns: interp_latents: 5-D Tensor, with interp_latents[i] representing in...
[ "def", "linear_interpolate", "(", "tensor1", ",", "tensor2", ",", "coeffs", ")", ":", "interp_tensors", "=", "[", "]", "for", "coeff", "in", "coeffs", ":", "interp_tensor", "=", "tensor1", "+", "coeff", "*", "(", "tensor2", "-", "tensor1", ")", "interp_ten...
Linearly interpolate between two tensors at coeff. Args: tensor1: 4-D Tensor, shape=(NHWC) tensor2: 4-D Tensor, shape=(NHWC) coeffs: list of floats. Returns: interp_latents: 5-D Tensor, with interp_latents[i] representing interpolations at coeffs[i]. shape=(l...
[ "Linearly", "interpolate", "between", "two", "tensors", "at", "coeff", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L34-L50
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
linear_interpolate_rank
def linear_interpolate_rank(tensor1, tensor2, coeffs, rank=1): """Linearly interpolate channel at "rank" between two tensors. The channels are ranked according to their L2 norm between tensor1[channel] and tensor2[channel]. Args: tensor1: 4-D Tensor, NHWC tensor2: 4-D Tensor, NHWC coeffs: list of ...
python
def linear_interpolate_rank(tensor1, tensor2, coeffs, rank=1): """Linearly interpolate channel at "rank" between two tensors. The channels are ranked according to their L2 norm between tensor1[channel] and tensor2[channel]. Args: tensor1: 4-D Tensor, NHWC tensor2: 4-D Tensor, NHWC coeffs: list of ...
[ "def", "linear_interpolate_rank", "(", "tensor1", ",", "tensor2", ",", "coeffs", ",", "rank", "=", "1", ")", ":", "# sum across space, max across channels.", "_", ",", "_", ",", "_", ",", "num_channels", "=", "common_layers", ".", "shape_list", "(", "tensor1", ...
Linearly interpolate channel at "rank" between two tensors. The channels are ranked according to their L2 norm between tensor1[channel] and tensor2[channel]. Args: tensor1: 4-D Tensor, NHWC tensor2: 4-D Tensor, NHWC coeffs: list of floats. rank: integer. Returns: interp_latents: list of in...
[ "Linearly", "interpolate", "channel", "at", "rank", "between", "two", "tensors", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L53-L82
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
postprocess
def postprocess(x, n_bits_x=8): """Converts x from [-0.5, 0.5], to [0, 255]. Args: x: 3-D or 4-D Tensor normalized between [-0.5, 0.5] n_bits_x: Number of bits representing each pixel of the output. Defaults to 8, to default to 256 possible values. Returns: x: 3-D or 4-D Tensor represen...
python
def postprocess(x, n_bits_x=8): """Converts x from [-0.5, 0.5], to [0, 255]. Args: x: 3-D or 4-D Tensor normalized between [-0.5, 0.5] n_bits_x: Number of bits representing each pixel of the output. Defaults to 8, to default to 256 possible values. Returns: x: 3-D or 4-D Tensor represen...
[ "def", "postprocess", "(", "x", ",", "n_bits_x", "=", "8", ")", ":", "x", "=", "tf", ".", "where", "(", "tf", ".", "is_finite", "(", "x", ")", ",", "x", ",", "tf", ".", "ones_like", "(", "x", ")", ")", "x", "=", "tf", ".", "clip_by_value", "(...
Converts x from [-0.5, 0.5], to [0, 255]. Args: x: 3-D or 4-D Tensor normalized between [-0.5, 0.5] n_bits_x: Number of bits representing each pixel of the output. Defaults to 8, to default to 256 possible values. Returns: x: 3-D or 4-D Tensor representing images or videos.
[ "Converts", "x", "from", "[", "-", "0", ".", "5", "0", ".", "5", "]", "to", "[", "0", "255", "]", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L85-L99
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
get_cond_latents_at_level
def get_cond_latents_at_level(cond_latents, level, hparams): """Returns a single or list of conditional latents at level 'level'.""" if cond_latents: if hparams.latent_dist_encoder in ["conv_net", "conv3d_net"]: return [cond_latent[level] for cond_latent in cond_latents] elif hparams.latent_dist_encod...
python
def get_cond_latents_at_level(cond_latents, level, hparams): """Returns a single or list of conditional latents at level 'level'.""" if cond_latents: if hparams.latent_dist_encoder in ["conv_net", "conv3d_net"]: return [cond_latent[level] for cond_latent in cond_latents] elif hparams.latent_dist_encod...
[ "def", "get_cond_latents_at_level", "(", "cond_latents", ",", "level", ",", "hparams", ")", ":", "if", "cond_latents", ":", "if", "hparams", ".", "latent_dist_encoder", "in", "[", "\"conv_net\"", ",", "\"conv3d_net\"", "]", ":", "return", "[", "cond_latent", "["...
Returns a single or list of conditional latents at level 'level'.
[ "Returns", "a", "single", "or", "list", "of", "conditional", "latents", "at", "level", "level", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L141-L147
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
check_cond_latents
def check_cond_latents(cond_latents, hparams): """Shape checking for cond_latents.""" if cond_latents is None: return if not isinstance(cond_latents[0], list): cond_latents = [cond_latents] exp_num_latents = hparams.num_cond_latents if hparams.latent_dist_encoder == "conv_net": exp_num_latents += ...
python
def check_cond_latents(cond_latents, hparams): """Shape checking for cond_latents.""" if cond_latents is None: return if not isinstance(cond_latents[0], list): cond_latents = [cond_latents] exp_num_latents = hparams.num_cond_latents if hparams.latent_dist_encoder == "conv_net": exp_num_latents += ...
[ "def", "check_cond_latents", "(", "cond_latents", ",", "hparams", ")", ":", "if", "cond_latents", "is", "None", ":", "return", "if", "not", "isinstance", "(", "cond_latents", "[", "0", "]", ",", "list", ")", ":", "cond_latents", "=", "[", "cond_latents", "...
Shape checking for cond_latents.
[ "Shape", "checking", "for", "cond_latents", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L150-L165
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
get_variable_ddi
def get_variable_ddi(name, shape, initial_value, dtype=tf.float32, init=False, trainable=True): """Wrapper for data-dependent initialization.""" # If init is a tf bool: w is assigned dynamically at runtime. # If init is a python bool: then w is determined during graph construction. w = tf.g...
python
def get_variable_ddi(name, shape, initial_value, dtype=tf.float32, init=False, trainable=True): """Wrapper for data-dependent initialization.""" # If init is a tf bool: w is assigned dynamically at runtime. # If init is a python bool: then w is determined during graph construction. w = tf.g...
[ "def", "get_variable_ddi", "(", "name", ",", "shape", ",", "initial_value", ",", "dtype", "=", "tf", ".", "float32", ",", "init", "=", "False", ",", "trainable", "=", "True", ")", ":", "# If init is a tf bool: w is assigned dynamically at runtime.", "# If init is a ...
Wrapper for data-dependent initialization.
[ "Wrapper", "for", "data", "-", "dependent", "initialization", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L169-L180
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
get_dropout
def get_dropout(x, rate=0.0, init=True): """Dropout x with dropout_rate = rate. Apply zero dropout during init or prediction time. Args: x: 4-D Tensor, shape=(NHWC). rate: Dropout rate. init: Initialization. Returns: x: activations after dropout. """ if init or rate == 0: return x re...
python
def get_dropout(x, rate=0.0, init=True): """Dropout x with dropout_rate = rate. Apply zero dropout during init or prediction time. Args: x: 4-D Tensor, shape=(NHWC). rate: Dropout rate. init: Initialization. Returns: x: activations after dropout. """ if init or rate == 0: return x re...
[ "def", "get_dropout", "(", "x", ",", "rate", "=", "0.0", ",", "init", "=", "True", ")", ":", "if", "init", "or", "rate", "==", "0", ":", "return", "x", "return", "tf", ".", "layers", ".", "dropout", "(", "x", ",", "rate", "=", "rate", ",", "tra...
Dropout x with dropout_rate = rate. Apply zero dropout during init or prediction time. Args: x: 4-D Tensor, shape=(NHWC). rate: Dropout rate. init: Initialization. Returns: x: activations after dropout.
[ "Dropout", "x", "with", "dropout_rate", "=", "rate", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L184-L198
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
actnorm_3d
def actnorm_3d(name, x, logscale_factor=3.): """Applies actnorm to each time-step independently. There are a total of 2*n_channels*n_steps parameters learnt. Args: name: variable scope. x: 5-D Tensor, (NTHWC) logscale_factor: Increases the learning rate of the scale by logscale_...
python
def actnorm_3d(name, x, logscale_factor=3.): """Applies actnorm to each time-step independently. There are a total of 2*n_channels*n_steps parameters learnt. Args: name: variable scope. x: 5-D Tensor, (NTHWC) logscale_factor: Increases the learning rate of the scale by logscale_...
[ "def", "actnorm_3d", "(", "name", ",", "x", ",", "logscale_factor", "=", "3.", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "x", "=", "tf", ".", "unstack", "(", "x", ",", "axis", ...
Applies actnorm to each time-step independently. There are a total of 2*n_channels*n_steps parameters learnt. Args: name: variable scope. x: 5-D Tensor, (NTHWC) logscale_factor: Increases the learning rate of the scale by logscale_factor. Returns: x: 5-D Tensor, (NTHWC) with...
[ "Applies", "actnorm", "to", "each", "time", "-", "step", "independently", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L202-L222
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
actnorm
def actnorm(name, x, logscale_factor=3., reverse=False, init=False, trainable=True): """x_{ij} = s x x_{ij} + b. Per-channel scaling and bias. If init is set to True, the scaling and bias are initialized such that the mean and variance of the output activations of the first minibatch are zero and o...
python
def actnorm(name, x, logscale_factor=3., reverse=False, init=False, trainable=True): """x_{ij} = s x x_{ij} + b. Per-channel scaling and bias. If init is set to True, the scaling and bias are initialized such that the mean and variance of the output activations of the first minibatch are zero and o...
[ "def", "actnorm", "(", "name", ",", "x", ",", "logscale_factor", "=", "3.", ",", "reverse", "=", "False", ",", "init", "=", "False", ",", "trainable", "=", "True", ")", ":", "var_arg_scope", "=", "arg_scope", "(", "[", "get_variable_ddi", "]", ",", "tr...
x_{ij} = s x x_{ij} + b. Per-channel scaling and bias. If init is set to True, the scaling and bias are initialized such that the mean and variance of the output activations of the first minibatch are zero and one respectively. Args: name: variable scope. x: input logscale_factor: Used in actnorm_...
[ "x_", "{", "ij", "}", "=", "s", "x", "x_", "{", "ij", "}", "+", "b", ".", "Per", "-", "channel", "scaling", "and", "bias", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L226-L261
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
actnorm_center
def actnorm_center(name, x, reverse=False, init=False): """Add a bias to x. Initialize such that the output of the first minibatch is zero centered per channel. Args: name: scope x: 2-D or 4-D Tensor. reverse: Forward or backward operation. init: data-dependent initialization. Returns: ...
python
def actnorm_center(name, x, reverse=False, init=False): """Add a bias to x. Initialize such that the output of the first minibatch is zero centered per channel. Args: name: scope x: 2-D or 4-D Tensor. reverse: Forward or backward operation. init: data-dependent initialization. Returns: ...
[ "def", "actnorm_center", "(", "name", ",", "x", ",", "reverse", "=", "False", ",", "init", "=", "False", ")", ":", "shape", "=", "common_layers", ".", "shape_list", "(", "x", ")", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "...
Add a bias to x. Initialize such that the output of the first minibatch is zero centered per channel. Args: name: scope x: 2-D or 4-D Tensor. reverse: Forward or backward operation. init: data-dependent initialization. Returns: x_center: (x + b), if reverse is True and (x - b) otherwise.
[ "Add", "a", "bias", "to", "x", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L265-L296
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
actnorm_scale
def actnorm_scale(name, x, logscale_factor=3., reverse=False, init=False): """Per-channel scaling of x.""" x_shape = common_layers.shape_list(x) with tf.variable_scope(name, reuse=tf.AUTO_REUSE): # Variance initialization logic. assert len(x_shape) == 2 or len(x_shape) == 4 if len(x_shape) == 2: ...
python
def actnorm_scale(name, x, logscale_factor=3., reverse=False, init=False): """Per-channel scaling of x.""" x_shape = common_layers.shape_list(x) with tf.variable_scope(name, reuse=tf.AUTO_REUSE): # Variance initialization logic. assert len(x_shape) == 2 or len(x_shape) == 4 if len(x_shape) == 2: ...
[ "def", "actnorm_scale", "(", "name", ",", "x", ",", "logscale_factor", "=", "3.", ",", "reverse", "=", "False", ",", "init", "=", "False", ")", ":", "x_shape", "=", "common_layers", ".", "shape_list", "(", "x", ")", "with", "tf", ".", "variable_scope", ...
Per-channel scaling of x.
[ "Per", "-", "channel", "scaling", "of", "x", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L300-L331
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
invertible_1x1_conv
def invertible_1x1_conv(name, x, reverse=False): """1X1 convolution on x. The 1X1 convolution is parametrized as P*L*(U + sign(s)*exp(log(s))) where 1. P is a permutation matrix. 2. L is a lower triangular matrix with diagonal entries unity. 3. U is a upper triangular matrix where the diagonal entries zero. ...
python
def invertible_1x1_conv(name, x, reverse=False): """1X1 convolution on x. The 1X1 convolution is parametrized as P*L*(U + sign(s)*exp(log(s))) where 1. P is a permutation matrix. 2. L is a lower triangular matrix with diagonal entries unity. 3. U is a upper triangular matrix where the diagonal entries zero. ...
[ "def", "invertible_1x1_conv", "(", "name", ",", "x", ",", "reverse", "=", "False", ")", ":", "_", ",", "height", ",", "width", ",", "channels", "=", "common_layers", ".", "shape_list", "(", "x", ")", "w_shape", "=", "[", "channels", ",", "channels", "]...
1X1 convolution on x. The 1X1 convolution is parametrized as P*L*(U + sign(s)*exp(log(s))) where 1. P is a permutation matrix. 2. L is a lower triangular matrix with diagonal entries unity. 3. U is a upper triangular matrix where the diagonal entries zero. 4. s is a vector. sign(s) and P are fixed and the...
[ "1X1", "convolution", "on", "x", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L335-L401
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
add_edge_bias
def add_edge_bias(x, filter_size): """Pad x and concatenates an edge bias across the depth of x. The edge bias can be thought of as a binary feature which is unity when the filter is being convolved over an edge and zero otherwise. Args: x: Input tensor, shape (NHWC) filter_size: filter_size to determ...
python
def add_edge_bias(x, filter_size): """Pad x and concatenates an edge bias across the depth of x. The edge bias can be thought of as a binary feature which is unity when the filter is being convolved over an edge and zero otherwise. Args: x: Input tensor, shape (NHWC) filter_size: filter_size to determ...
[ "def", "add_edge_bias", "(", "x", ",", "filter_size", ")", ":", "x_shape", "=", "common_layers", ".", "shape_list", "(", "x", ")", "if", "filter_size", "[", "0", "]", "==", "1", "and", "filter_size", "[", "1", "]", "==", "1", ":", "return", "x", "a",...
Pad x and concatenates an edge bias across the depth of x. The edge bias can be thought of as a binary feature which is unity when the filter is being convolved over an edge and zero otherwise. Args: x: Input tensor, shape (NHWC) filter_size: filter_size to determine padding. Returns: x_pad: Input...
[ "Pad", "x", "and", "concatenates", "an", "edge", "bias", "across", "the", "depth", "of", "x", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L404-L426
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
time_pad
def time_pad(x, filter_size, dilations): """Pad left across time and pad valid across the spatial components. Also concats a binary feature that indicates if a feature is padded or not. Args: x: 5-D Tensor, (NTHWC) filter_size: list of ints dilations: list of ints, dilations - 1 specifies the number...
python
def time_pad(x, filter_size, dilations): """Pad left across time and pad valid across the spatial components. Also concats a binary feature that indicates if a feature is padded or not. Args: x: 5-D Tensor, (NTHWC) filter_size: list of ints dilations: list of ints, dilations - 1 specifies the number...
[ "def", "time_pad", "(", "x", ",", "filter_size", ",", "dilations", ")", ":", "x_shape", "=", "common_layers", ".", "shape_list", "(", "x", ")", "if", "filter_size", "==", "[", "1", ",", "1", ",", "1", "]", ":", "return", "x", "_", ",", "h", ",", ...
Pad left across time and pad valid across the spatial components. Also concats a binary feature that indicates if a feature is padded or not. Args: x: 5-D Tensor, (NTHWC) filter_size: list of ints dilations: list of ints, dilations - 1 specifies the number of holes between two filter el...
[ "Pad", "left", "across", "time", "and", "pad", "valid", "across", "the", "spatial", "components", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L429-L461
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
conv
def conv(name, x, output_channels, filter_size=None, stride=None, logscale_factor=3.0, apply_actnorm=True, conv_init="default", dilations=None): """Convolutional layer with edge bias padding and optional actnorm. If x is 5-dimensional, actnorm is applied independently across every time-step. ...
python
def conv(name, x, output_channels, filter_size=None, stride=None, logscale_factor=3.0, apply_actnorm=True, conv_init="default", dilations=None): """Convolutional layer with edge bias padding and optional actnorm. If x is 5-dimensional, actnorm is applied independently across every time-step. ...
[ "def", "conv", "(", "name", ",", "x", ",", "output_channels", ",", "filter_size", "=", "None", ",", "stride", "=", "None", ",", "logscale_factor", "=", "3.0", ",", "apply_actnorm", "=", "True", ",", "conv_init", "=", "\"default\"", ",", "dilations", "=", ...
Convolutional layer with edge bias padding and optional actnorm. If x is 5-dimensional, actnorm is applied independently across every time-step. Args: name: variable scope. x: 4-D Tensor or 5-D Tensor of shape NHWC or NTHWC output_channels: Number of output channels. filter_size: list of ints, i...
[ "Convolutional", "layer", "with", "edge", "bias", "padding", "and", "optional", "actnorm", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L465-L544
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
conv_block
def conv_block(name, x, mid_channels, dilations=None, activation="relu", dropout=0.0): """2 layer conv block used in the affine coupling layer. Args: name: variable scope. x: 4-D or 5-D Tensor. mid_channels: Output channels of the second layer. dilations: Optional, list of integers. ...
python
def conv_block(name, x, mid_channels, dilations=None, activation="relu", dropout=0.0): """2 layer conv block used in the affine coupling layer. Args: name: variable scope. x: 4-D or 5-D Tensor. mid_channels: Output channels of the second layer. dilations: Optional, list of integers. ...
[ "def", "conv_block", "(", "name", ",", "x", ",", "mid_channels", ",", "dilations", "=", "None", ",", "activation", "=", "\"relu\"", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", ...
2 layer conv block used in the affine coupling layer. Args: name: variable scope. x: 4-D or 5-D Tensor. mid_channels: Output channels of the second layer. dilations: Optional, list of integers. activation: relu or gatu. If relu, the second layer is relu(W*x) If gatu, the second layer ...
[ "2", "layer", "conv", "block", "used", "in", "the", "affine", "coupling", "layer", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L548-L603
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
dilated_conv_stack
def dilated_conv_stack(name, x, mid_channels, output_channels, dilation_rates, activation="relu", dropout=0.0): """Dilated convolutional stack. Features at different rates are computed independently using a 3 layer convolutional stack and added. Args: name: va...
python
def dilated_conv_stack(name, x, mid_channels, output_channels, dilation_rates, activation="relu", dropout=0.0): """Dilated convolutional stack. Features at different rates are computed independently using a 3 layer convolutional stack and added. Args: name: va...
[ "def", "dilated_conv_stack", "(", "name", ",", "x", ",", "mid_channels", ",", "output_channels", ",", "dilation_rates", ",", "activation", "=", "\"relu\"", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", ...
Dilated convolutional stack. Features at different rates are computed independently using a 3 layer convolutional stack and added. Args: name: variable scope. x: 5-D Tensor. mid_channels: Number of output channels of the first layer in the conv stack. output_channels: Number of...
[ "Dilated", "convolutional", "stack", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L606-L634
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
conv_stack
def conv_stack(name, x, mid_channels, output_channels, dilations=None, activation="relu", dropout=0.0): """3-layer convolutional stack. Args: name: variable scope. x: 5-D Tensor. mid_channels: Number of output channels of the first layer. output_channels: Number of output channels. ...
python
def conv_stack(name, x, mid_channels, output_channels, dilations=None, activation="relu", dropout=0.0): """3-layer convolutional stack. Args: name: variable scope. x: 5-D Tensor. mid_channels: Number of output channels of the first layer. output_channels: Number of output channels. ...
[ "def", "conv_stack", "(", "name", ",", "x", ",", "mid_channels", ",", "output_channels", ",", "dilations", "=", "None", ",", "activation", "=", "\"relu\"", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reus...
3-layer convolutional stack. Args: name: variable scope. x: 5-D Tensor. mid_channels: Number of output channels of the first layer. output_channels: Number of output channels. dilations: Dilations to apply in the first 3x3 layer and the last 3x3 layer. By default, apply no dilation...
[ "3", "-", "layer", "convolutional", "stack", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L638-L665
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
additive_coupling
def additive_coupling(name, x, mid_channels=512, reverse=False, activation="relu", dropout=0.0): """Reversible additive coupling layer. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). mid_channels: number of channels in the coupling layer. reverse: Forward or reverse ...
python
def additive_coupling(name, x, mid_channels=512, reverse=False, activation="relu", dropout=0.0): """Reversible additive coupling layer. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). mid_channels: number of channels in the coupling layer. reverse: Forward or reverse ...
[ "def", "additive_coupling", "(", "name", ",", "x", ",", "mid_channels", "=", "512", ",", "reverse", "=", "False", ",", "activation", "=", "\"relu\"", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", ...
Reversible additive coupling layer. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). mid_channels: number of channels in the coupling layer. reverse: Forward or reverse operation. activation: "relu" or "gatu" dropout: default, 0.0 Returns: output: 4-D Tensor, shape=(NHWC) ob...
[ "Reversible", "additive", "coupling", "layer", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L669-L696
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
affine_coupling
def affine_coupling(name, x, mid_channels=512, activation="relu", reverse=False, dropout=0.0): """Reversible affine coupling layer. Args: name: variable scope. x: 4-D Tensor. mid_channels: number of channels in the coupling layer. activation: Can be either "relu" or "gatu". ...
python
def affine_coupling(name, x, mid_channels=512, activation="relu", reverse=False, dropout=0.0): """Reversible affine coupling layer. Args: name: variable scope. x: 4-D Tensor. mid_channels: number of channels in the coupling layer. activation: Can be either "relu" or "gatu". ...
[ "def", "affine_coupling", "(", "name", ",", "x", ",", "mid_channels", "=", "512", ",", "activation", "=", "\"relu\"", ",", "reverse", "=", "False", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=...
Reversible affine coupling layer. Args: name: variable scope. x: 4-D Tensor. mid_channels: number of channels in the coupling layer. activation: Can be either "relu" or "gatu". reverse: Forward or reverse operation. dropout: default, 0.0 Returns: output: x shifted and scaled by an affin...
[ "Reversible", "affine", "coupling", "layer", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L700-L738
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
squeeze
def squeeze(name, x, factor=2, reverse=True): """Block-wise spatial squeezing of x to increase the number of channels. Args: name: Used for variable scoping. x: 4-D Tensor of shape (batch_size X H X W X C) factor: Factor by which the spatial dimensions should be squeezed. reverse: Squueze or unsque...
python
def squeeze(name, x, factor=2, reverse=True): """Block-wise spatial squeezing of x to increase the number of channels. Args: name: Used for variable scoping. x: 4-D Tensor of shape (batch_size X H X W X C) factor: Factor by which the spatial dimensions should be squeezed. reverse: Squueze or unsque...
[ "def", "squeeze", "(", "name", ",", "x", ",", "factor", "=", "2", ",", "reverse", "=", "True", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "shape", "=", "common_layers", ".", "sh...
Block-wise spatial squeezing of x to increase the number of channels. Args: name: Used for variable scoping. x: 4-D Tensor of shape (batch_size X H X W X C) factor: Factor by which the spatial dimensions should be squeezed. reverse: Squueze or unsqueeze operation. Returns: x: 4-D Tensor of sha...
[ "Block", "-", "wise", "spatial", "squeezing", "of", "x", "to", "increase", "the", "number", "of", "channels", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L742-L776
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
get_dilation_rates
def get_dilation_rates(hparams, width): """Get a list of valid dilation rates. Args: hparams: HParams. width: spatial dimension. Ensures that the effective filter size is not larger than the spatial dimension. Returns: allowed_dilations: A list of dilation rates. """ # dil_rate=1 means...
python
def get_dilation_rates(hparams, width): """Get a list of valid dilation rates. Args: hparams: HParams. width: spatial dimension. Ensures that the effective filter size is not larger than the spatial dimension. Returns: allowed_dilations: A list of dilation rates. """ # dil_rate=1 means...
[ "def", "get_dilation_rates", "(", "hparams", ",", "width", ")", ":", "# dil_rate=1 means no dilation.", "allowed_dilations", "=", "[", "[", "1", "]", "*", "5", "]", "apply_dilations", "=", "hparams", ".", "get", "(", "\"latent_apply_dilations\"", ",", "False", "...
Get a list of valid dilation rates. Args: hparams: HParams. width: spatial dimension. Ensures that the effective filter size is not larger than the spatial dimension. Returns: allowed_dilations: A list of dilation rates.
[ "Get", "a", "list", "of", "valid", "dilation", "rates", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L779-L800
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
temporal_latent_to_dist
def temporal_latent_to_dist(name, x, hparams, output_channels=None): """Network that maps a time-indexed list of 3-D latents to a gaussian. Args: name: variable scope. x: List of 4-D Tensors indexed by time, (NHWC) hparams: tf.contrib.training.Hparams. output_channels: int, Number of channels of th...
python
def temporal_latent_to_dist(name, x, hparams, output_channels=None): """Network that maps a time-indexed list of 3-D latents to a gaussian. Args: name: variable scope. x: List of 4-D Tensors indexed by time, (NHWC) hparams: tf.contrib.training.Hparams. output_channels: int, Number of channels of th...
[ "def", "temporal_latent_to_dist", "(", "name", ",", "x", ",", "hparams", ",", "output_channels", "=", "None", ")", ":", "_", ",", "_", ",", "width", ",", "_", ",", "res_channels", "=", "common_layers", ".", "shape_list", "(", "x", ")", "if", "output_chan...
Network that maps a time-indexed list of 3-D latents to a gaussian. Args: name: variable scope. x: List of 4-D Tensors indexed by time, (NHWC) hparams: tf.contrib.training.Hparams. output_channels: int, Number of channels of the output gaussian mean. Returns: dist: tfp.distributions.Normal
[ "Network", "that", "maps", "a", "time", "-", "indexed", "list", "of", "3", "-", "D", "latents", "to", "a", "gaussian", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L804-L843
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
single_conv_dist
def single_conv_dist(name, x, output_channels=None): """A 3x3 convolution mapping x to a standard normal distribution at init. Args: name: variable scope. x: 4-D Tensor. output_channels: number of channels of the mean and std. """ with tf.variable_scope(name, reuse=tf.AUTO_REUSE): x_shape = com...
python
def single_conv_dist(name, x, output_channels=None): """A 3x3 convolution mapping x to a standard normal distribution at init. Args: name: variable scope. x: 4-D Tensor. output_channels: number of channels of the mean and std. """ with tf.variable_scope(name, reuse=tf.AUTO_REUSE): x_shape = com...
[ "def", "single_conv_dist", "(", "name", ",", "x", ",", "output_channels", "=", "None", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "x_shape", "=", "common_layers", ".", "shape_list", "...
A 3x3 convolution mapping x to a standard normal distribution at init. Args: name: variable scope. x: 4-D Tensor. output_channels: number of channels of the mean and std.
[ "A", "3x3", "convolution", "mapping", "x", "to", "a", "standard", "normal", "distribution", "at", "init", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L847-L863
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
latent_to_dist
def latent_to_dist(name, x, hparams, output_channels=None): """Map latent to the mean and log-scale of a Gaussian. Args: name: variable scope. x: 4-D Tensor of shape (NHWC) hparams: HParams. latent_architecture - can be "single_conv", "glow_nn" or "glow_resnet", defaul...
python
def latent_to_dist(name, x, hparams, output_channels=None): """Map latent to the mean and log-scale of a Gaussian. Args: name: variable scope. x: 4-D Tensor of shape (NHWC) hparams: HParams. latent_architecture - can be "single_conv", "glow_nn" or "glow_resnet", defaul...
[ "def", "latent_to_dist", "(", "name", ",", "x", ",", "hparams", ",", "output_channels", "=", "None", ")", ":", "architecture", "=", "hparams", ".", "get", "(", "\"latent_architecture\"", ",", "\"single_conv\"", ")", "depth", "=", "hparams", ".", "get", "(", ...
Map latent to the mean and log-scale of a Gaussian. Args: name: variable scope. x: 4-D Tensor of shape (NHWC) hparams: HParams. latent_architecture - can be "single_conv", "glow_nn" or "glow_resnet", default = single_conv latent_encoder_depth - int, depth of archit...
[ "Map", "latent", "to", "the", "mean", "and", "log", "-", "scale", "of", "a", "Gaussian", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L867-L925
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
noise_op
def noise_op(latents, hparams): """Adds isotropic gaussian-noise to each latent. Args: latents: 4-D or 5-D tensor, shape=(NTHWC) or (NHWC). hparams: HParams. Returns: latents: latents with isotropic gaussian noise appended. """ if hparams.latent_noise == 0 or hparams.mode != tf.estimator.ModeKeys...
python
def noise_op(latents, hparams): """Adds isotropic gaussian-noise to each latent. Args: latents: 4-D or 5-D tensor, shape=(NTHWC) or (NHWC). hparams: HParams. Returns: latents: latents with isotropic gaussian noise appended. """ if hparams.latent_noise == 0 or hparams.mode != tf.estimator.ModeKeys...
[ "def", "noise_op", "(", "latents", ",", "hparams", ")", ":", "if", "hparams", ".", "latent_noise", "==", "0", "or", "hparams", ".", "mode", "!=", "tf", ".", "estimator", ".", "ModeKeys", ".", "TRAIN", ":", "return", "latents", "latent_shape", "=", "commo...
Adds isotropic gaussian-noise to each latent. Args: latents: 4-D or 5-D tensor, shape=(NTHWC) or (NHWC). hparams: HParams. Returns: latents: latents with isotropic gaussian noise appended.
[ "Adds", "isotropic", "gaussian", "-", "noise", "to", "each", "latent", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L929-L941
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
merge_level_and_latent_dist
def merge_level_and_latent_dist(level_dist, latent_dist, merge_std="prev_level"): """Merge level_dist and latent_dist. new_dist ~ N(level_dist.mean + latent_dis.mean, std) where std is determined according to merge_std. Args: level_dist: instance of tfp.distributions.Normal...
python
def merge_level_and_latent_dist(level_dist, latent_dist, merge_std="prev_level"): """Merge level_dist and latent_dist. new_dist ~ N(level_dist.mean + latent_dis.mean, std) where std is determined according to merge_std. Args: level_dist: instance of tfp.distributions.Normal...
[ "def", "merge_level_and_latent_dist", "(", "level_dist", ",", "latent_dist", ",", "merge_std", "=", "\"prev_level\"", ")", ":", "level_mean", ",", "level_std", "=", "level_dist", ".", "loc", ",", "level_dist", ".", "scale", "latent_mean", ",", "latent_std", "=", ...
Merge level_dist and latent_dist. new_dist ~ N(level_dist.mean + latent_dis.mean, std) where std is determined according to merge_std. Args: level_dist: instance of tfp.distributions.Normal latent_dist: instance of tfp.distributions.Normal merge_std: can be "prev_level", "prev_step" or "normal". R...
[ "Merge", "level_dist", "and", "latent_dist", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L945-L972
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
level_cond_prior
def level_cond_prior(prior_dist, z, latent, hparams, state): """Returns a conditional prior for each level. Args: prior_dist: Distribution conditioned on the previous levels. z: Tensor, output of the previous levels. latent: Tensor or a list of tensors to condition the latent_distribution. hparams:...
python
def level_cond_prior(prior_dist, z, latent, hparams, state): """Returns a conditional prior for each level. Args: prior_dist: Distribution conditioned on the previous levels. z: Tensor, output of the previous levels. latent: Tensor or a list of tensors to condition the latent_distribution. hparams:...
[ "def", "level_cond_prior", "(", "prior_dist", ",", "z", ",", "latent", ",", "hparams", ",", "state", ")", ":", "latent_dist_encoder", "=", "hparams", ".", "get", "(", "\"latent_dist_encoder\"", ",", "None", ")", "latent_skip", "=", "hparams", ".", "get", "("...
Returns a conditional prior for each level. Args: prior_dist: Distribution conditioned on the previous levels. z: Tensor, output of the previous levels. latent: Tensor or a list of tensors to condition the latent_distribution. hparams: next_frame_glow hparams. state: Current LSTM state. Used only...
[ "Returns", "a", "conditional", "prior", "for", "each", "level", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L976-L1044
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
compute_prior
def compute_prior(name, z, latent, hparams, condition=False, state=None, temperature=1.0): """Distribution on z_t conditioned on z_{t-1} and latent. Args: name: variable scope. z: 4-D Tensor. latent: optional, if hparams.latent_dist_encoder == "pointwise", this is a list ...
python
def compute_prior(name, z, latent, hparams, condition=False, state=None, temperature=1.0): """Distribution on z_t conditioned on z_{t-1} and latent. Args: name: variable scope. z: 4-D Tensor. latent: optional, if hparams.latent_dist_encoder == "pointwise", this is a list ...
[ "def", "compute_prior", "(", "name", ",", "z", ",", "latent", ",", "hparams", ",", "condition", "=", "False", ",", "state", "=", "None", ",", "temperature", "=", "1.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "t...
Distribution on z_t conditioned on z_{t-1} and latent. Args: name: variable scope. z: 4-D Tensor. latent: optional, if hparams.latent_dist_encoder == "pointwise", this is a list of 4-D Tensors of length hparams.num_cond_latents. else, this is just a 4-D Tensor ...
[ "Distribution", "on", "z_t", "conditioned", "on", "z_", "{", "t", "-", "1", "}", "and", "latent", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1048-L1088
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
split
def split(name, x, reverse=False, eps=None, eps_std=None, cond_latents=None, hparams=None, state=None, condition=False, temperature=1.0): """Splits / concatenates x into x1 and x2 across number of channels. For the forward pass, x2 is assumed be gaussian, i.e P(x2 | x1) ~ N(mu, sigma) where mu and sigm...
python
def split(name, x, reverse=False, eps=None, eps_std=None, cond_latents=None, hparams=None, state=None, condition=False, temperature=1.0): """Splits / concatenates x into x1 and x2 across number of channels. For the forward pass, x2 is assumed be gaussian, i.e P(x2 | x1) ~ N(mu, sigma) where mu and sigm...
[ "def", "split", "(", "name", ",", "x", ",", "reverse", "=", "False", ",", "eps", "=", "None", ",", "eps_std", "=", "None", ",", "cond_latents", "=", "None", ",", "hparams", "=", "None", ",", "state", "=", "None", ",", "condition", "=", "False", ","...
Splits / concatenates x into x1 and x2 across number of channels. For the forward pass, x2 is assumed be gaussian, i.e P(x2 | x1) ~ N(mu, sigma) where mu and sigma are the outputs of a network conditioned on x1 and optionally on cond_latents. For the reverse pass, x2 is determined from mu(x1) and sigma(x1). ...
[ "Splits", "/", "concatenates", "x", "into", "x1", "and", "x2", "across", "number", "of", "channels", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1092-L1152
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
revnet_step
def revnet_step(name, x, hparams, reverse=True): """One step of glow generative flow. Actnorm + invertible 1X1 conv + affine_coupling. Args: name: used for variable scope. x: input hparams: coupling_width is the only hparam that is being used in this function. reverse: forward or re...
python
def revnet_step(name, x, hparams, reverse=True): """One step of glow generative flow. Actnorm + invertible 1X1 conv + affine_coupling. Args: name: used for variable scope. x: input hparams: coupling_width is the only hparam that is being used in this function. reverse: forward or re...
[ "def", "revnet_step", "(", "name", ",", "x", ",", "hparams", ",", "reverse", "=", "True", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "if", "hparams", ".", "coupling", "==", "\"add...
One step of glow generative flow. Actnorm + invertible 1X1 conv + affine_coupling. Args: name: used for variable scope. x: input hparams: coupling_width is the only hparam that is being used in this function. reverse: forward or reverse pass. Returns: z: Output of one step of re...
[ "One", "step", "of", "glow", "generative", "flow", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1156-L1193
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
revnet
def revnet(name, x, hparams, reverse=True): """'hparams.depth' steps of generative flow. Args: name: variable scope for the revnet block. x: 4-D Tensor, shape=(NHWC). hparams: HParams. reverse: bool, forward or backward pass. Returns: x: 4-D Tensor, shape=(NHWC). objective: float. """ ...
python
def revnet(name, x, hparams, reverse=True): """'hparams.depth' steps of generative flow. Args: name: variable scope for the revnet block. x: 4-D Tensor, shape=(NHWC). hparams: HParams. reverse: bool, forward or backward pass. Returns: x: 4-D Tensor, shape=(NHWC). objective: float. """ ...
[ "def", "revnet", "(", "name", ",", "x", ",", "hparams", ",", "reverse", "=", "True", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "steps", "=", "np", ".", "arange", "(", "hparams"...
hparams.depth' steps of generative flow. Args: name: variable scope for the revnet block. x: 4-D Tensor, shape=(NHWC). hparams: HParams. reverse: bool, forward or backward pass. Returns: x: 4-D Tensor, shape=(NHWC). objective: float.
[ "hparams", ".", "depth", "steps", "of", "generative", "flow", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1196-L1218
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
scale_gaussian_prior
def scale_gaussian_prior(name, z, logscale_factor=3.0, trainable=True): """Returns N(s^i * z^i, std^i) where s^i and std^i are pre-component. s^i is a learnable parameter with identity initialization. std^i is optionally learnable with identity initialization. Args: name: variable scope. z: input_tens...
python
def scale_gaussian_prior(name, z, logscale_factor=3.0, trainable=True): """Returns N(s^i * z^i, std^i) where s^i and std^i are pre-component. s^i is a learnable parameter with identity initialization. std^i is optionally learnable with identity initialization. Args: name: variable scope. z: input_tens...
[ "def", "scale_gaussian_prior", "(", "name", ",", "z", ",", "logscale_factor", "=", "3.0", ",", "trainable", "=", "True", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "z_shape", "=", "...
Returns N(s^i * z^i, std^i) where s^i and std^i are pre-component. s^i is a learnable parameter with identity initialization. std^i is optionally learnable with identity initialization. Args: name: variable scope. z: input_tensor logscale_factor: equivalent to scaling up the learning_rate by a facto...
[ "Returns", "N", "(", "s^i", "*", "z^i", "std^i", ")", "where", "s^i", "and", "std^i", "are", "pre", "-", "component", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1222-L1245
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
top_prior
def top_prior(name, z_shape, learn_prior="normal", temperature=1.0): """Unconditional prior distribution. Args: name: variable scope z_shape: Shape of the mean / scale of the prior distribution. learn_prior: Possible options are "normal" and "single_conv". If set to "single_conv", the ...
python
def top_prior(name, z_shape, learn_prior="normal", temperature=1.0): """Unconditional prior distribution. Args: name: variable scope z_shape: Shape of the mean / scale of the prior distribution. learn_prior: Possible options are "normal" and "single_conv". If set to "single_conv", the ...
[ "def", "top_prior", "(", "name", ",", "z_shape", ",", "learn_prior", "=", "\"normal\"", ",", "temperature", "=", "1.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "h", "=", "tf", ...
Unconditional prior distribution. Args: name: variable scope z_shape: Shape of the mean / scale of the prior distribution. learn_prior: Possible options are "normal" and "single_conv". If set to "single_conv", the gaussian is parametrized by a single convolutional layer ...
[ "Unconditional", "prior", "distribution", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1249-L1276
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
uniform_binning_correction
def uniform_binning_correction(x, n_bits=8): """Replaces x^i with q^i(x) = U(x, x + 1.0 / 256.0). Args: x: 4-D Tensor of shape (NHWC) n_bits: optional. Returns: x: x ~ U(x, x + 1.0 / 256) objective: Equivalent to -q(x)*log(q(x)). """ n_bins = 2**n_bits batch_size, height, width, n_channels ...
python
def uniform_binning_correction(x, n_bits=8): """Replaces x^i with q^i(x) = U(x, x + 1.0 / 256.0). Args: x: 4-D Tensor of shape (NHWC) n_bits: optional. Returns: x: x ~ U(x, x + 1.0 / 256) objective: Equivalent to -q(x)*log(q(x)). """ n_bins = 2**n_bits batch_size, height, width, n_channels ...
[ "def", "uniform_binning_correction", "(", "x", ",", "n_bits", "=", "8", ")", ":", "n_bins", "=", "2", "**", "n_bits", "batch_size", ",", "height", ",", "width", ",", "n_channels", "=", "common_layers", ".", "shape_list", "(", "x", ")", "hwc", "=", "float...
Replaces x^i with q^i(x) = U(x, x + 1.0 / 256.0). Args: x: 4-D Tensor of shape (NHWC) n_bits: optional. Returns: x: x ~ U(x, x + 1.0 / 256) objective: Equivalent to -q(x)*log(q(x)).
[ "Replaces", "x^i", "with", "q^i", "(", "x", ")", "=", "U", "(", "x", "x", "+", "1", ".", "0", "/", "256", ".", "0", ")", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1279-L1297
train
tensorflow/tensor2tensor
tensor2tensor/models/research/glow_ops.py
encoder_decoder
def encoder_decoder(name, x, hparams, eps=None, reverse=False, cond_latents=None, condition=False, states=None, temperature=1.0): """Glow encoder-decoder. n_levels of (Squeeze + Flow + Split.) operations. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). h...
python
def encoder_decoder(name, x, hparams, eps=None, reverse=False, cond_latents=None, condition=False, states=None, temperature=1.0): """Glow encoder-decoder. n_levels of (Squeeze + Flow + Split.) operations. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). h...
[ "def", "encoder_decoder", "(", "name", ",", "x", ",", "hparams", ",", "eps", "=", "None", ",", "reverse", "=", "False", ",", "cond_latents", "=", "None", ",", "condition", "=", "False", ",", "states", "=", "None", ",", "temperature", "=", "1.0", ")", ...
Glow encoder-decoder. n_levels of (Squeeze + Flow + Split.) operations. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). hparams: HParams. eps: Stores (glow(x) - mu) / sigma during the forward pass. Used only to test if the network is reversible. reverse: Forward or reverse pass....
[ "Glow", "encoder", "-", "decoder", ".", "n_levels", "of", "(", "Squeeze", "+", "Flow", "+", "Split", ".", ")", "operations", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1301-L1392
train
tensorflow/tensor2tensor
tensor2tensor/utils/quantization.py
bfloat16_activations_var_getter
def bfloat16_activations_var_getter(getter, *args, **kwargs): """A custom getter function for float32 parameters and bfloat16 activations. Args: getter: custom getter *args: arguments **kwargs: keyword arguments Returns: variables with the correct dtype. Raises: KeyError: if "dtype" is not ...
python
def bfloat16_activations_var_getter(getter, *args, **kwargs): """A custom getter function for float32 parameters and bfloat16 activations. Args: getter: custom getter *args: arguments **kwargs: keyword arguments Returns: variables with the correct dtype. Raises: KeyError: if "dtype" is not ...
[ "def", "bfloat16_activations_var_getter", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "requested_dtype", "=", "kwargs", "[", "\"dtype\"", "]", "if", "requested_dtype", "==", "tf", ".", "bfloat16", ":", "kwargs", "[", "\"dtype\"", "]",...
A custom getter function for float32 parameters and bfloat16 activations. Args: getter: custom getter *args: arguments **kwargs: keyword arguments Returns: variables with the correct dtype. Raises: KeyError: if "dtype" is not provided as a kwarg.
[ "A", "custom", "getter", "function", "for", "float32", "parameters", "and", "bfloat16", "activations", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L25-L48
train
tensorflow/tensor2tensor
tensor2tensor/utils/quantization.py
float16_activations_var_getter
def float16_activations_var_getter(getter, *args, **kwargs): """A custom getter function for float32 parameters and float16 activations. This function ensures the following: 1. All variables requested with type fp16 are stored as type fp32. 2. All variables requested with type fp32 are returned as type fp1...
python
def float16_activations_var_getter(getter, *args, **kwargs): """A custom getter function for float32 parameters and float16 activations. This function ensures the following: 1. All variables requested with type fp16 are stored as type fp32. 2. All variables requested with type fp32 are returned as type fp1...
[ "def", "float16_activations_var_getter", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "requested_dtype", "=", "kwargs", "[", "\"dtype\"", "]", "if", "requested_dtype", "==", "tf", ".", "float16", ":", "kwargs", "[", "\"dtype\"", "]", ...
A custom getter function for float32 parameters and float16 activations. This function ensures the following: 1. All variables requested with type fp16 are stored as type fp32. 2. All variables requested with type fp32 are returned as type fp16. See https://docs.nvidia.com/deeplearning/sdk/mixed-precision-...
[ "A", "custom", "getter", "function", "for", "float32", "parameters", "and", "float16", "activations", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L51-L86
train
tensorflow/tensor2tensor
tensor2tensor/utils/quantization.py
simulated_quantize
def simulated_quantize(x, num_bits, noise): """Simulate quantization to num_bits bits, with externally-stored scale. num_bits is the number of bits used to store each value. noise is a float32 Tensor containing values in [0, 1). Each value in noise should take different values across different steps, approxi...
python
def simulated_quantize(x, num_bits, noise): """Simulate quantization to num_bits bits, with externally-stored scale. num_bits is the number of bits used to store each value. noise is a float32 Tensor containing values in [0, 1). Each value in noise should take different values across different steps, approxi...
[ "def", "simulated_quantize", "(", "x", ",", "num_bits", ",", "noise", ")", ":", "shape", "=", "x", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "if", "not", "(", "len", "(", "shape", ")", ">=", "2", "and", "shape", "[", "-", "1", "]", ...
Simulate quantization to num_bits bits, with externally-stored scale. num_bits is the number of bits used to store each value. noise is a float32 Tensor containing values in [0, 1). Each value in noise should take different values across different steps, approximating a uniform distribution over [0, 1). In t...
[ "Simulate", "quantization", "to", "num_bits", "bits", "with", "externally", "-", "stored", "scale", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L89-L134
train
tensorflow/tensor2tensor
tensor2tensor/utils/quantization.py
noise_from_step_num
def noise_from_step_num(): """Quantization noise equal to (phi * (step_num + 1)) mod 1.0. Not using random_uniform here due to a problem on TPU in that random seeds are not respected, which may cause the parameters on different replicas to go out-of-sync. Returns: a float32 scalar """ step = tf.to_i...
python
def noise_from_step_num(): """Quantization noise equal to (phi * (step_num + 1)) mod 1.0. Not using random_uniform here due to a problem on TPU in that random seeds are not respected, which may cause the parameters on different replicas to go out-of-sync. Returns: a float32 scalar """ step = tf.to_i...
[ "def", "noise_from_step_num", "(", ")", ":", "step", "=", "tf", ".", "to_int32", "(", "tf", ".", "train", ".", "get_or_create_global_step", "(", ")", ")", "+", "1", "phi", "=", "(", "(", "5", "**", "0.5", ")", "-", "1", ")", "/", "2", "# Naive comp...
Quantization noise equal to (phi * (step_num + 1)) mod 1.0. Not using random_uniform here due to a problem on TPU in that random seeds are not respected, which may cause the parameters on different replicas to go out-of-sync. Returns: a float32 scalar
[ "Quantization", "noise", "equal", "to", "(", "phi", "*", "(", "step_num", "+", "1", "))", "mod", "1", ".", "0", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L137-L157
train
tensorflow/tensor2tensor
tensor2tensor/utils/quantization.py
_randomized_roundoff_to_bfloat16
def _randomized_roundoff_to_bfloat16(x, noise, cand1, cand2): """Round-off x to cand1 or to cand2 in an unbiased way. Cand1 and cand2 are the same shape as x. For every element of x, the corresponding elements of cand1 and cand2 should be the two closest bfloat16 values to x. Order does not matter. cand1 an...
python
def _randomized_roundoff_to_bfloat16(x, noise, cand1, cand2): """Round-off x to cand1 or to cand2 in an unbiased way. Cand1 and cand2 are the same shape as x. For every element of x, the corresponding elements of cand1 and cand2 should be the two closest bfloat16 values to x. Order does not matter. cand1 an...
[ "def", "_randomized_roundoff_to_bfloat16", "(", "x", ",", "noise", ",", "cand1", ",", "cand2", ")", ":", "cand1_f", "=", "tf", ".", "to_float", "(", "cand1", ")", "cand2_f", "=", "tf", ".", "to_float", "(", "cand2", ")", "step_size", "=", "cand2_f", "-",...
Round-off x to cand1 or to cand2 in an unbiased way. Cand1 and cand2 are the same shape as x. For every element of x, the corresponding elements of cand1 and cand2 should be the two closest bfloat16 values to x. Order does not matter. cand1 and cand2 must differ from each other. Args: x: A float32 Tens...
[ "Round", "-", "off", "x", "to", "cand1", "or", "to", "cand2", "in", "an", "unbiased", "way", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L160-L183
train
tensorflow/tensor2tensor
tensor2tensor/utils/quantization.py
_to_bfloat16_unbiased
def _to_bfloat16_unbiased(x, noise): """Convert a float32 to a bfloat16 using randomized roundoff. Args: x: A float32 Tensor. noise: a float32 Tensor with values in [0, 1), broadcastable to tf.shape(x) Returns: A float32 Tensor. """ x_sign = tf.sign(x) # Make sure x is positive. If it is zero,...
python
def _to_bfloat16_unbiased(x, noise): """Convert a float32 to a bfloat16 using randomized roundoff. Args: x: A float32 Tensor. noise: a float32 Tensor with values in [0, 1), broadcastable to tf.shape(x) Returns: A float32 Tensor. """ x_sign = tf.sign(x) # Make sure x is positive. If it is zero,...
[ "def", "_to_bfloat16_unbiased", "(", "x", ",", "noise", ")", ":", "x_sign", "=", "tf", ".", "sign", "(", "x", ")", "# Make sure x is positive. If it is zero, the two candidates are identical.", "x", "=", "x", "*", "x_sign", "+", "1e-30", "cand1", "=", "tf", "."...
Convert a float32 to a bfloat16 using randomized roundoff. Args: x: A float32 Tensor. noise: a float32 Tensor with values in [0, 1), broadcastable to tf.shape(x) Returns: A float32 Tensor.
[ "Convert", "a", "float32", "to", "a", "bfloat16", "using", "randomized", "roundoff", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L186-L206
train
tensorflow/tensor2tensor
tensor2tensor/utils/quantization.py
ParameterEncoding.custom_getter
def custom_getter(self, activation_dtype=tf.bfloat16): """A custom getter that uses the encoding for bfloat16 and float32 vars. When a bfloat16 or float32 variable is requsted, an encoded float16 varaible is created, which is then decoded and cast to a bfloat16 activation. Args: activation_d...
python
def custom_getter(self, activation_dtype=tf.bfloat16): """A custom getter that uses the encoding for bfloat16 and float32 vars. When a bfloat16 or float32 variable is requsted, an encoded float16 varaible is created, which is then decoded and cast to a bfloat16 activation. Args: activation_d...
[ "def", "custom_getter", "(", "self", ",", "activation_dtype", "=", "tf", ".", "bfloat16", ")", ":", "def", "getter_fn", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "requested_dtype", "=", "kwargs", "[", "\"dtype\"", "]", "if", "...
A custom getter that uses the encoding for bfloat16 and float32 vars. When a bfloat16 or float32 variable is requsted, an encoded float16 varaible is created, which is then decoded and cast to a bfloat16 activation. Args: activation_dtype: a dtype to which to convert the decoded value. Retu...
[ "A", "custom", "getter", "that", "uses", "the", "encoding", "for", "bfloat16", "and", "float32", "vars", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L246-L268
train
tensorflow/tensor2tensor
tensor2tensor/utils/video_metrics.py
load_videos
def load_videos(template, video_length, frame_shape): """Loads videos from files. Args: template: template string for listing the image files. video_length: length of the video. frame_shape: shape of each frame. Returns: dataset: the tf dataset frame by frame. dataset_len: number of the item...
python
def load_videos(template, video_length, frame_shape): """Loads videos from files. Args: template: template string for listing the image files. video_length: length of the video. frame_shape: shape of each frame. Returns: dataset: the tf dataset frame by frame. dataset_len: number of the item...
[ "def", "load_videos", "(", "template", ",", "video_length", ",", "frame_shape", ")", ":", "filenames", "=", "tf", ".", "gfile", ".", "Glob", "(", "template", ")", "if", "not", "filenames", ":", "raise", "ValueError", "(", "\"no files found.\"", ")", "filenam...
Loads videos from files. Args: template: template string for listing the image files. video_length: length of the video. frame_shape: shape of each frame. Returns: dataset: the tf dataset frame by frame. dataset_len: number of the items which is the number of image files. Raises: ValueE...
[ "Loads", "videos", "from", "files", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L38-L63
train
tensorflow/tensor2tensor
tensor2tensor/utils/video_metrics.py
psnr_and_ssim
def psnr_and_ssim(output, target): """Compute the PSNR and SSIM. Args: output: 4-D Tensor, shape=(num_frames, height, width, num_channels) target: 4-D Tensor, shape=(num_frames, height, width, num_channels) Returns: psnr: 1-D Tensor, shape=(num_frames,) ssim: 1-D Tensor, shape=(num_frames,) """...
python
def psnr_and_ssim(output, target): """Compute the PSNR and SSIM. Args: output: 4-D Tensor, shape=(num_frames, height, width, num_channels) target: 4-D Tensor, shape=(num_frames, height, width, num_channels) Returns: psnr: 1-D Tensor, shape=(num_frames,) ssim: 1-D Tensor, shape=(num_frames,) """...
[ "def", "psnr_and_ssim", "(", "output", ",", "target", ")", ":", "output", "=", "tf", ".", "cast", "(", "output", ",", "dtype", "=", "tf", ".", "int32", ")", "target", "=", "tf", ".", "cast", "(", "target", ",", "dtype", "=", "tf", ".", "int32", "...
Compute the PSNR and SSIM. Args: output: 4-D Tensor, shape=(num_frames, height, width, num_channels) target: 4-D Tensor, shape=(num_frames, height, width, num_channels) Returns: psnr: 1-D Tensor, shape=(num_frames,) ssim: 1-D Tensor, shape=(num_frames,)
[ "Compute", "the", "PSNR", "and", "SSIM", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L93-L107
train
tensorflow/tensor2tensor
tensor2tensor/utils/video_metrics.py
get_zipped_dataset_from_predictions
def get_zipped_dataset_from_predictions(predictions): """Creates dataset from in-memory predictions.""" targets = stack_data_given_key(predictions, "targets") outputs = stack_data_given_key(predictions, "outputs") num_videos, num_steps = targets.shape[:2] # Truncate output time-steps to match target time-ste...
python
def get_zipped_dataset_from_predictions(predictions): """Creates dataset from in-memory predictions.""" targets = stack_data_given_key(predictions, "targets") outputs = stack_data_given_key(predictions, "outputs") num_videos, num_steps = targets.shape[:2] # Truncate output time-steps to match target time-ste...
[ "def", "get_zipped_dataset_from_predictions", "(", "predictions", ")", ":", "targets", "=", "stack_data_given_key", "(", "predictions", ",", "\"targets\"", ")", "outputs", "=", "stack_data_given_key", "(", "predictions", ",", "\"outputs\"", ")", "num_videos", ",", "nu...
Creates dataset from in-memory predictions.
[ "Creates", "dataset", "from", "in", "-", "memory", "predictions", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L116-L132
train
tensorflow/tensor2tensor
tensor2tensor/utils/video_metrics.py
compute_one_decoding_video_metrics
def compute_one_decoding_video_metrics(iterator, feed_dict, num_videos): """Computes the average of all the metric for one decoding. Args: iterator: dataset iterator. feed_dict: feed dict to initialize iterator. num_videos: number of videos. Returns: all_psnr: 2-D Numpy array, shape=(num_samples...
python
def compute_one_decoding_video_metrics(iterator, feed_dict, num_videos): """Computes the average of all the metric for one decoding. Args: iterator: dataset iterator. feed_dict: feed dict to initialize iterator. num_videos: number of videos. Returns: all_psnr: 2-D Numpy array, shape=(num_samples...
[ "def", "compute_one_decoding_video_metrics", "(", "iterator", ",", "feed_dict", ",", "num_videos", ")", ":", "output", ",", "target", "=", "iterator", ".", "get_next", "(", ")", "metrics", "=", "psnr_and_ssim", "(", "output", ",", "target", ")", "with", "tf", ...
Computes the average of all the metric for one decoding. Args: iterator: dataset iterator. feed_dict: feed dict to initialize iterator. num_videos: number of videos. Returns: all_psnr: 2-D Numpy array, shape=(num_samples, num_frames) all_ssim: 2-D Numpy array, shape=(num_samples, num_frames)
[ "Computes", "the", "average", "of", "all", "the", "metric", "for", "one", "decoding", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L135-L164
train
tensorflow/tensor2tensor
tensor2tensor/utils/video_metrics.py
reduce_to_best_decode
def reduce_to_best_decode(metrics, reduce_func): """Extracts the best-decode from the metrics according to reduce_func. Args: metrics: 3-D numpy array, shape=(num_decodes, num_samples, num_frames) reduce_func: callable, np.argmax or np.argmin. Returns: best_metrics: 2-D numpy array, shape=(num_sample...
python
def reduce_to_best_decode(metrics, reduce_func): """Extracts the best-decode from the metrics according to reduce_func. Args: metrics: 3-D numpy array, shape=(num_decodes, num_samples, num_frames) reduce_func: callable, np.argmax or np.argmin. Returns: best_metrics: 2-D numpy array, shape=(num_sample...
[ "def", "reduce_to_best_decode", "(", "metrics", ",", "reduce_func", ")", ":", "num_videos", "=", "metrics", ".", "shape", "[", "1", "]", "# Take mean of the metric across the frames to approximate the video", "# closest to the ground truth.", "mean_across_frames", "=", "np", ...
Extracts the best-decode from the metrics according to reduce_func. Args: metrics: 3-D numpy array, shape=(num_decodes, num_samples, num_frames) reduce_func: callable, np.argmax or np.argmin. Returns: best_metrics: 2-D numpy array, shape=(num_samples, num_frames). best_decode_ind: 1-D numpy array, ...
[ "Extracts", "the", "best", "-", "decode", "from", "the", "metrics", "according", "to", "reduce_func", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L167-L185
train
tensorflow/tensor2tensor
tensor2tensor/utils/video_metrics.py
compute_all_metrics_statistics
def compute_all_metrics_statistics(all_results): """Computes statistics of metrics across multiple decodings. Args: all_results: dict of 3-D numpy arrays. Each array has shape=(num_decodes, num_samples, num_frames). Returns: statistics: dict of 1-D numpy arrays, shape=(num_frames). ...
python
def compute_all_metrics_statistics(all_results): """Computes statistics of metrics across multiple decodings. Args: all_results: dict of 3-D numpy arrays. Each array has shape=(num_decodes, num_samples, num_frames). Returns: statistics: dict of 1-D numpy arrays, shape=(num_frames). ...
[ "def", "compute_all_metrics_statistics", "(", "all_results", ")", ":", "statistics", "=", "{", "}", "decode_inds", "=", "{", "}", "all_metrics", "=", "all_results", ".", "keys", "(", ")", "for", "key", "in", "all_metrics", ":", "values", "=", "all_results", ...
Computes statistics of metrics across multiple decodings. Args: all_results: dict of 3-D numpy arrays. Each array has shape=(num_decodes, num_samples, num_frames). Returns: statistics: dict of 1-D numpy arrays, shape=(num_frames). First the statistic (max/mean/std) is compu...
[ "Computes", "statistics", "of", "metrics", "across", "multiple", "decodings", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L188-L220
train
tensorflow/tensor2tensor
tensor2tensor/utils/video_metrics.py
compute_video_metrics_from_predictions
def compute_video_metrics_from_predictions(predictions, decode_hparams): """Computes metrics from predictions. Args: predictions: list of list of dicts. outer length: num_decodes, inner_length: num_samples decode_hparams: Decode hparams. instance of HParams. Returns: statistics: dict...
python
def compute_video_metrics_from_predictions(predictions, decode_hparams): """Computes metrics from predictions. Args: predictions: list of list of dicts. outer length: num_decodes, inner_length: num_samples decode_hparams: Decode hparams. instance of HParams. Returns: statistics: dict...
[ "def", "compute_video_metrics_from_predictions", "(", "predictions", ",", "decode_hparams", ")", ":", "all_results", "=", "{", "}", "ssim_all_decodes", ",", "psnr_all_decodes", "=", "[", "]", ",", "[", "]", "for", "single_decode", "in", "predictions", ":", "args",...
Computes metrics from predictions. Args: predictions: list of list of dicts. outer length: num_decodes, inner_length: num_samples decode_hparams: Decode hparams. instance of HParams. Returns: statistics: dict of Tensors, key being the metric with each Tensor having the ...
[ "Computes", "metrics", "from", "predictions", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L223-L246
train
tensorflow/tensor2tensor
tensor2tensor/utils/video_metrics.py
compute_video_metrics_from_png_files
def compute_video_metrics_from_png_files( output_dirs, problem_name, video_length, frame_shape): """Computes the average of all the metric for one decoding. This function assumes that all the predicted and target frames have been saved on the disk and sorting them by name will result to consecutive frames ...
python
def compute_video_metrics_from_png_files( output_dirs, problem_name, video_length, frame_shape): """Computes the average of all the metric for one decoding. This function assumes that all the predicted and target frames have been saved on the disk and sorting them by name will result to consecutive frames ...
[ "def", "compute_video_metrics_from_png_files", "(", "output_dirs", ",", "problem_name", ",", "video_length", ",", "frame_shape", ")", ":", "ssim_all_decodes", ",", "psnr_all_decodes", "=", "[", "]", ",", "[", "]", "for", "output_dir", "in", "output_dirs", ":", "ou...
Computes the average of all the metric for one decoding. This function assumes that all the predicted and target frames have been saved on the disk and sorting them by name will result to consecutive frames saved in order. Args: output_dirs: directory with all the saved frames. problem_name: prefix of...
[ "Computes", "the", "average", "of", "all", "the", "metric", "for", "one", "decoding", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L249-L279
train
tensorflow/tensor2tensor
tensor2tensor/utils/video_metrics.py
compute_and_save_video_metrics
def compute_and_save_video_metrics( output_dirs, problem_name, video_length, frame_shape): """Compute and saves the video metrics.""" statistics, all_results = compute_video_metrics_from_png_files( output_dirs, problem_name, video_length, frame_shape) for results, output_dir in zip(all_results, output_d...
python
def compute_and_save_video_metrics( output_dirs, problem_name, video_length, frame_shape): """Compute and saves the video metrics.""" statistics, all_results = compute_video_metrics_from_png_files( output_dirs, problem_name, video_length, frame_shape) for results, output_dir in zip(all_results, output_d...
[ "def", "compute_and_save_video_metrics", "(", "output_dirs", ",", "problem_name", ",", "video_length", ",", "frame_shape", ")", ":", "statistics", ",", "all_results", "=", "compute_video_metrics_from_png_files", "(", "output_dirs", ",", "problem_name", ",", "video_length"...
Compute and saves the video metrics.
[ "Compute", "and", "saves", "the", "video", "metrics", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L282-L294
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
swap_time_and_batch_axes
def swap_time_and_batch_axes(inputs): """Swaps time and batch axis (the first two axis).""" transposed_axes = tf.concat([[1, 0], tf.range(2, tf.rank(inputs))], axis=0) return tf.transpose(inputs, transposed_axes)
python
def swap_time_and_batch_axes(inputs): """Swaps time and batch axis (the first two axis).""" transposed_axes = tf.concat([[1, 0], tf.range(2, tf.rank(inputs))], axis=0) return tf.transpose(inputs, transposed_axes)
[ "def", "swap_time_and_batch_axes", "(", "inputs", ")", ":", "transposed_axes", "=", "tf", ".", "concat", "(", "[", "[", "1", ",", "0", "]", ",", "tf", ".", "range", "(", "2", ",", "tf", ".", "rank", "(", "inputs", ")", ")", "]", ",", "axis", "=",...
Swaps time and batch axis (the first two axis).
[ "Swaps", "time", "and", "batch", "axis", "(", "the", "first", "two", "axis", ")", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L41-L44
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
encode_to_shape
def encode_to_shape(inputs, shape, scope): """Encode the given tensor to given image shape.""" with tf.variable_scope(scope, reuse=tf.AUTO_REUSE): w, h = shape[1], shape[2] x = inputs x = tfl.flatten(x) x = tfl.dense(x, w * h, activation=None, name="enc_dense") x = tf.reshape(x, (-1, w, h, 1)) ...
python
def encode_to_shape(inputs, shape, scope): """Encode the given tensor to given image shape.""" with tf.variable_scope(scope, reuse=tf.AUTO_REUSE): w, h = shape[1], shape[2] x = inputs x = tfl.flatten(x) x = tfl.dense(x, w * h, activation=None, name="enc_dense") x = tf.reshape(x, (-1, w, h, 1)) ...
[ "def", "encode_to_shape", "(", "inputs", ",", "shape", ",", "scope", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "w", ",", "h", "=", "shape", "[", "1", "]", ",", "shape", "[", ...
Encode the given tensor to given image shape.
[ "Encode", "the", "given", "tensor", "to", "given", "image", "shape", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L47-L55
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
decode_to_shape
def decode_to_shape(inputs, shape, scope): """Encode the given tensor to given image shape.""" with tf.variable_scope(scope, reuse=tf.AUTO_REUSE): x = inputs x = tfl.flatten(x) x = tfl.dense(x, shape[2], activation=None, name="dec_dense") x = tf.expand_dims(x, axis=1) return x
python
def decode_to_shape(inputs, shape, scope): """Encode the given tensor to given image shape.""" with tf.variable_scope(scope, reuse=tf.AUTO_REUSE): x = inputs x = tfl.flatten(x) x = tfl.dense(x, shape[2], activation=None, name="dec_dense") x = tf.expand_dims(x, axis=1) return x
[ "def", "decode_to_shape", "(", "inputs", ",", "shape", ",", "scope", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "x", "=", "inputs", "x", "=", "tfl", ".", "flatten", "(", "x", "...
Encode the given tensor to given image shape.
[ "Encode", "the", "given", "tensor", "to", "given", "image", "shape", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L58-L65
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
basic_lstm
def basic_lstm(inputs, state, num_units, name=None): """Basic LSTM.""" input_shape = common_layers.shape_list(inputs) # reuse parameters across time-steps. cell = tf.nn.rnn_cell.BasicLSTMCell( num_units, name=name, reuse=tf.AUTO_REUSE) if state is None: state = cell.zero_state(input_shape[0], tf.flo...
python
def basic_lstm(inputs, state, num_units, name=None): """Basic LSTM.""" input_shape = common_layers.shape_list(inputs) # reuse parameters across time-steps. cell = tf.nn.rnn_cell.BasicLSTMCell( num_units, name=name, reuse=tf.AUTO_REUSE) if state is None: state = cell.zero_state(input_shape[0], tf.flo...
[ "def", "basic_lstm", "(", "inputs", ",", "state", ",", "num_units", ",", "name", "=", "None", ")", ":", "input_shape", "=", "common_layers", ".", "shape_list", "(", "inputs", ")", "# reuse parameters across time-steps.", "cell", "=", "tf", ".", "nn", ".", "r...
Basic LSTM.
[ "Basic", "LSTM", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L68-L77
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
lstm_cell
def lstm_cell(inputs, state, num_units, use_peepholes=False, cell_clip=0.0, initializer=None, num_proj=None, num_unit_shards=None, num_proj_shards=None, reuse=None, name=None): "...
python
def lstm_cell(inputs, state, num_units, use_peepholes=False, cell_clip=0.0, initializer=None, num_proj=None, num_unit_shards=None, num_proj_shards=None, reuse=None, name=None): "...
[ "def", "lstm_cell", "(", "inputs", ",", "state", ",", "num_units", ",", "use_peepholes", "=", "False", ",", "cell_clip", "=", "0.0", ",", "initializer", "=", "None", ",", "num_proj", "=", "None", ",", "num_unit_shards", "=", "None", ",", "num_proj_shards", ...
Full LSTM cell.
[ "Full", "LSTM", "cell", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L80-L106
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
conv_lstm_2d
def conv_lstm_2d(inputs, state, output_channels, kernel_size=5, name=None, spatial_dims=None): """2D Convolutional LSTM.""" input_shape = common_layers.shape_list(inputs) batch_size, input_channels = input_shape[0], input_shape[-1] if spatial_dims is None: input_shape = input_shape[1:] el...
python
def conv_lstm_2d(inputs, state, output_channels, kernel_size=5, name=None, spatial_dims=None): """2D Convolutional LSTM.""" input_shape = common_layers.shape_list(inputs) batch_size, input_channels = input_shape[0], input_shape[-1] if spatial_dims is None: input_shape = input_shape[1:] el...
[ "def", "conv_lstm_2d", "(", "inputs", ",", "state", ",", "output_channels", ",", "kernel_size", "=", "5", ",", "name", "=", "None", ",", "spatial_dims", "=", "None", ")", ":", "input_shape", "=", "common_layers", ".", "shape_list", "(", "inputs", ")", "bat...
2D Convolutional LSTM.
[ "2D", "Convolutional", "LSTM", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L109-L125
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
scheduled_sample_count
def scheduled_sample_count(ground_truth_x, generated_x, batch_size, scheduled_sample_var): """Sample batch with specified mix of groundtruth and generated data points. Args: ground_truth_x: tensor of ground-truth data points. ...
python
def scheduled_sample_count(ground_truth_x, generated_x, batch_size, scheduled_sample_var): """Sample batch with specified mix of groundtruth and generated data points. Args: ground_truth_x: tensor of ground-truth data points. ...
[ "def", "scheduled_sample_count", "(", "ground_truth_x", ",", "generated_x", ",", "batch_size", ",", "scheduled_sample_var", ")", ":", "num_ground_truth", "=", "scheduled_sample_var", "idx", "=", "tf", ".", "random_shuffle", "(", "tf", ".", "range", "(", "batch_size"...
Sample batch with specified mix of groundtruth and generated data points. Args: ground_truth_x: tensor of ground-truth data points. generated_x: tensor of generated data points. batch_size: batch size scheduled_sample_var: number of ground-truth examples to include in batch. Returns: New batch ...
[ "Sample", "batch", "with", "specified", "mix", "of", "groundtruth", "and", "generated", "data", "points", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L128-L156
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
inject_additional_input
def inject_additional_input(layer, inputs, name, mode="concat"): """Injects the additional input into the layer. Args: layer: layer that the input should be injected to. inputs: inputs to be injected. name: TF scope name. mode: how the infor should be added to the layer: "concat" concats as a...
python
def inject_additional_input(layer, inputs, name, mode="concat"): """Injects the additional input into the layer. Args: layer: layer that the input should be injected to. inputs: inputs to be injected. name: TF scope name. mode: how the infor should be added to the layer: "concat" concats as a...
[ "def", "inject_additional_input", "(", "layer", ",", "inputs", ",", "name", ",", "mode", "=", "\"concat\"", ")", ":", "layer_shape", "=", "common_layers", ".", "shape_list", "(", "layer", ")", "input_shape", "=", "common_layers", ".", "shape_list", "(", "input...
Injects the additional input into the layer. Args: layer: layer that the input should be injected to. inputs: inputs to be injected. name: TF scope name. mode: how the infor should be added to the layer: "concat" concats as additional channels. "multiplicative" broadcasts inputs and multi...
[ "Injects", "the", "additional", "input", "into", "the", "layer", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L159-L199
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
scheduled_sample_prob
def scheduled_sample_prob(ground_truth_x, generated_x, batch_size, scheduled_sample_var): """Probability based scheduled sampling. Args: ground_truth_x: tensor of ground-truth data points. generated_x: tensor of generated data po...
python
def scheduled_sample_prob(ground_truth_x, generated_x, batch_size, scheduled_sample_var): """Probability based scheduled sampling. Args: ground_truth_x: tensor of ground-truth data points. generated_x: tensor of generated data po...
[ "def", "scheduled_sample_prob", "(", "ground_truth_x", ",", "generated_x", ",", "batch_size", ",", "scheduled_sample_var", ")", ":", "probability_threshold", "=", "scheduled_sample_var", "probability_of_generated", "=", "tf", ".", "random_uniform", "(", "[", "batch_size",...
Probability based scheduled sampling. Args: ground_truth_x: tensor of ground-truth data points. generated_x: tensor of generated data points. batch_size: batch size scheduled_sample_var: probability of choosing from ground_truth. Returns: New batch with randomly selected data points.
[ "Probability", "based", "scheduled", "sampling", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L202-L219
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
dna_transformation
def dna_transformation(prev_image, dna_input, dna_kernel_size, relu_shift): """Apply dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. dna_input: hidden lyaer to be used for computing DNA transformation. dna_kernel_size: dna kernel size. relu_shift: shi...
python
def dna_transformation(prev_image, dna_input, dna_kernel_size, relu_shift): """Apply dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. dna_input: hidden lyaer to be used for computing DNA transformation. dna_kernel_size: dna kernel size. relu_shift: shi...
[ "def", "dna_transformation", "(", "prev_image", ",", "dna_input", ",", "dna_kernel_size", ",", "relu_shift", ")", ":", "# Construct translated images.", "prev_image_pad", "=", "tf", ".", "pad", "(", "prev_image", ",", "[", "[", "0", ",", "0", "]", ",", "[", ...
Apply dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. dna_input: hidden lyaer to be used for computing DNA transformation. dna_kernel_size: dna kernel size. relu_shift: shift for ReLU function. Returns: List of images transformed by the predicted ...
[ "Apply", "dynamic", "neural", "advection", "to", "previous", "image", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L222-L251
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
cdna_transformation
def cdna_transformation(prev_image, cdna_input, num_masks, color_channels, dna_kernel_size, relu_shift): """Apply convolutional dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. cdna_input: hidden lyaer to be used for computing CDNA kern...
python
def cdna_transformation(prev_image, cdna_input, num_masks, color_channels, dna_kernel_size, relu_shift): """Apply convolutional dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. cdna_input: hidden lyaer to be used for computing CDNA kern...
[ "def", "cdna_transformation", "(", "prev_image", ",", "cdna_input", ",", "num_masks", ",", "color_channels", ",", "dna_kernel_size", ",", "relu_shift", ")", ":", "batch_size", "=", "tf", ".", "shape", "(", "cdna_input", ")", "[", "0", "]", "height", "=", "in...
Apply convolutional dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. cdna_input: hidden lyaer to be used for computing CDNA kernels. num_masks: number of masks and hence the number of CDNA transformations. color_channels: the number of color channels in ...
[ "Apply", "convolutional", "dynamic", "neural", "advection", "to", "previous", "image", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L254-L304
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
vgg_layer
def vgg_layer(inputs, nout, kernel_size=3, activation=tf.nn.leaky_relu, padding="SAME", is_training=True, has_batchnorm=False, scope=None): """A layer of VGG network with batch norm. Args: inputs: image tensor ...
python
def vgg_layer(inputs, nout, kernel_size=3, activation=tf.nn.leaky_relu, padding="SAME", is_training=True, has_batchnorm=False, scope=None): """A layer of VGG network with batch norm. Args: inputs: image tensor ...
[ "def", "vgg_layer", "(", "inputs", ",", "nout", ",", "kernel_size", "=", "3", ",", "activation", "=", "tf", ".", "nn", ".", "leaky_relu", ",", "padding", "=", "\"SAME\"", ",", "is_training", "=", "True", ",", "has_batchnorm", "=", "False", ",", "scope", ...
A layer of VGG network with batch norm. Args: inputs: image tensor nout: number of output channels kernel_size: size of the kernel activation: activation function padding: padding of the image is_training: whether it is training mode or not has_batchnorm: whether batchnorm is applied or n...
[ "A", "layer", "of", "VGG", "network", "with", "batch", "norm", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L307-L335
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
tile_and_concat
def tile_and_concat(image, latent, concat_latent=True): """Tile latent and concatenate to image across depth. Args: image: 4-D Tensor, (batch_size X height X width X channels) latent: 2-D Tensor, (batch_size X latent_dims) concat_latent: If set to False, the image is returned as is. Returns: con...
python
def tile_and_concat(image, latent, concat_latent=True): """Tile latent and concatenate to image across depth. Args: image: 4-D Tensor, (batch_size X height X width X channels) latent: 2-D Tensor, (batch_size X latent_dims) concat_latent: If set to False, the image is returned as is. Returns: con...
[ "def", "tile_and_concat", "(", "image", ",", "latent", ",", "concat_latent", "=", "True", ")", ":", "if", "not", "concat_latent", ":", "return", "image", "image_shape", "=", "common_layers", ".", "shape_list", "(", "image", ")", "latent_shape", "=", "common_la...
Tile latent and concatenate to image across depth. Args: image: 4-D Tensor, (batch_size X height X width X channels) latent: 2-D Tensor, (batch_size X latent_dims) concat_latent: If set to False, the image is returned as is. Returns: concat_latent: 4-D Tensor, (batch_size X height X width X channe...
[ "Tile", "latent", "and", "concatenate", "to", "image", "across", "depth", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L338-L361
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
_encode_gif
def _encode_gif(images, fps): """Encodes numpy images into gif string. Args: images: A 4-D `uint8` `np.array` (or a list of 3-D images) of shape `[time, height, width, channels]` where `channels` is 1 or 3. fps: frames per second of the animation Returns: The encoded gif string. Raises: ...
python
def _encode_gif(images, fps): """Encodes numpy images into gif string. Args: images: A 4-D `uint8` `np.array` (or a list of 3-D images) of shape `[time, height, width, channels]` where `channels` is 1 or 3. fps: frames per second of the animation Returns: The encoded gif string. Raises: ...
[ "def", "_encode_gif", "(", "images", ",", "fps", ")", ":", "writer", "=", "WholeVideoWriter", "(", "fps", ")", "writer", ".", "write_multi", "(", "images", ")", "return", "writer", ".", "finish", "(", ")" ]
Encodes numpy images into gif string. Args: images: A 4-D `uint8` `np.array` (or a list of 3-D images) of shape `[time, height, width, channels]` where `channels` is 1 or 3. fps: frames per second of the animation Returns: The encoded gif string. Raises: IOError: If the ffmpeg command ret...
[ "Encodes", "numpy", "images", "into", "gif", "string", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L364-L380
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
ffmpeg_works
def ffmpeg_works(): """Tries to encode images with ffmpeg to check if it works.""" images = np.zeros((2, 32, 32, 3), dtype=np.uint8) try: _encode_gif(images, 2) return True except (IOError, OSError): return False
python
def ffmpeg_works(): """Tries to encode images with ffmpeg to check if it works.""" images = np.zeros((2, 32, 32, 3), dtype=np.uint8) try: _encode_gif(images, 2) return True except (IOError, OSError): return False
[ "def", "ffmpeg_works", "(", ")", ":", "images", "=", "np", ".", "zeros", "(", "(", "2", ",", "32", ",", "32", ",", "3", ")", ",", "dtype", "=", "np", ".", "uint8", ")", "try", ":", "_encode_gif", "(", "images", ",", "2", ")", "return", "True", ...
Tries to encode images with ffmpeg to check if it works.
[ "Tries", "to", "encode", "images", "with", "ffmpeg", "to", "check", "if", "it", "works", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L383-L390
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
py_gif_summary
def py_gif_summary(tag, images, max_outputs, fps, return_summary_value=False): """Outputs a `Summary` protocol buffer with gif animations. Args: tag: Name of the summary. images: A 5-D `uint8` `np.array` of shape `[batch_size, time, height, width, channels]` where `channels` is 1 or 3. max_output...
python
def py_gif_summary(tag, images, max_outputs, fps, return_summary_value=False): """Outputs a `Summary` protocol buffer with gif animations. Args: tag: Name of the summary. images: A 5-D `uint8` `np.array` of shape `[batch_size, time, height, width, channels]` where `channels` is 1 or 3. max_output...
[ "def", "py_gif_summary", "(", "tag", ",", "images", ",", "max_outputs", ",", "fps", ",", "return_summary_value", "=", "False", ")", ":", "images", "=", "np", ".", "asarray", "(", "images", ")", "if", "images", ".", "dtype", "!=", "np", ".", "uint8", ":...
Outputs a `Summary` protocol buffer with gif animations. Args: tag: Name of the summary. images: A 5-D `uint8` `np.array` of shape `[batch_size, time, height, width, channels]` where `channels` is 1 or 3. max_outputs: Max number of batch elements to generate gifs for. fps: frames per second of ...
[ "Outputs", "a", "Summary", "protocol", "buffer", "with", "gif", "animations", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L393-L455
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
gif_summary
def gif_summary(name, tensor, max_outputs=3, fps=10, collections=None, family=None): """Outputs a `Summary` protocol buffer with gif animations. Args: name: Name of the summary. tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width, channels]` where `channels` is 1...
python
def gif_summary(name, tensor, max_outputs=3, fps=10, collections=None, family=None): """Outputs a `Summary` protocol buffer with gif animations. Args: name: Name of the summary. tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width, channels]` where `channels` is 1...
[ "def", "gif_summary", "(", "name", ",", "tensor", ",", "max_outputs", "=", "3", ",", "fps", "=", "10", ",", "collections", "=", "None", ",", "family", "=", "None", ")", ":", "tensor", "=", "tf", ".", "convert_to_tensor", "(", "tensor", ")", "if", "le...
Outputs a `Summary` protocol buffer with gif animations. Args: name: Name of the summary. tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width, channels]` where `channels` is 1 or 3. max_outputs: Max number of batch elements to generate gifs for. fps: frames per second of t...
[ "Outputs", "a", "Summary", "protocol", "buffer", "with", "gif", "animations", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L458-L497
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
conv_latent_tower
def conv_latent_tower(images, time_axis, latent_channels=1, min_logvar=-5, is_training=False, random_latent=False, tiny_mode=False, small_mode=False): """Builds convolutional latent tower for stochastic model. At training time this tower generates a latent distribution (...
python
def conv_latent_tower(images, time_axis, latent_channels=1, min_logvar=-5, is_training=False, random_latent=False, tiny_mode=False, small_mode=False): """Builds convolutional latent tower for stochastic model. At training time this tower generates a latent distribution (...
[ "def", "conv_latent_tower", "(", "images", ",", "time_axis", ",", "latent_channels", "=", "1", ",", "min_logvar", "=", "-", "5", ",", "is_training", "=", "False", ",", "random_latent", "=", "False", ",", "tiny_mode", "=", "False", ",", "small_mode", "=", "...
Builds convolutional latent tower for stochastic model. At training time this tower generates a latent distribution (mean and std) conditioned on the entire video. This latent variable will be fed to the main tower as an extra variable to be used for future frames prediction. At inference time, the tower is di...
[ "Builds", "convolutional", "latent", "tower", "for", "stochastic", "model", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L516-L582
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
beta_schedule
def beta_schedule(schedule, global_step, final_beta, decay_start, decay_end): """Get KL multiplier (beta) based on the schedule.""" if decay_start > decay_end: raise ValueError("decay_end is smaller than decay_end.") # Since some of the TF schedules do not support incrementing a value, # in all of the sche...
python
def beta_schedule(schedule, global_step, final_beta, decay_start, decay_end): """Get KL multiplier (beta) based on the schedule.""" if decay_start > decay_end: raise ValueError("decay_end is smaller than decay_end.") # Since some of the TF schedules do not support incrementing a value, # in all of the sche...
[ "def", "beta_schedule", "(", "schedule", ",", "global_step", ",", "final_beta", ",", "decay_start", ",", "decay_end", ")", ":", "if", "decay_start", ">", "decay_end", ":", "raise", "ValueError", "(", "\"decay_end is smaller than decay_end.\"", ")", "# Since some of th...
Get KL multiplier (beta) based on the schedule.
[ "Get", "KL", "multiplier", "(", "beta", ")", "based", "on", "the", "schedule", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L585-L618
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
extract_random_video_patch
def extract_random_video_patch(videos, num_frames=-1): """For every video, extract a random consecutive patch of num_frames. Args: videos: 5-D Tensor, (NTHWC) num_frames: Integer, if -1 then the entire video is returned. Returns: video_patch: 5-D Tensor, (NTHWC) with T = num_frames. Raises: Val...
python
def extract_random_video_patch(videos, num_frames=-1): """For every video, extract a random consecutive patch of num_frames. Args: videos: 5-D Tensor, (NTHWC) num_frames: Integer, if -1 then the entire video is returned. Returns: video_patch: 5-D Tensor, (NTHWC) with T = num_frames. Raises: Val...
[ "def", "extract_random_video_patch", "(", "videos", ",", "num_frames", "=", "-", "1", ")", ":", "if", "num_frames", "==", "-", "1", ":", "return", "videos", "batch_size", ",", "num_total_frames", ",", "h", ",", "w", ",", "c", "=", "common_layers", ".", "...
For every video, extract a random consecutive patch of num_frames. Args: videos: 5-D Tensor, (NTHWC) num_frames: Integer, if -1 then the entire video is returned. Returns: video_patch: 5-D Tensor, (NTHWC) with T = num_frames. Raises: ValueError: If num_frames is greater than the number of total f...
[ "For", "every", "video", "extract", "a", "random", "consecutive", "patch", "of", "num_frames", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L621-L658
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
VideoWriter.write_multi
def write_multi(self, frames, encoded_frames=None): """Writes multiple video frames.""" if encoded_frames is None: # Infinite iterator. encoded_frames = iter(lambda: None, 1) for (frame, encoded_frame) in zip(frames, encoded_frames): self.write(frame, encoded_frame)
python
def write_multi(self, frames, encoded_frames=None): """Writes multiple video frames.""" if encoded_frames is None: # Infinite iterator. encoded_frames = iter(lambda: None, 1) for (frame, encoded_frame) in zip(frames, encoded_frames): self.write(frame, encoded_frame)
[ "def", "write_multi", "(", "self", ",", "frames", ",", "encoded_frames", "=", "None", ")", ":", "if", "encoded_frames", "is", "None", ":", "# Infinite iterator.", "encoded_frames", "=", "iter", "(", "lambda", ":", "None", ",", "1", ")", "for", "(", "frame"...
Writes multiple video frames.
[ "Writes", "multiple", "video", "frames", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L668-L674
train
tensorflow/tensor2tensor
tensor2tensor/layers/common_video.py
WholeVideoWriter.__init_ffmpeg
def __init_ffmpeg(self, image_shape): """Initializes ffmpeg to write frames.""" import itertools # pylint: disable=g-import-not-at-top from subprocess import Popen, PIPE # pylint: disable=g-import-not-at-top,g-multiple-import,g-importing-member ffmpeg = "ffmpeg" height, width, channels = image_sha...
python
def __init_ffmpeg(self, image_shape): """Initializes ffmpeg to write frames.""" import itertools # pylint: disable=g-import-not-at-top from subprocess import Popen, PIPE # pylint: disable=g-import-not-at-top,g-multiple-import,g-importing-member ffmpeg = "ffmpeg" height, width, channels = image_sha...
[ "def", "__init_ffmpeg", "(", "self", ",", "image_shape", ")", ":", "import", "itertools", "# pylint: disable=g-import-not-at-top", "from", "subprocess", "import", "Popen", ",", "PIPE", "# pylint: disable=g-import-not-at-top,g-multiple-import,g-importing-member", "ffmpeg", "=", ...
Initializes ffmpeg to write frames.
[ "Initializes", "ffmpeg", "to", "write", "frames", "." ]
272500b6efe353aeb638d2745ed56e519462ca31
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L715-L744
train