repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
tensorflow/tensor2tensor | tensor2tensor/utils/trainer_lib.py | T2TExperiment.continuous_decode | def continuous_decode(self):
"""Decode from dataset on new checkpoint."""
for _ in next_checkpoint(self._hparams.model_dir,
self._decode_hparams.decode_timeout_mins):
self.decode() | python | def continuous_decode(self):
"""Decode from dataset on new checkpoint."""
for _ in next_checkpoint(self._hparams.model_dir,
self._decode_hparams.decode_timeout_mins):
self.decode() | [
"def",
"continuous_decode",
"(",
"self",
")",
":",
"for",
"_",
"in",
"next_checkpoint",
"(",
"self",
".",
"_hparams",
".",
"model_dir",
",",
"self",
".",
"_decode_hparams",
".",
"decode_timeout_mins",
")",
":",
"self",
".",
"decode",
"(",
")"
] | Decode from dataset on new checkpoint. | [
"Decode",
"from",
"dataset",
"on",
"new",
"checkpoint",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/trainer_lib.py#L558-L562 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/trainer_lib.py | T2TExperiment.continuous_decode_on_train_data | def continuous_decode_on_train_data(self):
"""Decode from dataset on new checkpoint."""
for _ in next_checkpoint(self._hparams.model_dir,
self._decode_hparams.decode_timeout_mins):
self.decode(dataset_split=tf.estimator.ModeKeys.TRAIN) | python | def continuous_decode_on_train_data(self):
"""Decode from dataset on new checkpoint."""
for _ in next_checkpoint(self._hparams.model_dir,
self._decode_hparams.decode_timeout_mins):
self.decode(dataset_split=tf.estimator.ModeKeys.TRAIN) | [
"def",
"continuous_decode_on_train_data",
"(",
"self",
")",
":",
"for",
"_",
"in",
"next_checkpoint",
"(",
"self",
".",
"_hparams",
".",
"model_dir",
",",
"self",
".",
"_decode_hparams",
".",
"decode_timeout_mins",
")",
":",
"self",
".",
"decode",
"(",
"datase... | Decode from dataset on new checkpoint. | [
"Decode",
"from",
"dataset",
"on",
"new",
"checkpoint",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/trainer_lib.py#L564-L568 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/trainer_lib.py | T2TExperiment.continuous_decode_on_eval_data | def continuous_decode_on_eval_data(self):
"""Decode from dataset on new checkpoint."""
if self._hparams.mlperf_mode:
ckpt_generator = next_undecoded_checkpoint(
self._hparams.model_dir, self._decode_hparams.decode_timeout_mins)
else:
ckpt_generator = next_checkpoint(self._hparams.model... | python | def continuous_decode_on_eval_data(self):
"""Decode from dataset on new checkpoint."""
if self._hparams.mlperf_mode:
ckpt_generator = next_undecoded_checkpoint(
self._hparams.model_dir, self._decode_hparams.decode_timeout_mins)
else:
ckpt_generator = next_checkpoint(self._hparams.model... | [
"def",
"continuous_decode_on_eval_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"_hparams",
".",
"mlperf_mode",
":",
"ckpt_generator",
"=",
"next_undecoded_checkpoint",
"(",
"self",
".",
"_hparams",
".",
"model_dir",
",",
"self",
".",
"_decode_hparams",
".",
... | Decode from dataset on new checkpoint. | [
"Decode",
"from",
"dataset",
"on",
"new",
"checkpoint",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/trainer_lib.py#L570-L604 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/trainer_lib.py | T2TExperiment.continuous_decode_from_file | def continuous_decode_from_file(self):
"""Decode from file on new checkpoint."""
for _ in next_checkpoint(self._hparams.model_dir,
self._decode_hparams.decode_timeout_mins):
self.decode(decode_from_file=True) | python | def continuous_decode_from_file(self):
"""Decode from file on new checkpoint."""
for _ in next_checkpoint(self._hparams.model_dir,
self._decode_hparams.decode_timeout_mins):
self.decode(decode_from_file=True) | [
"def",
"continuous_decode_from_file",
"(",
"self",
")",
":",
"for",
"_",
"in",
"next_checkpoint",
"(",
"self",
".",
"_hparams",
".",
"model_dir",
",",
"self",
".",
"_decode_hparams",
".",
"decode_timeout_mins",
")",
":",
"self",
".",
"decode",
"(",
"decode_fro... | Decode from file on new checkpoint. | [
"Decode",
"from",
"file",
"on",
"new",
"checkpoint",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/trainer_lib.py#L606-L610 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | _flatten_dict | def _flatten_dict(original_dict):
"""Flatten dict of dicts into a single dict with appropriate prefixes.
Handles only 2 levels of nesting in the original dict.
Args:
original_dict: Dict which may contain one or more dicts.
Returns:
flat_dict: Dict without any nesting. Any dicts in the original dict ha... | python | def _flatten_dict(original_dict):
"""Flatten dict of dicts into a single dict with appropriate prefixes.
Handles only 2 levels of nesting in the original dict.
Args:
original_dict: Dict which may contain one or more dicts.
Returns:
flat_dict: Dict without any nesting. Any dicts in the original dict ha... | [
"def",
"_flatten_dict",
"(",
"original_dict",
")",
":",
"flat_dict",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"original_dict",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"for",
"name",
",",
"tensor",
... | Flatten dict of dicts into a single dict with appropriate prefixes.
Handles only 2 levels of nesting in the original dict.
Args:
original_dict: Dict which may contain one or more dicts.
Returns:
flat_dict: Dict without any nesting. Any dicts in the original dict have
their keys as prefixes in the ... | [
"Flatten",
"dict",
"of",
"dicts",
"into",
"a",
"single",
"dict",
"with",
"appropriate",
"prefixes",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L63-L87 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | _unflatten_dict | def _unflatten_dict(flat_dict, prefixes):
"""Returns a dict of dicts if any prefixes match keys in the flat dict.
The function handles the case where the prefix may not be a dict.
Args:
flat_dict: A dict without any nesting.
prefixes: A list of strings which may have been dicts in the
original s... | python | def _unflatten_dict(flat_dict, prefixes):
"""Returns a dict of dicts if any prefixes match keys in the flat dict.
The function handles the case where the prefix may not be a dict.
Args:
flat_dict: A dict without any nesting.
prefixes: A list of strings which may have been dicts in the
original s... | [
"def",
"_unflatten_dict",
"(",
"flat_dict",
",",
"prefixes",
")",
":",
"original_dict",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"flat_dict",
".",
"items",
"(",
")",
":",
"prefix_found",
"=",
"False",
"for",
"prefix",
"in",
"prefixes",
":",
"full... | Returns a dict of dicts if any prefixes match keys in the flat dict.
The function handles the case where the prefix may not be a dict.
Args:
flat_dict: A dict without any nesting.
prefixes: A list of strings which may have been dicts in the
original structure. | [
"Returns",
"a",
"dict",
"of",
"dicts",
"if",
"any",
"prefixes",
"match",
"keys",
"in",
"the",
"flat",
"dict",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L90-L117 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | create_dummy_vars | def create_dummy_vars():
"""Dummy vars for restore to work when not using TPU codepath."""
var_names = set([v.name for v in tf.global_variables()])
if "losses_avg/problem_0/total_loss:0" in var_names:
return
with tf.variable_scope("losses_avg"):
with tf.variable_scope("problem_0"):
for var_name in... | python | def create_dummy_vars():
"""Dummy vars for restore to work when not using TPU codepath."""
var_names = set([v.name for v in tf.global_variables()])
if "losses_avg/problem_0/total_loss:0" in var_names:
return
with tf.variable_scope("losses_avg"):
with tf.variable_scope("problem_0"):
for var_name in... | [
"def",
"create_dummy_vars",
"(",
")",
":",
"var_names",
"=",
"set",
"(",
"[",
"v",
".",
"name",
"for",
"v",
"in",
"tf",
".",
"global_variables",
"(",
")",
"]",
")",
"if",
"\"losses_avg/problem_0/total_loss:0\"",
"in",
"var_names",
":",
"return",
"with",
"t... | Dummy vars for restore to work when not using TPU codepath. | [
"Dummy",
"vars",
"for",
"restore",
"to",
"work",
"when",
"not",
"using",
"TPU",
"codepath",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L1916-L1927 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | create_tpu_eval_metrics_fn | def create_tpu_eval_metrics_fn(problem, model_hparams):
"""Create the metrics_fn that TPUEstimatorSpec expects."""
metric_fns = []
eval_metrics = problem.eval_metric_fns(model_hparams)
tm = _create_target_modality(problem.get_hparams(model_hparams).modality)
if isinstance(tm, dict):
for k, v in six.iter... | python | def create_tpu_eval_metrics_fn(problem, model_hparams):
"""Create the metrics_fn that TPUEstimatorSpec expects."""
metric_fns = []
eval_metrics = problem.eval_metric_fns(model_hparams)
tm = _create_target_modality(problem.get_hparams(model_hparams).modality)
if isinstance(tm, dict):
for k, v in six.iter... | [
"def",
"create_tpu_eval_metrics_fn",
"(",
"problem",
",",
"model_hparams",
")",
":",
"metric_fns",
"=",
"[",
"]",
"eval_metrics",
"=",
"problem",
".",
"eval_metric_fns",
"(",
"model_hparams",
")",
"tm",
"=",
"_create_target_modality",
"(",
"problem",
".",
"get_hpa... | Create the metrics_fn that TPUEstimatorSpec expects. | [
"Create",
"the",
"metrics_fn",
"that",
"TPUEstimatorSpec",
"expects",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L1939-L2015 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | remove_summaries | def remove_summaries():
"""Remove summaries from the default graph."""
g = tf.get_default_graph()
key = tf.GraphKeys.SUMMARIES
log_debug("Remove summaries %s" % str(g.get_collection(key)))
del g.get_collection_ref(key)[:]
assert not g.get_collection(key) | python | def remove_summaries():
"""Remove summaries from the default graph."""
g = tf.get_default_graph()
key = tf.GraphKeys.SUMMARIES
log_debug("Remove summaries %s" % str(g.get_collection(key)))
del g.get_collection_ref(key)[:]
assert not g.get_collection(key) | [
"def",
"remove_summaries",
"(",
")",
":",
"g",
"=",
"tf",
".",
"get_default_graph",
"(",
")",
"key",
"=",
"tf",
".",
"GraphKeys",
".",
"SUMMARIES",
"log_debug",
"(",
"\"Remove summaries %s\"",
"%",
"str",
"(",
"g",
".",
"get_collection",
"(",
"key",
")",
... | Remove summaries from the default graph. | [
"Remove",
"summaries",
"from",
"the",
"default",
"graph",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L2018-L2024 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | create_host_call | def create_host_call(model_dir):
"""Construct a host_call writing scalar summaries.
Args:
model_dir: String containing path to train
Returns:
(fn, args) Pair to be called by TPUEstimator as the host_call.
"""
graph = tf.get_default_graph()
summaries = graph.get_collection(tf.GraphKeys.SUMMARIES)
... | python | def create_host_call(model_dir):
"""Construct a host_call writing scalar summaries.
Args:
model_dir: String containing path to train
Returns:
(fn, args) Pair to be called by TPUEstimator as the host_call.
"""
graph = tf.get_default_graph()
summaries = graph.get_collection(tf.GraphKeys.SUMMARIES)
... | [
"def",
"create_host_call",
"(",
"model_dir",
")",
":",
"graph",
"=",
"tf",
".",
"get_default_graph",
"(",
")",
"summaries",
"=",
"graph",
".",
"get_collection",
"(",
"tf",
".",
"GraphKeys",
".",
"SUMMARIES",
")",
"gs_t",
"=",
"tf",
".",
"reshape",
"(",
"... | Construct a host_call writing scalar summaries.
Args:
model_dir: String containing path to train
Returns:
(fn, args) Pair to be called by TPUEstimator as the host_call. | [
"Construct",
"a",
"host_call",
"writing",
"scalar",
"summaries",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L2027-L2098 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | average_sharded_losses | def average_sharded_losses(sharded_losses):
"""Average losses across datashards.
Args:
sharded_losses: list<dict<str loss_name, Tensor loss>>. The loss
can be a single Tensor or a 2-tuple (numerator and denominator).
Returns:
losses: dict<str loss_name, Tensor avg_loss>
"""
losses = {}
for l... | python | def average_sharded_losses(sharded_losses):
"""Average losses across datashards.
Args:
sharded_losses: list<dict<str loss_name, Tensor loss>>. The loss
can be a single Tensor or a 2-tuple (numerator and denominator).
Returns:
losses: dict<str loss_name, Tensor avg_loss>
"""
losses = {}
for l... | [
"def",
"average_sharded_losses",
"(",
"sharded_losses",
")",
":",
"losses",
"=",
"{",
"}",
"for",
"loss_name",
"in",
"sorted",
"(",
"sharded_losses",
"[",
"0",
"]",
")",
":",
"all_shards",
"=",
"[",
"shard_losses",
"[",
"loss_name",
"]",
"for",
"shard_losses... | Average losses across datashards.
Args:
sharded_losses: list<dict<str loss_name, Tensor loss>>. The loss
can be a single Tensor or a 2-tuple (numerator and denominator).
Returns:
losses: dict<str loss_name, Tensor avg_loss> | [
"Average",
"losses",
"across",
"datashards",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L2121-L2143 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | summarize_features | def summarize_features(features, num_shards=1):
"""Generate summaries for features."""
if not common_layers.should_generate_summaries():
return
with tf.name_scope("input_stats"):
for (k, v) in sorted(six.iteritems(features)):
if (isinstance(v, tf.Tensor) and (v.get_shape().ndims > 1) and
... | python | def summarize_features(features, num_shards=1):
"""Generate summaries for features."""
if not common_layers.should_generate_summaries():
return
with tf.name_scope("input_stats"):
for (k, v) in sorted(six.iteritems(features)):
if (isinstance(v, tf.Tensor) and (v.get_shape().ndims > 1) and
... | [
"def",
"summarize_features",
"(",
"features",
",",
"num_shards",
"=",
"1",
")",
":",
"if",
"not",
"common_layers",
".",
"should_generate_summaries",
"(",
")",
":",
"return",
"with",
"tf",
".",
"name_scope",
"(",
"\"input_stats\"",
")",
":",
"for",
"(",
"k",
... | Generate summaries for features. | [
"Generate",
"summaries",
"for",
"features",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L2146-L2161 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | _compose_custom_getters | def _compose_custom_getters(getter_a, getter_b):
"""Compose two custom getters.
Example use:
tf.get_variable_scope().set_custom_getter(
compose_custom_getters(tf.get_variable_scope().custom_getter, new_getter))
This composes getters in the same way as creating a new variable scope with
the new_getter, b... | python | def _compose_custom_getters(getter_a, getter_b):
"""Compose two custom getters.
Example use:
tf.get_variable_scope().set_custom_getter(
compose_custom_getters(tf.get_variable_scope().custom_getter, new_getter))
This composes getters in the same way as creating a new variable scope with
the new_getter, b... | [
"def",
"_compose_custom_getters",
"(",
"getter_a",
",",
"getter_b",
")",
":",
"if",
"not",
"getter_a",
":",
"return",
"getter_b",
"if",
"not",
"getter_b",
":",
"return",
"getter_a",
"def",
"getter_fn",
"(",
"getter",
",",
"*",
"args",
",",
"*",
"*",
"kwarg... | Compose two custom getters.
Example use:
tf.get_variable_scope().set_custom_getter(
compose_custom_getters(tf.get_variable_scope().custom_getter, new_getter))
This composes getters in the same way as creating a new variable scope with
the new_getter, but it does not actually create a new variable scope.
... | [
"Compose",
"two",
"custom",
"getters",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L2186-L2211 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | set_custom_getter_compose | def set_custom_getter_compose(custom_getter):
"""Set a custom getter in the current variable scope.
Do not overwrite the existing custom getter - rather compose with it.
Args:
custom_getter: a custom getter.
"""
tf.get_variable_scope().set_custom_getter(
_compose_custom_getters(tf.get_variable_sco... | python | def set_custom_getter_compose(custom_getter):
"""Set a custom getter in the current variable scope.
Do not overwrite the existing custom getter - rather compose with it.
Args:
custom_getter: a custom getter.
"""
tf.get_variable_scope().set_custom_getter(
_compose_custom_getters(tf.get_variable_sco... | [
"def",
"set_custom_getter_compose",
"(",
"custom_getter",
")",
":",
"tf",
".",
"get_variable_scope",
"(",
")",
".",
"set_custom_getter",
"(",
"_compose_custom_getters",
"(",
"tf",
".",
"get_variable_scope",
"(",
")",
".",
"custom_getter",
",",
"custom_getter",
")",
... | Set a custom getter in the current variable scope.
Do not overwrite the existing custom getter - rather compose with it.
Args:
custom_getter: a custom getter. | [
"Set",
"a",
"custom",
"getter",
"in",
"the",
"current",
"variable",
"scope",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L2214-L2224 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | initialize_from_ckpt | def initialize_from_ckpt(ckpt_dir, hparams):
"""Initialize variables from given directory."""
model_dir = hparams.get("model_dir", None)
already_has_ckpt = (
model_dir and tf.train.latest_checkpoint(model_dir) is not None)
if already_has_ckpt:
return
tf.logging.info("Checkpoint dir: %s", ckpt_dir)
... | python | def initialize_from_ckpt(ckpt_dir, hparams):
"""Initialize variables from given directory."""
model_dir = hparams.get("model_dir", None)
already_has_ckpt = (
model_dir and tf.train.latest_checkpoint(model_dir) is not None)
if already_has_ckpt:
return
tf.logging.info("Checkpoint dir: %s", ckpt_dir)
... | [
"def",
"initialize_from_ckpt",
"(",
"ckpt_dir",
",",
"hparams",
")",
":",
"model_dir",
"=",
"hparams",
".",
"get",
"(",
"\"model_dir\"",
",",
"None",
")",
"already_has_ckpt",
"=",
"(",
"model_dir",
"and",
"tf",
".",
"train",
".",
"latest_checkpoint",
"(",
"m... | Initialize variables from given directory. | [
"Initialize",
"variables",
"from",
"given",
"directory",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L2236-L2255 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel._target_modality_is_real | def _target_modality_is_real(self):
"""Whether the target modality is real-valued."""
vocab_size = self._problem_hparams.vocab_size["targets"]
if vocab_size is not None and hasattr(self._hparams, "vocab_divisor"):
vocab_size += (-vocab_size) % self._hparams.vocab_divisor
modality = self._problem_h... | python | def _target_modality_is_real(self):
"""Whether the target modality is real-valued."""
vocab_size = self._problem_hparams.vocab_size["targets"]
if vocab_size is not None and hasattr(self._hparams, "vocab_divisor"):
vocab_size += (-vocab_size) % self._hparams.vocab_divisor
modality = self._problem_h... | [
"def",
"_target_modality_is_real",
"(",
"self",
")",
":",
"vocab_size",
"=",
"self",
".",
"_problem_hparams",
".",
"vocab_size",
"[",
"\"targets\"",
"]",
"if",
"vocab_size",
"is",
"not",
"None",
"and",
"hasattr",
"(",
"self",
".",
"_hparams",
",",
"\"vocab_div... | Whether the target modality is real-valued. | [
"Whether",
"the",
"target",
"modality",
"is",
"real",
"-",
"valued",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L302-L311 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.model_fn_sharded | def model_fn_sharded(self, sharded_features):
"""Estimator model_fn sharded along batch dimension.
Args:
sharded_features: {str: [Tensor]}. Features sharded along batch dimension.
Each list is the same length (== number of shards).
Returns:
sharded_logits: [Tensor]. Logits for each sha... | python | def model_fn_sharded(self, sharded_features):
"""Estimator model_fn sharded along batch dimension.
Args:
sharded_features: {str: [Tensor]}. Features sharded along batch dimension.
Each list is the same length (== number of shards).
Returns:
sharded_logits: [Tensor]. Logits for each sha... | [
"def",
"model_fn_sharded",
"(",
"self",
",",
"sharded_features",
")",
":",
"dp",
"=",
"self",
".",
"_data_parallelism",
"# [{str: Tensor}]. Transpose of 'sharded_features'.",
"datashard_to_features",
"=",
"self",
".",
"_to_features_per_datashard",
"(",
"sharded_features",
"... | Estimator model_fn sharded along batch dimension.
Args:
sharded_features: {str: [Tensor]}. Features sharded along batch dimension.
Each list is the same length (== number of shards).
Returns:
sharded_logits: [Tensor]. Logits for each shard of examples.
losses: {str: 0-D Tensor}. Loss... | [
"Estimator",
"model_fn",
"sharded",
"along",
"batch",
"dimension",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L348-L412 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.bottom | def bottom(self, features):
"""Transforms features to feed into body.
Args:
features: dict of str to Tensor. Typically it is the preprocessed data
batch after Problem's preprocess_example().
Returns:
transformed_features: dict of same key-value pairs as features. The value
Tens... | python | def bottom(self, features):
"""Transforms features to feed into body.
Args:
features: dict of str to Tensor. Typically it is the preprocessed data
batch after Problem's preprocess_example().
Returns:
transformed_features: dict of same key-value pairs as features. The value
Tens... | [
"def",
"bottom",
"(",
"self",
",",
"features",
")",
":",
"if",
"not",
"self",
".",
"_problem_hparams",
":",
"log_warn",
"(",
"\"Without a Problem, T2TModel.bottom is a passthrough.\"",
")",
"return",
"features",
"transformed_features",
"=",
"collections",
".",
"Ordere... | Transforms features to feed into body.
Args:
features: dict of str to Tensor. Typically it is the preprocessed data
batch after Problem's preprocess_example().
Returns:
transformed_features: dict of same key-value pairs as features. The value
Tensors are newly transformed. | [
"Transforms",
"features",
"to",
"feed",
"into",
"body",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L443-L516 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.top | def top(self, body_output, features):
"""Computes logits given body output and features.
Args:
body_output: dict of str to Tensor, comprising one key-value pair for each
target. Each value denotes the target's pre-logit activations.
Alternatively, it may be a single Tensor denoting the pr... | python | def top(self, body_output, features):
"""Computes logits given body output and features.
Args:
body_output: dict of str to Tensor, comprising one key-value pair for each
target. Each value denotes the target's pre-logit activations.
Alternatively, it may be a single Tensor denoting the pr... | [
"def",
"top",
"(",
"self",
",",
"body_output",
",",
"features",
")",
":",
"if",
"isinstance",
"(",
"body_output",
",",
"dict",
")",
":",
"logits",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"body_output",
")",
":",
"# ... | Computes logits given body output and features.
Args:
body_output: dict of str to Tensor, comprising one key-value pair for each
target. Each value denotes the target's pre-logit activations.
Alternatively, it may be a single Tensor denoting the pre-logits for
that target.
featu... | [
"Computes",
"logits",
"given",
"body",
"output",
"and",
"features",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L583-L612 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.optimize | def optimize(self, loss, num_async_replicas=1, use_tpu=False):
"""Return a training op minimizing loss."""
lr = learning_rate.learning_rate_schedule(self.hparams)
if num_async_replicas > 1:
log_info("Dividing learning rate by num_async_replicas: %d",
num_async_replicas)
lr /= math.s... | python | def optimize(self, loss, num_async_replicas=1, use_tpu=False):
"""Return a training op minimizing loss."""
lr = learning_rate.learning_rate_schedule(self.hparams)
if num_async_replicas > 1:
log_info("Dividing learning rate by num_async_replicas: %d",
num_async_replicas)
lr /= math.s... | [
"def",
"optimize",
"(",
"self",
",",
"loss",
",",
"num_async_replicas",
"=",
"1",
",",
"use_tpu",
"=",
"False",
")",
":",
"lr",
"=",
"learning_rate",
".",
"learning_rate_schedule",
"(",
"self",
".",
"hparams",
")",
"if",
"num_async_replicas",
">",
"1",
":"... | Return a training op minimizing loss. | [
"Return",
"a",
"training",
"op",
"minimizing",
"loss",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L710-L718 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.set_mode | def set_mode(self, mode):
"""Set hparams with the given mode."""
log_info("Setting T2TModel mode to '%s'", mode)
hparams = hparams_lib.copy_hparams(self._original_hparams)
hparams.add_hparam("mode", mode)
# When not in training mode, set all forms of dropout to zero.
if mode != tf.estimator.Mode... | python | def set_mode(self, mode):
"""Set hparams with the given mode."""
log_info("Setting T2TModel mode to '%s'", mode)
hparams = hparams_lib.copy_hparams(self._original_hparams)
hparams.add_hparam("mode", mode)
# When not in training mode, set all forms of dropout to zero.
if mode != tf.estimator.Mode... | [
"def",
"set_mode",
"(",
"self",
",",
"mode",
")",
":",
"log_info",
"(",
"\"Setting T2TModel mode to '%s'\"",
",",
"mode",
")",
"hparams",
"=",
"hparams_lib",
".",
"copy_hparams",
"(",
"self",
".",
"_original_hparams",
")",
"hparams",
".",
"add_hparam",
"(",
"\... | Set hparams with the given mode. | [
"Set",
"hparams",
"with",
"the",
"given",
"mode",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L720-L731 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.eval_autoregressive | def eval_autoregressive(self, features=None, decode_length=50):
"""Autoregressive eval.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional timesteps to decode.
Returns:
logits: `Tensor`
losses: a dictio... | python | def eval_autoregressive(self, features=None, decode_length=50):
"""Autoregressive eval.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional timesteps to decode.
Returns:
logits: `Tensor`
losses: a dictio... | [
"def",
"eval_autoregressive",
"(",
"self",
",",
"features",
"=",
"None",
",",
"decode_length",
"=",
"50",
")",
":",
"results",
"=",
"self",
".",
"_slow_greedy_infer",
"(",
"features",
",",
"decode_length",
"=",
"decode_length",
")",
"return",
"results",
"[",
... | Autoregressive eval.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional timesteps to decode.
Returns:
logits: `Tensor`
losses: a dictionary: {loss-name (string): floating point `Scalar`}.
Contains... | [
"Autoregressive",
"eval",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L737-L752 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.infer | def infer(self,
features=None,
decode_length=50,
beam_size=1,
top_beams=1,
alpha=0.0,
use_tpu=False):
"""A inference method.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an i... | python | def infer(self,
features=None,
decode_length=50,
beam_size=1,
top_beams=1,
alpha=0.0,
use_tpu=False):
"""A inference method.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an i... | [
"def",
"infer",
"(",
"self",
",",
"features",
"=",
"None",
",",
"decode_length",
"=",
"50",
",",
"beam_size",
"=",
"1",
",",
"top_beams",
"=",
"1",
",",
"alpha",
"=",
"0.0",
",",
"use_tpu",
"=",
"False",
")",
":",
"set_custom_getter_compose",
"(",
"sel... | A inference method.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional timesteps to decode.
beam_size: number of beams.
top_beams: an integer. How many of the beams to return.
alpha: Float that controls th... | [
"A",
"inference",
"method",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L761-L817 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel._beam_decode | def _beam_decode(self,
features,
decode_length,
beam_size,
top_beams,
alpha,
use_tpu=False):
"""Beam search decoding.
Models should ideally implement a more efficient version of this function.
... | python | def _beam_decode(self,
features,
decode_length,
beam_size,
top_beams,
alpha,
use_tpu=False):
"""Beam search decoding.
Models should ideally implement a more efficient version of this function.
... | [
"def",
"_beam_decode",
"(",
"self",
",",
"features",
",",
"decode_length",
",",
"beam_size",
",",
"top_beams",
",",
"alpha",
",",
"use_tpu",
"=",
"False",
")",
":",
"return",
"self",
".",
"_beam_decode_slow",
"(",
"features",
",",
"decode_length",
",",
"beam... | Beam search decoding.
Models should ideally implement a more efficient version of this function.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional timesteps to decode.
beam_size: number of beams.
top_beams: an integer. How many of the beams to... | [
"Beam",
"search",
"decoding",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L819-L843 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel._beam_decode_slow | def _beam_decode_slow(self, features, decode_length, beam_size, top_beams,
alpha, use_tpu=False):
"""Slow version of Beam search decoding.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional times... | python | def _beam_decode_slow(self, features, decode_length, beam_size, top_beams,
alpha, use_tpu=False):
"""Slow version of Beam search decoding.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional times... | [
"def",
"_beam_decode_slow",
"(",
"self",
",",
"features",
",",
"decode_length",
",",
"beam_size",
",",
"top_beams",
",",
"alpha",
",",
"use_tpu",
"=",
"False",
")",
":",
"batch_size",
"=",
"common_layers",
".",
"shape_list",
"(",
"features",
"[",
"\"inputs\"",... | Slow version of Beam search decoding.
Quadratic time in decode_length.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional timesteps to decode.
beam_size: number of beams.
top_beams: an integer. How many of the beams to return.
alpha: Floa... | [
"Slow",
"version",
"of",
"Beam",
"search",
"decoding",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L845-L951 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel._greedy_infer | def _greedy_infer(self, features, decode_length, use_tpu=False):
"""A greedy inference method.
Models should ideally implement a more efficient version of this function.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional timesteps to decode.
use_... | python | def _greedy_infer(self, features, decode_length, use_tpu=False):
"""A greedy inference method.
Models should ideally implement a more efficient version of this function.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional timesteps to decode.
use_... | [
"def",
"_greedy_infer",
"(",
"self",
",",
"features",
",",
"decode_length",
",",
"use_tpu",
"=",
"False",
")",
":",
"if",
"use_tpu",
":",
"return",
"self",
".",
"_slow_greedy_infer_tpu",
"(",
"features",
",",
"decode_length",
")",
"return",
"self",
".",
"_sl... | A greedy inference method.
Models should ideally implement a more efficient version of this function.
Args:
features: an map of string to `Tensor`
decode_length: an integer. How many additional timesteps to decode.
use_tpu: A bool, whether to build the inference graph for TPU.
Returns:... | [
"A",
"greedy",
"inference",
"method",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L953-L975 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel._slow_greedy_infer_tpu | def _slow_greedy_infer_tpu(self, features, decode_length):
"""A slow greedy inference method on TPU.
Quadratic time in decode_length.
Args:
features: An map of string to `Tensor`.
decode_length: An integer, how many additional timesteps to decode.
Returns:
A dict of decoding results... | python | def _slow_greedy_infer_tpu(self, features, decode_length):
"""A slow greedy inference method on TPU.
Quadratic time in decode_length.
Args:
features: An map of string to `Tensor`.
decode_length: An integer, how many additional timesteps to decode.
Returns:
A dict of decoding results... | [
"def",
"_slow_greedy_infer_tpu",
"(",
"self",
",",
"features",
",",
"decode_length",
")",
":",
"if",
"not",
"features",
":",
"features",
"=",
"{",
"}",
"inputs_old",
"=",
"None",
"if",
"\"inputs\"",
"in",
"features",
"and",
"len",
"(",
"features",
"[",
"\"... | A slow greedy inference method on TPU.
Quadratic time in decode_length.
Args:
features: An map of string to `Tensor`.
decode_length: An integer, how many additional timesteps to decode.
Returns:
A dict of decoding results {
"outputs": integer `Tensor` of decoded ids of shape
... | [
"A",
"slow",
"greedy",
"inference",
"method",
"on",
"TPU",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L977-L1143 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.sample | def sample(self, features):
"""Run the model and extract samples.
Args:
features: an map of string to `Tensor`.
Returns:
samples: an integer `Tensor`.
logits: a list of `Tensor`s, one per datashard.
losses: a dictionary: {loss-name (string): floating point `Scalar`}.
"""
... | python | def sample(self, features):
"""Run the model and extract samples.
Args:
features: an map of string to `Tensor`.
Returns:
samples: an integer `Tensor`.
logits: a list of `Tensor`s, one per datashard.
losses: a dictionary: {loss-name (string): floating point `Scalar`}.
"""
... | [
"def",
"sample",
"(",
"self",
",",
"features",
")",
":",
"logits",
",",
"losses",
"=",
"self",
"(",
"features",
")",
"# pylint: disable=not-callable",
"if",
"self",
".",
"_target_modality_is_real",
":",
"return",
"logits",
",",
"logits",
",",
"losses",
"# Raw ... | Run the model and extract samples.
Args:
features: an map of string to `Tensor`.
Returns:
samples: an integer `Tensor`.
logits: a list of `Tensor`s, one per datashard.
losses: a dictionary: {loss-name (string): floating point `Scalar`}. | [
"Run",
"the",
"model",
"and",
"extract",
"samples",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L1326-L1355 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.estimator_model_fn | def estimator_model_fn(cls,
hparams,
features,
labels,
mode,
config=None,
params=None,
decode_hparams=None,
use_tpu=Fals... | python | def estimator_model_fn(cls,
hparams,
features,
labels,
mode,
config=None,
params=None,
decode_hparams=None,
use_tpu=Fals... | [
"def",
"estimator_model_fn",
"(",
"cls",
",",
"hparams",
",",
"features",
",",
"labels",
",",
"mode",
",",
"config",
"=",
"None",
",",
"params",
"=",
"None",
",",
"decode_hparams",
"=",
"None",
",",
"use_tpu",
"=",
"False",
")",
":",
"if",
"mode",
"=="... | Model fn for Estimator.
Args:
hparams: HParams, model hyperparameters
features: dict<str name, Tensor feature>
labels: Tensor
mode: tf.estimator.ModeKeys
config: RunConfig, possibly with data_parallelism attribute
params: dict, may include batch_size, use_tpu
decode_hparam... | [
"Model",
"fn",
"for",
"Estimator",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L1418-L1538 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.estimator_spec_train | def estimator_spec_train(self, loss, num_async_replicas=1, use_tpu=False):
"""Constructs `tf.estimator.EstimatorSpec` for TRAIN (training) mode."""
train_op = self.optimize(loss, num_async_replicas=num_async_replicas,
use_tpu=use_tpu)
if use_tpu:
if self._hparams.warm_sta... | python | def estimator_spec_train(self, loss, num_async_replicas=1, use_tpu=False):
"""Constructs `tf.estimator.EstimatorSpec` for TRAIN (training) mode."""
train_op = self.optimize(loss, num_async_replicas=num_async_replicas,
use_tpu=use_tpu)
if use_tpu:
if self._hparams.warm_sta... | [
"def",
"estimator_spec_train",
"(",
"self",
",",
"loss",
",",
"num_async_replicas",
"=",
"1",
",",
"use_tpu",
"=",
"False",
")",
":",
"train_op",
"=",
"self",
".",
"optimize",
"(",
"loss",
",",
"num_async_replicas",
"=",
"num_async_replicas",
",",
"use_tpu",
... | Constructs `tf.estimator.EstimatorSpec` for TRAIN (training) mode. | [
"Constructs",
"tf",
".",
"estimator",
".",
"EstimatorSpec",
"for",
"TRAIN",
"(",
"training",
")",
"mode",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L1549-L1586 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.estimator_spec_eval | def estimator_spec_eval(self, features, logits, labels, loss, losses_dict):
"""Constructs `tf.estimator.EstimatorSpec` for EVAL (evaluation) mode."""
del losses_dict
hparams = self.hparams
if not hasattr(hparams, "problem"):
raise NotImplementedError(_no_problem_err("estimator_spec_eval"))
p... | python | def estimator_spec_eval(self, features, logits, labels, loss, losses_dict):
"""Constructs `tf.estimator.EstimatorSpec` for EVAL (evaluation) mode."""
del losses_dict
hparams = self.hparams
if not hasattr(hparams, "problem"):
raise NotImplementedError(_no_problem_err("estimator_spec_eval"))
p... | [
"def",
"estimator_spec_eval",
"(",
"self",
",",
"features",
",",
"logits",
",",
"labels",
",",
"loss",
",",
"losses_dict",
")",
":",
"del",
"losses_dict",
"hparams",
"=",
"self",
".",
"hparams",
"if",
"not",
"hasattr",
"(",
"hparams",
",",
"\"problem\"",
"... | Constructs `tf.estimator.EstimatorSpec` for EVAL (evaluation) mode. | [
"Constructs",
"tf",
".",
"estimator",
".",
"EstimatorSpec",
"for",
"EVAL",
"(",
"evaluation",
")",
"mode",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L1588-L1679 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.estimator_spec_predict | def estimator_spec_predict(self, features, use_tpu=False):
"""Constructs `tf.estimator.EstimatorSpec` for PREDICT (inference) mode."""
decode_hparams = self._decode_hparams
top_beams = decode_hparams.beam_size if decode_hparams.return_beams else 1
infer_out = self.infer(
features,
beam_s... | python | def estimator_spec_predict(self, features, use_tpu=False):
"""Constructs `tf.estimator.EstimatorSpec` for PREDICT (inference) mode."""
decode_hparams = self._decode_hparams
top_beams = decode_hparams.beam_size if decode_hparams.return_beams else 1
infer_out = self.infer(
features,
beam_s... | [
"def",
"estimator_spec_predict",
"(",
"self",
",",
"features",
",",
"use_tpu",
"=",
"False",
")",
":",
"decode_hparams",
"=",
"self",
".",
"_decode_hparams",
"top_beams",
"=",
"decode_hparams",
".",
"beam_size",
"if",
"decode_hparams",
".",
"return_beams",
"else",... | Constructs `tf.estimator.EstimatorSpec` for PREDICT (inference) mode. | [
"Constructs",
"tf",
".",
"estimator",
".",
"EstimatorSpec",
"for",
"PREDICT",
"(",
"inference",
")",
"mode",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L1681-L1754 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel._summarize_losses | def _summarize_losses(self, losses_dict):
"""Adds `tf.summary`s to all terms in the losses dictionary."""
if common_layers.should_generate_summaries():
with tf.name_scope("losses"):
for loss_name, loss_val in sorted(losses_dict.items()):
tf.summary.scalar(loss_name, loss_val) | python | def _summarize_losses(self, losses_dict):
"""Adds `tf.summary`s to all terms in the losses dictionary."""
if common_layers.should_generate_summaries():
with tf.name_scope("losses"):
for loss_name, loss_val in sorted(losses_dict.items()):
tf.summary.scalar(loss_name, loss_val) | [
"def",
"_summarize_losses",
"(",
"self",
",",
"losses_dict",
")",
":",
"if",
"common_layers",
".",
"should_generate_summaries",
"(",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"\"losses\"",
")",
":",
"for",
"loss_name",
",",
"loss_val",
"in",
"sorted",
... | Adds `tf.summary`s to all terms in the losses dictionary. | [
"Adds",
"tf",
".",
"summary",
"s",
"to",
"all",
"terms",
"in",
"the",
"losses",
"dictionary",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L1771-L1776 | train |
tensorflow/tensor2tensor | tensor2tensor/utils/t2t_model.py | T2TModel.maybe_scheduled_sampling | def maybe_scheduled_sampling(self, features, logits, losses):
"""Scheduled sampling.
Performs forward inference again with "targets" feature replaced with values
sampled from the model.
This is the identity unless self.hparams.scheduled_sampling_prob > 0
(default).
**WARNING**: This is not a ... | python | def maybe_scheduled_sampling(self, features, logits, losses):
"""Scheduled sampling.
Performs forward inference again with "targets" feature replaced with values
sampled from the model.
This is the identity unless self.hparams.scheduled_sampling_prob > 0
(default).
**WARNING**: This is not a ... | [
"def",
"maybe_scheduled_sampling",
"(",
"self",
",",
"features",
",",
"logits",
",",
"losses",
")",
":",
"hparams",
"=",
"self",
".",
"hparams",
"problem_hparams",
"=",
"self",
".",
"_problem_hparams",
"# Only do scheduled sampling if requested.",
"if",
"hparams",
"... | Scheduled sampling.
Performs forward inference again with "targets" feature replaced with values
sampled from the model.
This is the identity unless self.hparams.scheduled_sampling_prob > 0
(default).
**WARNING**: This is not a faithful implementation of scheduled sampling.
This implementatio... | [
"Scheduled",
"sampling",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/t2t_model.py#L1778-L1901 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_prepare_decoder | def attention_lm_moe_prepare_decoder(targets, hparams):
"""Prepare one shard of the model for the decoder.
Args:
targets: a Tensor.
hparams: run hyperparameters
Returns:
decoder_input: a Tensor, bottom of decoder stack
decoder_self_attention_bias: a Tensor, containing large negative values
t... | python | def attention_lm_moe_prepare_decoder(targets, hparams):
"""Prepare one shard of the model for the decoder.
Args:
targets: a Tensor.
hparams: run hyperparameters
Returns:
decoder_input: a Tensor, bottom of decoder stack
decoder_self_attention_bias: a Tensor, containing large negative values
t... | [
"def",
"attention_lm_moe_prepare_decoder",
"(",
"targets",
",",
"hparams",
")",
":",
"targets_pad_mask",
"=",
"common_attention",
".",
"embedding_to_padding",
"(",
"targets",
")",
"with",
"tf",
".",
"name_scope",
"(",
"\"pad_remover\"",
")",
":",
"# Because of the shi... | Prepare one shard of the model for the decoder.
Args:
targets: a Tensor.
hparams: run hyperparameters
Returns:
decoder_input: a Tensor, bottom of decoder stack
decoder_self_attention_bias: a Tensor, containing large negative values
to implement masked attention and possibly biases for diagonal... | [
"Prepare",
"one",
"shard",
"of",
"the",
"model",
"for",
"the",
"decoder",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L334-L364 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | get_batch_coordinate | def get_batch_coordinate(x, axis=0):
"""Return a flat int32 tensor of shape [1, batch_size*length, 1]."""
# Compute the batch coordinate before flattening all batches
batch_coordinate = tf.expand_dims(
common_attention.coordinate_tensor(tf.shape(x)[:-1], axis=axis), axis=-1)
return batch_coordinate | python | def get_batch_coordinate(x, axis=0):
"""Return a flat int32 tensor of shape [1, batch_size*length, 1]."""
# Compute the batch coordinate before flattening all batches
batch_coordinate = tf.expand_dims(
common_attention.coordinate_tensor(tf.shape(x)[:-1], axis=axis), axis=-1)
return batch_coordinate | [
"def",
"get_batch_coordinate",
"(",
"x",
",",
"axis",
"=",
"0",
")",
":",
"# Compute the batch coordinate before flattening all batches",
"batch_coordinate",
"=",
"tf",
".",
"expand_dims",
"(",
"common_attention",
".",
"coordinate_tensor",
"(",
"tf",
".",
"shape",
"("... | Return a flat int32 tensor of shape [1, batch_size*length, 1]. | [
"Return",
"a",
"flat",
"int32",
"tensor",
"of",
"shape",
"[",
"1",
"batch_size",
"*",
"length",
"1",
"]",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L368-L373 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | expand_batch_coordinates | def expand_batch_coordinates(bc, length_factor):
"""Duplicate elements of bc by length_factor.
Args:
bc (tf.Tensor): int32 tensor of shape [1, length, 1]
length_factor (int):
Returns:
tf.Tensor: of shape [1, length*length_factor, 1] where every elements has
been duplicated length_factor times.... | python | def expand_batch_coordinates(bc, length_factor):
"""Duplicate elements of bc by length_factor.
Args:
bc (tf.Tensor): int32 tensor of shape [1, length, 1]
length_factor (int):
Returns:
tf.Tensor: of shape [1, length*length_factor, 1] where every elements has
been duplicated length_factor times.... | [
"def",
"expand_batch_coordinates",
"(",
"bc",
",",
"length_factor",
")",
":",
"assert",
"bc",
".",
"get_shape",
"(",
")",
".",
"as_list",
"(",
")",
"==",
"[",
"1",
",",
"None",
",",
"1",
"]",
"# bc has shape [1, length, 1]",
"bc",
"*=",
"tf",
".",
"const... | Duplicate elements of bc by length_factor.
Args:
bc (tf.Tensor): int32 tensor of shape [1, length, 1]
length_factor (int):
Returns:
tf.Tensor: of shape [1, length*length_factor, 1] where every elements has
been duplicated length_factor times. | [
"Duplicate",
"elements",
"of",
"bc",
"by",
"length_factor",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L377-L394 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | remove_pad | def remove_pad(x, pad_remover, mode):
"""Remove padding by concatenating all dimension into one.
Args:
x (tf.Tensor): input of shape [batch_size, length, depth]
pad_remover (obj): a PadRemover object
mode (ModeKeys): infer, train or eval. If inference, the padding remover is
not applied
Return... | python | def remove_pad(x, pad_remover, mode):
"""Remove padding by concatenating all dimension into one.
Args:
x (tf.Tensor): input of shape [batch_size, length, depth]
pad_remover (obj): a PadRemover object
mode (ModeKeys): infer, train or eval. If inference, the padding remover is
not applied
Return... | [
"def",
"remove_pad",
"(",
"x",
",",
"pad_remover",
",",
"mode",
")",
":",
"# Concatenate all tokens (without padding)",
"x",
"=",
"expert_utils",
".",
"flatten_all_but_last",
"(",
"x",
")",
"# Remove padding for training and eval",
"if",
"mode",
"!=",
"ModeKeys",
".",... | Remove padding by concatenating all dimension into one.
Args:
x (tf.Tensor): input of shape [batch_size, length, depth]
pad_remover (obj): a PadRemover object
mode (ModeKeys): infer, train or eval. If inference, the padding remover is
not applied
Returns:
tf.Tensor of shape [1,length_nonpad,... | [
"Remove",
"padding",
"by",
"concatenating",
"all",
"dimension",
"into",
"one",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L398-L422 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_base | def attention_lm_moe_base():
"""Set of hyperparameters.
suitable for 1 gpu.
on lm1b_32k:
~229M params
0.9 steps/sec on [GeForce GTX TITAN X]
Returns:
a hparams object
"""
hparams = common_hparams.basic_params1()
hparams.hidden_size = 1024
hparams.batch_size = 8192
hparams.max_length =... | python | def attention_lm_moe_base():
"""Set of hyperparameters.
suitable for 1 gpu.
on lm1b_32k:
~229M params
0.9 steps/sec on [GeForce GTX TITAN X]
Returns:
a hparams object
"""
hparams = common_hparams.basic_params1()
hparams.hidden_size = 1024
hparams.batch_size = 8192
hparams.max_length =... | [
"def",
"attention_lm_moe_base",
"(",
")",
":",
"hparams",
"=",
"common_hparams",
".",
"basic_params1",
"(",
")",
"hparams",
".",
"hidden_size",
"=",
"1024",
"hparams",
".",
"batch_size",
"=",
"8192",
"hparams",
".",
"max_length",
"=",
"256",
"hparams",
".",
... | Set of hyperparameters.
suitable for 1 gpu.
on lm1b_32k:
~229M params
0.9 steps/sec on [GeForce GTX TITAN X]
Returns:
a hparams object | [
"Set",
"of",
"hyperparameters",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L435-L515 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_base_long_seq | def attention_lm_moe_base_long_seq():
"""Hyper parameters specifics for long sequence generation."""
hparams = attention_lm_moe_base()
hparams.max_length = 0 # max_length == batch_size
hparams.eval_drop_long_sequences = True
hparams.min_length_bucket = 256 # Avoid cyclic problems for big batches
hparams.... | python | def attention_lm_moe_base_long_seq():
"""Hyper parameters specifics for long sequence generation."""
hparams = attention_lm_moe_base()
hparams.max_length = 0 # max_length == batch_size
hparams.eval_drop_long_sequences = True
hparams.min_length_bucket = 256 # Avoid cyclic problems for big batches
hparams.... | [
"def",
"attention_lm_moe_base_long_seq",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_base",
"(",
")",
"hparams",
".",
"max_length",
"=",
"0",
"# max_length == batch_size",
"hparams",
".",
"eval_drop_long_sequences",
"=",
"True",
"hparams",
".",
"min_length_bucket",... | Hyper parameters specifics for long sequence generation. | [
"Hyper",
"parameters",
"specifics",
"for",
"long",
"sequence",
"generation",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L519-L528 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_base_ae | def attention_lm_moe_base_ae():
"""Base model with attention expert."""
hparams = attention_lm_moe_base_long_seq()
hparams.attention_type = AttentionType.LOCAL_EXPERTS
hparams.learning_rate = 0.05
hparams.learning_rate_warmup_steps = 10000
# According to noam, ("n", "da") seems better for harder-to-learn m... | python | def attention_lm_moe_base_ae():
"""Base model with attention expert."""
hparams = attention_lm_moe_base_long_seq()
hparams.attention_type = AttentionType.LOCAL_EXPERTS
hparams.learning_rate = 0.05
hparams.learning_rate_warmup_steps = 10000
# According to noam, ("n", "da") seems better for harder-to-learn m... | [
"def",
"attention_lm_moe_base_ae",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_base_long_seq",
"(",
")",
"hparams",
".",
"attention_type",
"=",
"AttentionType",
".",
"LOCAL_EXPERTS",
"hparams",
".",
"learning_rate",
"=",
"0.05",
"hparams",
".",
"learning_rate_war... | Base model with attention expert. | [
"Base",
"model",
"with",
"attention",
"expert",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L532-L542 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_ae_extended | def attention_lm_ae_extended():
"""Experiment with the exp_factor params."""
hparams = attention_lm_moe_base_long_seq()
hparams.attention_layers = "eeee"
hparams.attention_local = True
# hparams.factored_logits=1 # Necessary when the number of expert grow bigger
hparams.attention_moe_k = 2
hparams.attent... | python | def attention_lm_ae_extended():
"""Experiment with the exp_factor params."""
hparams = attention_lm_moe_base_long_seq()
hparams.attention_layers = "eeee"
hparams.attention_local = True
# hparams.factored_logits=1 # Necessary when the number of expert grow bigger
hparams.attention_moe_k = 2
hparams.attent... | [
"def",
"attention_lm_ae_extended",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_base_long_seq",
"(",
")",
"hparams",
".",
"attention_layers",
"=",
"\"eeee\"",
"hparams",
".",
"attention_local",
"=",
"True",
"# hparams.factored_logits=1 # Necessary when the number of expe... | Experiment with the exp_factor params. | [
"Experiment",
"with",
"the",
"exp_factor",
"params",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L599-L611 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_base_memeff | def attention_lm_moe_base_memeff():
"""Base model with attention expert."""
hparams = attention_lm_moe_base_long_seq()
hparams.use_sepconv = False
hparams.diet_experts = True
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
hparams.layer_prepostprocess_dropout = 0.0
hpa... | python | def attention_lm_moe_base_memeff():
"""Base model with attention expert."""
hparams = attention_lm_moe_base_long_seq()
hparams.use_sepconv = False
hparams.diet_experts = True
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
hparams.layer_prepostprocess_dropout = 0.0
hpa... | [
"def",
"attention_lm_moe_base_memeff",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_base_long_seq",
"(",
")",
"hparams",
".",
"use_sepconv",
"=",
"False",
"hparams",
".",
"diet_experts",
"=",
"True",
"hparams",
".",
"layer_preprocess_sequence",
"=",
"\"n\"",
"hp... | Base model with attention expert. | [
"Base",
"model",
"with",
"attention",
"expert",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L615-L628 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_small | def attention_lm_moe_small():
"""Cheap model for single-gpu training.
on lm1b_32k:
~312M params
1.6 steps/sec on [GeForce GTX TITAN X]
After 50K steps on 8 GPUs (synchronous):
eval_log_ppl_per_token = 3.31
Returns:
an hparams object.
"""
hparams = attention_lm_moe_base()
hparam... | python | def attention_lm_moe_small():
"""Cheap model for single-gpu training.
on lm1b_32k:
~312M params
1.6 steps/sec on [GeForce GTX TITAN X]
After 50K steps on 8 GPUs (synchronous):
eval_log_ppl_per_token = 3.31
Returns:
an hparams object.
"""
hparams = attention_lm_moe_base()
hparam... | [
"def",
"attention_lm_moe_small",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_base",
"(",
")",
"hparams",
".",
"num_hidden_layers",
"=",
"4",
"hparams",
".",
"hidden_size",
"=",
"512",
"hparams",
".",
"filter_size",
"=",
"2048",
"hparams",
".",
"moe_num_expe... | Cheap model for single-gpu training.
on lm1b_32k:
~312M params
1.6 steps/sec on [GeForce GTX TITAN X]
After 50K steps on 8 GPUs (synchronous):
eval_log_ppl_per_token = 3.31
Returns:
an hparams object. | [
"Cheap",
"model",
"for",
"single",
"-",
"gpu",
"training",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L632-L650 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_attention_moe_tiny | def attention_lm_attention_moe_tiny():
"""Cheap model for debugging.
Returns:
an hparams object.
"""
hparams = attention_lm_moe_small()
hparams.moe_layers = ""
hparams.attention_num_experts = 128
hparams.filter_size = 8192
hparams.attention_type = AttentionType.LOCAL_EXPERTS
return hparams | python | def attention_lm_attention_moe_tiny():
"""Cheap model for debugging.
Returns:
an hparams object.
"""
hparams = attention_lm_moe_small()
hparams.moe_layers = ""
hparams.attention_num_experts = 128
hparams.filter_size = 8192
hparams.attention_type = AttentionType.LOCAL_EXPERTS
return hparams | [
"def",
"attention_lm_attention_moe_tiny",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_small",
"(",
")",
"hparams",
".",
"moe_layers",
"=",
"\"\"",
"hparams",
".",
"attention_num_experts",
"=",
"128",
"hparams",
".",
"filter_size",
"=",
"8192",
"hparams",
".",... | Cheap model for debugging.
Returns:
an hparams object. | [
"Cheap",
"model",
"for",
"debugging",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L666-L677 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_large | def attention_lm_moe_large():
"""Large model for distributed training.
Over 1B parameters, so requires multi-gpu training due to memory
requirements.
on lm1b_32k:
After 45K steps on 8 GPUs (synchronous):
eval_log_ppl_per_token = 3.18
eval_ppl_per_word = exp(1.107893 * eval_log_ppl_per_to... | python | def attention_lm_moe_large():
"""Large model for distributed training.
Over 1B parameters, so requires multi-gpu training due to memory
requirements.
on lm1b_32k:
After 45K steps on 8 GPUs (synchronous):
eval_log_ppl_per_token = 3.18
eval_ppl_per_word = exp(1.107893 * eval_log_ppl_per_to... | [
"def",
"attention_lm_moe_large",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_base",
"(",
")",
"hparams",
".",
"num_hidden_layers",
"=",
"5",
"hparams",
".",
"moe_layers",
"=",
"\"3\"",
"hparams",
".",
"hidden_size",
"=",
"1024",
"hparams",
".",
"num_heads",... | Large model for distributed training.
Over 1B parameters, so requires multi-gpu training due to memory
requirements.
on lm1b_32k:
After 45K steps on 8 GPUs (synchronous):
eval_log_ppl_per_token = 3.18
eval_ppl_per_word = exp(1.107893 * eval_log_ppl_per_token) = 33.9
Returns:
an hpar... | [
"Large",
"model",
"for",
"distributed",
"training",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L699-L722 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_memory_efficient | def attention_lm_moe_memory_efficient():
"""Memory-efficient version."""
hparams = attention_lm_moe_large()
hparams.diet_experts = True
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
hparams.layer_prepostprocess_dropout = 0.0
hparams.memory_efficient_ffn = True
hparams... | python | def attention_lm_moe_memory_efficient():
"""Memory-efficient version."""
hparams = attention_lm_moe_large()
hparams.diet_experts = True
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
hparams.layer_prepostprocess_dropout = 0.0
hparams.memory_efficient_ffn = True
hparams... | [
"def",
"attention_lm_moe_memory_efficient",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_large",
"(",
")",
"hparams",
".",
"diet_experts",
"=",
"True",
"hparams",
".",
"layer_preprocess_sequence",
"=",
"\"n\"",
"hparams",
".",
"layer_postprocess_sequence",
"=",
"\... | Memory-efficient version. | [
"Memory",
"-",
"efficient",
"version",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L733-L744 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_24b_diet | def attention_lm_moe_24b_diet():
"""Unnecessarily large model with 24B params - because we can."""
hparams = attention_lm_moe_large_diet()
hparams.moe_hidden_sizes = "12288"
hparams.moe_num_experts = 1024
hparams.batch_size = 4096
return hparams | python | def attention_lm_moe_24b_diet():
"""Unnecessarily large model with 24B params - because we can."""
hparams = attention_lm_moe_large_diet()
hparams.moe_hidden_sizes = "12288"
hparams.moe_num_experts = 1024
hparams.batch_size = 4096
return hparams | [
"def",
"attention_lm_moe_24b_diet",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_large_diet",
"(",
")",
"hparams",
".",
"moe_hidden_sizes",
"=",
"\"12288\"",
"hparams",
".",
"moe_num_experts",
"=",
"1024",
"hparams",
".",
"batch_size",
"=",
"4096",
"return",
"... | Unnecessarily large model with 24B params - because we can. | [
"Unnecessarily",
"large",
"model",
"with",
"24B",
"params",
"-",
"because",
"we",
"can",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L757-L763 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_translation | def attention_lm_moe_translation():
"""Version to use for seq2seq."""
hparams = attention_lm_moe_base()
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
hparams.learning_rate = 0.4
hparams.prepend_mode = "prepend_inputs_masked_attention"
hparams.max_length = 512
hparams.... | python | def attention_lm_moe_translation():
"""Version to use for seq2seq."""
hparams = attention_lm_moe_base()
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
hparams.learning_rate = 0.4
hparams.prepend_mode = "prepend_inputs_masked_attention"
hparams.max_length = 512
hparams.... | [
"def",
"attention_lm_moe_translation",
"(",
")",
":",
"hparams",
"=",
"attention_lm_moe_base",
"(",
")",
"hparams",
".",
"layer_preprocess_sequence",
"=",
"\"n\"",
"hparams",
".",
"layer_postprocess_sequence",
"=",
"\"da\"",
"hparams",
".",
"learning_rate",
"=",
"0.4"... | Version to use for seq2seq. | [
"Version",
"to",
"use",
"for",
"seq2seq",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L767-L780 | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/attention_lm_moe.py | attention_lm_moe_unscramble_base | def attention_lm_moe_unscramble_base():
"""Version to use with languagemodel_wiki_scramble1k50."""
hparams = attention_lm_no_moe_small()
hparams.use_inputs = True
hparams.min_length_bucket = 1024
hparams.max_length = 1024
hparams.batch_size = 5000
hparams.layer_prepostprocess_dropout = 0.0
hparams.layer... | python | def attention_lm_moe_unscramble_base():
"""Version to use with languagemodel_wiki_scramble1k50."""
hparams = attention_lm_no_moe_small()
hparams.use_inputs = True
hparams.min_length_bucket = 1024
hparams.max_length = 1024
hparams.batch_size = 5000
hparams.layer_prepostprocess_dropout = 0.0
hparams.layer... | [
"def",
"attention_lm_moe_unscramble_base",
"(",
")",
":",
"hparams",
"=",
"attention_lm_no_moe_small",
"(",
")",
"hparams",
".",
"use_inputs",
"=",
"True",
"hparams",
".",
"min_length_bucket",
"=",
"1024",
"hparams",
".",
"max_length",
"=",
"1024",
"hparams",
".",... | Version to use with languagemodel_wiki_scramble1k50. | [
"Version",
"to",
"use",
"with",
"languagemodel_wiki_scramble1k50",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/attention_lm_moe.py#L784-L794 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | audio_bottom | def audio_bottom(x, model_hparams, vocab_size):
"""Transform input from data space to model space.
Args:
x: A Tensor with shape [batch, ...]
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
body_input: A Tensor with shape [batch, ?, ?,
model_hparams.... | python | def audio_bottom(x, model_hparams, vocab_size):
"""Transform input from data space to model space.
Args:
x: A Tensor with shape [batch, ...]
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
body_input: A Tensor with shape [batch, ?, ?,
model_hparams.... | [
"def",
"audio_bottom",
"(",
"x",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"vocab_size",
"# unused arg",
"inputs",
"=",
"x",
"with",
"tf",
".",
"variable_scope",
"(",
"\"audio_modality\"",
")",
":",
"# TODO(aidangomez): Will need to sort out a better a... | Transform input from data space to model space.
Args:
x: A Tensor with shape [batch, ...]
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
body_input: A Tensor with shape [batch, ?, ?,
model_hparams.hidden_size]. | [
"Transform",
"input",
"from",
"data",
"space",
"to",
"model",
"space",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L128-L173 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | image_targets_bottom | def image_targets_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for target images."""
pixel_embedding_size = 64
inputs = x
with tf.variable_scope("image_modality"):
if not tf.executing_eagerly():
tf.summary.image(
"targets_bottom",
common_layers.tpu_safe_image_summ... | python | def image_targets_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for target images."""
pixel_embedding_size = 64
inputs = x
with tf.variable_scope("image_modality"):
if not tf.executing_eagerly():
tf.summary.image(
"targets_bottom",
common_layers.tpu_safe_image_summ... | [
"def",
"image_targets_bottom",
"(",
"x",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"pixel_embedding_size",
"=",
"64",
"inputs",
"=",
"x",
"with",
"tf",
".",
"variable_scope",
"(",
"\"image_modality\"",
")",
":",
"if",
"not",
"tf",
".",
"executing_eage... | Bottom transformation for target images. | [
"Bottom",
"transformation",
"for",
"target",
"images",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L260-L288 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | _image_channel_compress_bottom | def _image_channel_compress_bottom(inputs, model_hparams, name="bottom"):
"""Compresses channel-wise input pixels into whole pixel representions.
Perform conversion of RGB pixel values to a real number in the range -1 to
1. This combines pixel channels to form a representation of shape
[img_len, img_len].
A... | python | def _image_channel_compress_bottom(inputs, model_hparams, name="bottom"):
"""Compresses channel-wise input pixels into whole pixel representions.
Perform conversion of RGB pixel values to a real number in the range -1 to
1. This combines pixel channels to form a representation of shape
[img_len, img_len].
A... | [
"def",
"_image_channel_compress_bottom",
"(",
"inputs",
",",
"model_hparams",
",",
"name",
"=",
"\"bottom\"",
")",
":",
"num_channels",
"=",
"3",
"with",
"tf",
".",
"variable_scope",
"(",
"name",
")",
":",
"inputs",
"=",
"tf",
".",
"to_float",
"(",
"inputs",... | Compresses channel-wise input pixels into whole pixel representions.
Perform conversion of RGB pixel values to a real number in the range -1 to
1. This combines pixel channels to form a representation of shape
[img_len, img_len].
Args:
inputs: Tensor representing RGB pixel intensities as integers, of shap... | [
"Compresses",
"channel",
"-",
"wise",
"input",
"pixels",
"into",
"whole",
"pixel",
"representions",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L291-L333 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | image_channel_embeddings_bottom | def image_channel_embeddings_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for image targets."""
del vocab_size # unused arg
inputs = tf.to_int32(x)
io_depth = model_hparams.num_channels
tshape = common_layers.shape_list(inputs)
hidden_size = model_hparams.hidden_size
target_embeddings =... | python | def image_channel_embeddings_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for image targets."""
del vocab_size # unused arg
inputs = tf.to_int32(x)
io_depth = model_hparams.num_channels
tshape = common_layers.shape_list(inputs)
hidden_size = model_hparams.hidden_size
target_embeddings =... | [
"def",
"image_channel_embeddings_bottom",
"(",
"x",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"vocab_size",
"# unused arg",
"inputs",
"=",
"tf",
".",
"to_int32",
"(",
"x",
")",
"io_depth",
"=",
"model_hparams",
".",
"num_channels",
"tshape",
"=",... | Bottom transformation for image targets. | [
"Bottom",
"transformation",
"for",
"image",
"targets",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L346-L356 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | speech_recognition_bottom | def speech_recognition_bottom(x, model_hparams, vocab_size):
"""Use batchnorm instead of CMVN and shorten the stft with strided convs.
Args:
x: float32 tensor with shape [batch_size, len, 1, freqs * channels]
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
... | python | def speech_recognition_bottom(x, model_hparams, vocab_size):
"""Use batchnorm instead of CMVN and shorten the stft with strided convs.
Args:
x: float32 tensor with shape [batch_size, len, 1, freqs * channels]
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
... | [
"def",
"speech_recognition_bottom",
"(",
"x",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"vocab_size",
"# unused arg",
"inputs",
"=",
"x",
"p",
"=",
"model_hparams",
"num_mel_bins",
"=",
"p",
".",
"audio_num_mel_bins",
"num_channels",
"=",
"3",
"i... | Use batchnorm instead of CMVN and shorten the stft with strided convs.
Args:
x: float32 tensor with shape [batch_size, len, 1, freqs * channels]
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
float32 tensor with shape [batch_size, shorter_len, 1, hidden_si... | [
"Use",
"batchnorm",
"instead",
"of",
"CMVN",
"and",
"shorten",
"the",
"stft",
"with",
"strided",
"convs",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L373-L452 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | get_weights | def get_weights(model_hparams, vocab_size, hidden_dim=None):
"""Create or get concatenated embedding or softmax variable.
Args:
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
hidden_dim: dim of the variable. Defaults to _model_hparams' hidden_size
Returns:
a lis... | python | def get_weights(model_hparams, vocab_size, hidden_dim=None):
"""Create or get concatenated embedding or softmax variable.
Args:
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
hidden_dim: dim of the variable. Defaults to _model_hparams' hidden_size
Returns:
a lis... | [
"def",
"get_weights",
"(",
"model_hparams",
",",
"vocab_size",
",",
"hidden_dim",
"=",
"None",
")",
":",
"if",
"hidden_dim",
"is",
"None",
":",
"hidden_dim",
"=",
"model_hparams",
".",
"hidden_size",
"num_shards",
"=",
"model_hparams",
".",
"symbol_modality_num_sh... | Create or get concatenated embedding or softmax variable.
Args:
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
hidden_dim: dim of the variable. Defaults to _model_hparams' hidden_size
Returns:
a list of num_shards Tensors. | [
"Create",
"or",
"get",
"concatenated",
"embedding",
"or",
"softmax",
"variable",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L455-L485 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | _symbol_bottom_simple | def _symbol_bottom_simple(x, model_hparams, vocab_size, name, reuse):
"""Bottom transformation for symbols."""
with tf.variable_scope(name, reuse=reuse):
# Ensure the inputs are 3-D
if len(x.get_shape()) == 4:
x = tf.squeeze(x, axis=3)
while len(x.get_shape()) < 3:
x = tf.expand_dims(x, axis... | python | def _symbol_bottom_simple(x, model_hparams, vocab_size, name, reuse):
"""Bottom transformation for symbols."""
with tf.variable_scope(name, reuse=reuse):
# Ensure the inputs are 3-D
if len(x.get_shape()) == 4:
x = tf.squeeze(x, axis=3)
while len(x.get_shape()) < 3:
x = tf.expand_dims(x, axis... | [
"def",
"_symbol_bottom_simple",
"(",
"x",
",",
"model_hparams",
",",
"vocab_size",
",",
"name",
",",
"reuse",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"name",
",",
"reuse",
"=",
"reuse",
")",
":",
"# Ensure the inputs are 3-D",
"if",
"len",
"(",
... | Bottom transformation for symbols. | [
"Bottom",
"transformation",
"for",
"symbols",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L488-L505 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | symbol_targets_bottom | def symbol_targets_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for target symbols."""
if (model_hparams.shared_embedding_and_softmax_weights or
model_hparams.get("shared_embedding")):
try:
return _symbol_bottom_simple(
x, model_hparams, vocab_size, "shared", reuse=True)
... | python | def symbol_targets_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for target symbols."""
if (model_hparams.shared_embedding_and_softmax_weights or
model_hparams.get("shared_embedding")):
try:
return _symbol_bottom_simple(
x, model_hparams, vocab_size, "shared", reuse=True)
... | [
"def",
"symbol_targets_bottom",
"(",
"x",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"if",
"(",
"model_hparams",
".",
"shared_embedding_and_softmax_weights",
"or",
"model_hparams",
".",
"get",
"(",
"\"shared_embedding\"",
")",
")",
":",
"try",
":",
"return... | Bottom transformation for target symbols. | [
"Bottom",
"transformation",
"for",
"target",
"symbols",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L517-L530 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | video_bitwise_bottom | def video_bitwise_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for embedding video bitwise."""
pixel_embedding_size = 64
inputs = x
with tf.variable_scope("video_modality_bitwise", reuse=tf.AUTO_REUSE):
common_layers.summarize_video(inputs, "bottom")
# Embed bitwise.
assert vocab_s... | python | def video_bitwise_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for embedding video bitwise."""
pixel_embedding_size = 64
inputs = x
with tf.variable_scope("video_modality_bitwise", reuse=tf.AUTO_REUSE):
common_layers.summarize_video(inputs, "bottom")
# Embed bitwise.
assert vocab_s... | [
"def",
"video_bitwise_bottom",
"(",
"x",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"pixel_embedding_size",
"=",
"64",
"inputs",
"=",
"x",
"with",
"tf",
".",
"variable_scope",
"(",
"\"video_modality_bitwise\"",
",",
"reuse",
"=",
"tf",
".",
"AUTO_REUSE",... | Bottom transformation for embedding video bitwise. | [
"Bottom",
"transformation",
"for",
"embedding",
"video",
"bitwise",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L552-L566 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | video_pixel_noise_bottom | def video_pixel_noise_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for video."""
input_noise = getattr(model_hparams, "video_modality_input_noise", 0.25)
inputs = x
if model_hparams.mode == tf.estimator.ModeKeys.TRAIN:
background = tfp.stats.percentile(inputs, 50., axis=[0, 1, 2, 3])
i... | python | def video_pixel_noise_bottom(x, model_hparams, vocab_size):
"""Bottom transformation for video."""
input_noise = getattr(model_hparams, "video_modality_input_noise", 0.25)
inputs = x
if model_hparams.mode == tf.estimator.ModeKeys.TRAIN:
background = tfp.stats.percentile(inputs, 50., axis=[0, 1, 2, 3])
i... | [
"def",
"video_pixel_noise_bottom",
"(",
"x",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"input_noise",
"=",
"getattr",
"(",
"model_hparams",
",",
"\"video_modality_input_noise\"",
",",
"0.25",
")",
"inputs",
"=",
"x",
"if",
"model_hparams",
".",
"mode",
... | Bottom transformation for video. | [
"Bottom",
"transformation",
"for",
"video",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L599-L612 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | convert_rgb_to_real | def convert_rgb_to_real(prediction, targets):
"""Convert prediction and target from rgb to real."""
prediction = tf.squeeze(prediction, axis=-1)
prediction = common_layers.convert_rgb_to_real(prediction)
targets = common_layers.convert_rgb_to_real(targets)
return prediction, targets | python | def convert_rgb_to_real(prediction, targets):
"""Convert prediction and target from rgb to real."""
prediction = tf.squeeze(prediction, axis=-1)
prediction = common_layers.convert_rgb_to_real(prediction)
targets = common_layers.convert_rgb_to_real(targets)
return prediction, targets | [
"def",
"convert_rgb_to_real",
"(",
"prediction",
",",
"targets",
")",
":",
"prediction",
"=",
"tf",
".",
"squeeze",
"(",
"prediction",
",",
"axis",
"=",
"-",
"1",
")",
"prediction",
"=",
"common_layers",
".",
"convert_rgb_to_real",
"(",
"prediction",
")",
"t... | Convert prediction and target from rgb to real. | [
"Convert",
"prediction",
"and",
"target",
"from",
"rgb",
"to",
"real",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L615-L620 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | ctc_symbol_loss | def ctc_symbol_loss(top_out, targets, model_hparams, vocab_size, weight_fn):
"""Compute the CTC loss."""
del model_hparams, vocab_size # unused arg
logits = top_out
with tf.name_scope("ctc_loss", values=[logits, targets]):
# For CTC we assume targets are 1d, [batch, length, 1, 1] here.
targets_shape = ... | python | def ctc_symbol_loss(top_out, targets, model_hparams, vocab_size, weight_fn):
"""Compute the CTC loss."""
del model_hparams, vocab_size # unused arg
logits = top_out
with tf.name_scope("ctc_loss", values=[logits, targets]):
# For CTC we assume targets are 1d, [batch, length, 1, 1] here.
targets_shape = ... | [
"def",
"ctc_symbol_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weight_fn",
")",
":",
"del",
"model_hparams",
",",
"vocab_size",
"# unused arg",
"logits",
"=",
"top_out",
"with",
"tf",
".",
"name_scope",
"(",
"\"ctc_loss\... | Compute the CTC loss. | [
"Compute",
"the",
"CTC",
"loss",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L638-L662 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | generic_loss | def generic_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Compute loss numerator and denominator for one shard of output."""
del vocab_size # unused arg
logits = top_out
logits = common_attention.maybe_upcast(logits, hparams=model_hparams)
cutoff = getattr(model_hparams, "video_modality_l... | python | def generic_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Compute loss numerator and denominator for one shard of output."""
del vocab_size # unused arg
logits = top_out
logits = common_attention.maybe_upcast(logits, hparams=model_hparams)
cutoff = getattr(model_hparams, "video_modality_l... | [
"def",
"generic_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weights_fn",
")",
":",
"del",
"vocab_size",
"# unused arg",
"logits",
"=",
"top_out",
"logits",
"=",
"common_attention",
".",
"maybe_upcast",
"(",
"logits",
","... | Compute loss numerator and denominator for one shard of output. | [
"Compute",
"loss",
"numerator",
"and",
"denominator",
"for",
"one",
"shard",
"of",
"output",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L665-L676 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | multi_label_loss | def multi_label_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Average loss over the labels."""
del vocab_size # unused arg
logits = top_out
num_labels = tf.shape(targets)[1]
logits = tf.tile(logits, [1, num_labels, 1, 1, 1])
xent, weights = common_layers.padded_cross_entropy(
log... | python | def multi_label_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Average loss over the labels."""
del vocab_size # unused arg
logits = top_out
num_labels = tf.shape(targets)[1]
logits = tf.tile(logits, [1, num_labels, 1, 1, 1])
xent, weights = common_layers.padded_cross_entropy(
log... | [
"def",
"multi_label_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weights_fn",
")",
":",
"del",
"vocab_size",
"# unused arg",
"logits",
"=",
"top_out",
"num_labels",
"=",
"tf",
".",
"shape",
"(",
"targets",
")",
"[",
"... | Average loss over the labels. | [
"Average",
"loss",
"over",
"the",
"labels",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L689-L711 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | one_hot_class_label_loss | def one_hot_class_label_loss(top_out,
targets,
model_hparams,
vocab_size,
weights_fn):
"""Apply softmax cross-entropy between outputs and targets.
Args:
top_out: logits Tensor with shape [batch, ... | python | def one_hot_class_label_loss(top_out,
targets,
model_hparams,
vocab_size,
weights_fn):
"""Apply softmax cross-entropy between outputs and targets.
Args:
top_out: logits Tensor with shape [batch, ... | [
"def",
"one_hot_class_label_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weights_fn",
")",
":",
"del",
"model_hparams",
",",
"vocab_size",
"# unused arg",
"loss_scale",
"=",
"tf",
".",
"losses",
".",
"softmax_cross_entropy",
... | Apply softmax cross-entropy between outputs and targets.
Args:
top_out: logits Tensor with shape [batch, ?, ?, num_classes]
targets: one-hot encoding Tensor with shape [batch, ?, ?, num_classes]
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
weights_fn:
Returns... | [
"Apply",
"softmax",
"cross",
"-",
"entropy",
"between",
"outputs",
"and",
"targets",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L714-L736 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | real_log_poisson_loss | def real_log_poisson_loss(top_out,
targets,
model_hparams,
vocab_size,
weights_fn):
"""Poisson loss for real."""
del model_hparams, vocab_size # unused arg
predictions = top_out
if (len(common_layers.shape_l... | python | def real_log_poisson_loss(top_out,
targets,
model_hparams,
vocab_size,
weights_fn):
"""Poisson loss for real."""
del model_hparams, vocab_size # unused arg
predictions = top_out
if (len(common_layers.shape_l... | [
"def",
"real_log_poisson_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weights_fn",
")",
":",
"del",
"model_hparams",
",",
"vocab_size",
"# unused arg",
"predictions",
"=",
"top_out",
"if",
"(",
"len",
"(",
"common_layers",
... | Poisson loss for real. | [
"Poisson",
"loss",
"for",
"real",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L751-L765 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | sigmoid_class_label_loss | def sigmoid_class_label_loss(top_out,
targets,
model_hparams,
vocab_size,
weights_fn):
"""Loss for class label."""
# Expect inputs of size [batch-size, timesteps, 1, num-classes], where the
# last d... | python | def sigmoid_class_label_loss(top_out,
targets,
model_hparams,
vocab_size,
weights_fn):
"""Loss for class label."""
# Expect inputs of size [batch-size, timesteps, 1, num-classes], where the
# last d... | [
"def",
"sigmoid_class_label_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weights_fn",
")",
":",
"# Expect inputs of size [batch-size, timesteps, 1, num-classes], where the",
"# last dimension of num-classes represents logits for binary labels",
... | Loss for class label. | [
"Loss",
"for",
"class",
"label",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L768-L781 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | video_loss | def video_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Compute loss numerator and denominator for one shard of output."""
del vocab_size # unused arg
logits = top_out
logits = tf.reshape(logits, [-1] + common_layers.shape_list(logits)[2:])
targets = tf.reshape(targets, [-1] + common_laye... | python | def video_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Compute loss numerator and denominator for one shard of output."""
del vocab_size # unused arg
logits = top_out
logits = tf.reshape(logits, [-1] + common_layers.shape_list(logits)[2:])
targets = tf.reshape(targets, [-1] + common_laye... | [
"def",
"video_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weights_fn",
")",
":",
"del",
"vocab_size",
"# unused arg",
"logits",
"=",
"top_out",
"logits",
"=",
"tf",
".",
"reshape",
"(",
"logits",
",",
"[",
"-",
"1"... | Compute loss numerator and denominator for one shard of output. | [
"Compute",
"loss",
"numerator",
"and",
"denominator",
"for",
"one",
"shard",
"of",
"output",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L812-L824 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | video_l1_loss | def video_l1_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Compute loss numerator and denominator for one shard of output."""
del vocab_size # unused arg
logits = top_out
logits = tf.reshape(logits, [-1] + common_layers.shape_list(logits)[2:-1])
targets = tf.reshape(targets, [-1] + common... | python | def video_l1_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Compute loss numerator and denominator for one shard of output."""
del vocab_size # unused arg
logits = top_out
logits = tf.reshape(logits, [-1] + common_layers.shape_list(logits)[2:-1])
targets = tf.reshape(targets, [-1] + common... | [
"def",
"video_l1_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weights_fn",
")",
":",
"del",
"vocab_size",
"# unused arg",
"logits",
"=",
"top_out",
"logits",
"=",
"tf",
".",
"reshape",
"(",
"logits",
",",
"[",
"-",
... | Compute loss numerator and denominator for one shard of output. | [
"Compute",
"loss",
"numerator",
"and",
"denominator",
"for",
"one",
"shard",
"of",
"output",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L852-L865 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | video_l2_loss | def video_l2_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Compute loss numerator and denominator for one shard of output."""
del vocab_size # unused arg
logits = top_out
logits = tf.reshape(logits, [-1] + common_layers.shape_list(logits)[2:-1])
targets = tf.reshape(targets, [-1] + common... | python | def video_l2_loss(top_out, targets, model_hparams, vocab_size, weights_fn):
"""Compute loss numerator and denominator for one shard of output."""
del vocab_size # unused arg
logits = top_out
logits = tf.reshape(logits, [-1] + common_layers.shape_list(logits)[2:-1])
targets = tf.reshape(targets, [-1] + common... | [
"def",
"video_l2_loss",
"(",
"top_out",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
",",
"weights_fn",
")",
":",
"del",
"vocab_size",
"# unused arg",
"logits",
"=",
"top_out",
"logits",
"=",
"tf",
".",
"reshape",
"(",
"logits",
",",
"[",
"-",
... | Compute loss numerator and denominator for one shard of output. | [
"Compute",
"loss",
"numerator",
"and",
"denominator",
"for",
"one",
"shard",
"of",
"output",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L874-L887 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | class_label_top | def class_label_top(body_output, targets, model_hparams, vocab_size):
"""Transform inputs from model space to target space.
Average over inner dims and a linear layer to logits.
Args:
body_output: A Tensor with shape [batch, ?, ?, body_output_size].
targets:
model_hparams: HParams, model hyperparmet... | python | def class_label_top(body_output, targets, model_hparams, vocab_size):
"""Transform inputs from model space to target space.
Average over inner dims and a linear layer to logits.
Args:
body_output: A Tensor with shape [batch, ?, ?, body_output_size].
targets:
model_hparams: HParams, model hyperparmet... | [
"def",
"class_label_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
"# unused arg",
"with",
"tf",
".",
"variable_scope",
"(",
"\"class_label_modality_%d_%d\"",
"%",
"(",
"vocab_size",
",",
"model_hparams... | Transform inputs from model space to target space.
Average over inner dims and a linear layer to logits.
Args:
body_output: A Tensor with shape [batch, ?, ?, body_output_size].
targets:
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
a Tensors, each ... | [
"Transform",
"inputs",
"from",
"model",
"space",
"to",
"target",
"space",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L927-L947 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | image_top | def image_top(body_output, targets, model_hparams, vocab_size):
"""Top transformation for images."""
del targets # unused arg
# TODO(lukaszkaiser): is this a universal enough way to get channels?
num_channels = model_hparams.problem.num_channels
with tf.variable_scope("rgb_softmax"):
body_output_shape = ... | python | def image_top(body_output, targets, model_hparams, vocab_size):
"""Top transformation for images."""
del targets # unused arg
# TODO(lukaszkaiser): is this a universal enough way to get channels?
num_channels = model_hparams.problem.num_channels
with tf.variable_scope("rgb_softmax"):
body_output_shape = ... | [
"def",
"image_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
"# unused arg",
"# TODO(lukaszkaiser): is this a universal enough way to get channels?",
"num_channels",
"=",
"model_hparams",
".",
"problem",
".",
... | Top transformation for images. | [
"Top",
"transformation",
"for",
"images",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L955-L972 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | image_channel_compress_top | def image_channel_compress_top(body_output, targets, model_hparams, vocab_size):
"""Transforms body output to return logits.
Args:
body_output: Tensor of shape [batch, img_len, img_len, depth].
targets:
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
... | python | def image_channel_compress_top(body_output, targets, model_hparams, vocab_size):
"""Transforms body output to return logits.
Args:
body_output: Tensor of shape [batch, img_len, img_len, depth].
targets:
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
... | [
"def",
"image_channel_compress_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
"# unused arg",
"with",
"tf",
".",
"variable_scope",
"(",
"\"image_channel_compress_modality\"",
")",
":",
"hidden_size",
"=",... | Transforms body output to return logits.
Args:
body_output: Tensor of shape [batch, img_len, img_len, depth].
targets:
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
Tensor of shape [batch, img_len, img_len, channels, vocab_size]. | [
"Transforms",
"body",
"output",
"to",
"return",
"logits",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L975-L1010 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | image_channel_embeddings_top | def image_channel_embeddings_top(body_output,
targets,
model_hparams,
vocab_size):
"""Top transformation for images."""
del targets # unused arg
with tf.variable_scope("image_channel_embeddings_bottom"):
img_le... | python | def image_channel_embeddings_top(body_output,
targets,
model_hparams,
vocab_size):
"""Top transformation for images."""
del targets # unused arg
with tf.variable_scope("image_channel_embeddings_bottom"):
img_le... | [
"def",
"image_channel_embeddings_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
"# unused arg",
"with",
"tf",
".",
"variable_scope",
"(",
"\"image_channel_embeddings_bottom\"",
")",
":",
"img_len",
"=",
... | Top transformation for images. | [
"Top",
"transformation",
"for",
"images",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1013-L1026 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | softmax_average_pooling_class_label_top | def softmax_average_pooling_class_label_top(body_output,
targets,
model_hparams,
vocab_size):
"""Loss for class label."""
del targets # unused arg
with tf.variable_scope(
"sof... | python | def softmax_average_pooling_class_label_top(body_output,
targets,
model_hparams,
vocab_size):
"""Loss for class label."""
del targets # unused arg
with tf.variable_scope(
"sof... | [
"def",
"softmax_average_pooling_class_label_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
"# unused arg",
"with",
"tf",
".",
"variable_scope",
"(",
"\"softmax_average_pooling_onehot_class_label_modality_%d_%d\""... | Loss for class label. | [
"Loss",
"for",
"class",
"label",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1062-L1073 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | softmax_last_timestep_class_label_top | def softmax_last_timestep_class_label_top(body_output,
targets,
model_hparams,
vocab_size):
"""Loss for class label."""
del targets # unused arg
with tf.variable_scope(
"softmax_las... | python | def softmax_last_timestep_class_label_top(body_output,
targets,
model_hparams,
vocab_size):
"""Loss for class label."""
del targets # unused arg
with tf.variable_scope(
"softmax_las... | [
"def",
"softmax_last_timestep_class_label_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
"# unused arg",
"with",
"tf",
".",
"variable_scope",
"(",
"\"softmax_last_timestep_onehot_class_label_modality_%d_%d\"",
... | Loss for class label. | [
"Loss",
"for",
"class",
"label",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1076-L1087 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | softmax_max_pooling_class_label_top | def softmax_max_pooling_class_label_top(body_output,
targets,
model_hparams,
vocab_size):
"""Loss for class label."""
del targets # unused arg
with tf.variable_scope(
"softmax_max_pooling... | python | def softmax_max_pooling_class_label_top(body_output,
targets,
model_hparams,
vocab_size):
"""Loss for class label."""
del targets # unused arg
with tf.variable_scope(
"softmax_max_pooling... | [
"def",
"softmax_max_pooling_class_label_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
"# unused arg",
"with",
"tf",
".",
"variable_scope",
"(",
"\"softmax_max_pooling_onehot_class_label_modality_%d_%d\"",
"%",... | Loss for class label. | [
"Loss",
"for",
"class",
"label",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1090-L1101 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | symbol_top | def symbol_top(body_output, targets, model_hparams, vocab_size):
"""Generate logits.
Args:
body_output: A Tensor with shape
[batch, p0, p1, model_hparams.hidden_size].
targets: Unused.
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
logits: A Te... | python | def symbol_top(body_output, targets, model_hparams, vocab_size):
"""Generate logits.
Args:
body_output: A Tensor with shape
[batch, p0, p1, model_hparams.hidden_size].
targets: Unused.
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
logits: A Te... | [
"def",
"symbol_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
"# unused arg",
"if",
"model_hparams",
".",
"shared_embedding_and_softmax_weights",
":",
"scope_name",
"=",
"\"shared\"",
"reuse",
"=",
"tf"... | Generate logits.
Args:
body_output: A Tensor with shape
[batch, p0, p1, model_hparams.hidden_size].
targets: Unused.
model_hparams: HParams, model hyperparmeters.
vocab_size: int, vocabulary size.
Returns:
logits: A Tensor with shape [batch, p0, p1, ?, vocab_size]. | [
"Generate",
"logits",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1105-L1137 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | video_top | def video_top(body_output, targets, model_hparams, vocab_size):
"""Top transformation for video."""
del targets # unused arg
num_channels = model_hparams.problem.num_channels
shape = common_layers.shape_list(body_output)
reshape_shape = shape[:-1] + [num_channels, vocab_size]
res = tf.reshape(body_output, ... | python | def video_top(body_output, targets, model_hparams, vocab_size):
"""Top transformation for video."""
del targets # unused arg
num_channels = model_hparams.problem.num_channels
shape = common_layers.shape_list(body_output)
reshape_shape = shape[:-1] + [num_channels, vocab_size]
res = tf.reshape(body_output, ... | [
"def",
"video_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
"# unused arg",
"num_channels",
"=",
"model_hparams",
".",
"problem",
".",
"num_channels",
"shape",
"=",
"common_layers",
".",
"shape_list"... | Top transformation for video. | [
"Top",
"transformation",
"for",
"video",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1146-L1157 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | video_l1_top | def video_l1_top(body_output, targets, model_hparams, vocab_size):
"""Top transformation for video."""
del targets, vocab_size # unused arg
num_channels = model_hparams.problem.num_channels
num_frames = model_hparams.video_num_target_frames
with tf.variable_scope("rgb"):
body_output_shape = common_layers... | python | def video_l1_top(body_output, targets, model_hparams, vocab_size):
"""Top transformation for video."""
del targets, vocab_size # unused arg
num_channels = model_hparams.problem.num_channels
num_frames = model_hparams.video_num_target_frames
with tf.variable_scope("rgb"):
body_output_shape = common_layers... | [
"def",
"video_l1_top",
"(",
"body_output",
",",
"targets",
",",
"model_hparams",
",",
"vocab_size",
")",
":",
"del",
"targets",
",",
"vocab_size",
"# unused arg",
"num_channels",
"=",
"model_hparams",
".",
"problem",
".",
"num_channels",
"num_frames",
"=",
"model_... | Top transformation for video. | [
"Top",
"transformation",
"for",
"video",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1160-L1176 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | get_bottom | def get_bottom(modality_type, value=None):
"""Gets default bottom transformation; if none available, return value."""
if modality_type == ModalityType.AUDIO:
return audio_bottom
elif modality_type == ModalityType.AUDIO_SPECTRAL:
return audio_spectral_bottom
elif modality_type in (ModalityType.CLASS_LABE... | python | def get_bottom(modality_type, value=None):
"""Gets default bottom transformation; if none available, return value."""
if modality_type == ModalityType.AUDIO:
return audio_bottom
elif modality_type == ModalityType.AUDIO_SPECTRAL:
return audio_spectral_bottom
elif modality_type in (ModalityType.CLASS_LABE... | [
"def",
"get_bottom",
"(",
"modality_type",
",",
"value",
"=",
"None",
")",
":",
"if",
"modality_type",
"==",
"ModalityType",
".",
"AUDIO",
":",
"return",
"audio_bottom",
"elif",
"modality_type",
"==",
"ModalityType",
".",
"AUDIO_SPECTRAL",
":",
"return",
"audio_... | Gets default bottom transformation; if none available, return value. | [
"Gets",
"default",
"bottom",
"transformation",
";",
"if",
"none",
"available",
"return",
"value",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1192-L1242 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | get_loss | def get_loss(modality_type, value=None):
"""Gets default loss transformation; if none available, return value."""
if modality_type in (ModalityType.AUDIO,
ModalityType.AUDIO_SPECTRAL,
ModalityType.CLASS_LABEL,
ModalityType.IDENTITY,
... | python | def get_loss(modality_type, value=None):
"""Gets default loss transformation; if none available, return value."""
if modality_type in (ModalityType.AUDIO,
ModalityType.AUDIO_SPECTRAL,
ModalityType.CLASS_LABEL,
ModalityType.IDENTITY,
... | [
"def",
"get_loss",
"(",
"modality_type",
",",
"value",
"=",
"None",
")",
":",
"if",
"modality_type",
"in",
"(",
"ModalityType",
".",
"AUDIO",
",",
"ModalityType",
".",
"AUDIO_SPECTRAL",
",",
"ModalityType",
".",
"CLASS_LABEL",
",",
"ModalityType",
".",
"IDENTI... | Gets default loss transformation; if none available, return value. | [
"Gets",
"default",
"loss",
"transformation",
";",
"if",
"none",
"available",
"return",
"value",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1245-L1296 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | get_name | def get_name(modality_type, value=None):
"""Gets default name for transformations; if none available, return value."""
# For legacy reasons, modalities vary in their naming scheme. Future plans are
# to remove any need for get_name. We do not recommend using it.
if modality_type == ModalityType.AUDIO:
retur... | python | def get_name(modality_type, value=None):
"""Gets default name for transformations; if none available, return value."""
# For legacy reasons, modalities vary in their naming scheme. Future plans are
# to remove any need for get_name. We do not recommend using it.
if modality_type == ModalityType.AUDIO:
retur... | [
"def",
"get_name",
"(",
"modality_type",
",",
"value",
"=",
"None",
")",
":",
"# For legacy reasons, modalities vary in their naming scheme. Future plans are",
"# to remove any need for get_name. We do not recommend using it.",
"if",
"modality_type",
"==",
"ModalityType",
".",
"AUD... | Gets default name for transformations; if none available, return value. | [
"Gets",
"default",
"name",
"for",
"transformations",
";",
"if",
"none",
"available",
"return",
"value",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1299-L1384 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | get_targets_bottom | def get_targets_bottom(modality_type, value=None):
"""Gets default bottom transformation for targets; if none, return value."""
if modality_type == ModalityType.AUDIO:
return make_targets_bottom(audio_bottom)
elif modality_type == ModalityType.AUDIO_SPECTRAL:
return make_targets_bottom(audio_spectral_bott... | python | def get_targets_bottom(modality_type, value=None):
"""Gets default bottom transformation for targets; if none, return value."""
if modality_type == ModalityType.AUDIO:
return make_targets_bottom(audio_bottom)
elif modality_type == ModalityType.AUDIO_SPECTRAL:
return make_targets_bottom(audio_spectral_bott... | [
"def",
"get_targets_bottom",
"(",
"modality_type",
",",
"value",
"=",
"None",
")",
":",
"if",
"modality_type",
"==",
"ModalityType",
".",
"AUDIO",
":",
"return",
"make_targets_bottom",
"(",
"audio_bottom",
")",
"elif",
"modality_type",
"==",
"ModalityType",
".",
... | Gets default bottom transformation for targets; if none, return value. | [
"Gets",
"default",
"bottom",
"transformation",
"for",
"targets",
";",
"if",
"none",
"return",
"value",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1387-L1439 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | get_top | def get_top(modality_type, value=None):
"""Gets default top transformation; if none available, return value."""
if modality_type in (ModalityType.AUDIO,
ModalityType.AUDIO_SPECTRAL,
ModalityType.GENERIC_L2_LOSS,
ModalityType.IDENTITY,
... | python | def get_top(modality_type, value=None):
"""Gets default top transformation; if none available, return value."""
if modality_type in (ModalityType.AUDIO,
ModalityType.AUDIO_SPECTRAL,
ModalityType.GENERIC_L2_LOSS,
ModalityType.IDENTITY,
... | [
"def",
"get_top",
"(",
"modality_type",
",",
"value",
"=",
"None",
")",
":",
"if",
"modality_type",
"in",
"(",
"ModalityType",
".",
"AUDIO",
",",
"ModalityType",
".",
"AUDIO_SPECTRAL",
",",
"ModalityType",
".",
"GENERIC_L2_LOSS",
",",
"ModalityType",
".",
"IDE... | Gets default top transformation; if none available, return value. | [
"Gets",
"default",
"top",
"transformation",
";",
"if",
"none",
"available",
"return",
"value",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1442-L1492 | train |
tensorflow/tensor2tensor | tensor2tensor/layers/modalities.py | get_weights_fn | def get_weights_fn(modality_type, value=None):
"""Gets default weights function; if none available, return value."""
if modality_type in (ModalityType.CTC_SYMBOL,
ModalityType.IDENTITY_SYMBOL,
ModalityType.MULTI_LABEL,
ModalityType.SYMBOL,
... | python | def get_weights_fn(modality_type, value=None):
"""Gets default weights function; if none available, return value."""
if modality_type in (ModalityType.CTC_SYMBOL,
ModalityType.IDENTITY_SYMBOL,
ModalityType.MULTI_LABEL,
ModalityType.SYMBOL,
... | [
"def",
"get_weights_fn",
"(",
"modality_type",
",",
"value",
"=",
"None",
")",
":",
"if",
"modality_type",
"in",
"(",
"ModalityType",
".",
"CTC_SYMBOL",
",",
"ModalityType",
".",
"IDENTITY_SYMBOL",
",",
"ModalityType",
".",
"MULTI_LABEL",
",",
"ModalityType",
".... | Gets default weights function; if none available, return value. | [
"Gets",
"default",
"weights",
"function",
";",
"if",
"none",
"available",
"return",
"value",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/modalities.py#L1495-L1505 | train |
tensorflow/tensor2tensor | tensor2tensor/data_generators/paraphrase_ms_coco.py | create_combination | def create_combination(list_of_sentences):
"""Generates all possible pair combinations for the input list of sentences.
For example:
input = ["paraphrase1", "paraphrase2", "paraphrase3"]
output = [("paraphrase1", "paraphrase2"),
("paraphrase1", "paraphrase3"),
("paraphrase2", "paraphr... | python | def create_combination(list_of_sentences):
"""Generates all possible pair combinations for the input list of sentences.
For example:
input = ["paraphrase1", "paraphrase2", "paraphrase3"]
output = [("paraphrase1", "paraphrase2"),
("paraphrase1", "paraphrase3"),
("paraphrase2", "paraphr... | [
"def",
"create_combination",
"(",
"list_of_sentences",
")",
":",
"num_sentences",
"=",
"len",
"(",
"list_of_sentences",
")",
"-",
"1",
"combinations",
"=",
"[",
"]",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"list_of_sentences",
")",
":",
"if",
"i",
"=... | Generates all possible pair combinations for the input list of sentences.
For example:
input = ["paraphrase1", "paraphrase2", "paraphrase3"]
output = [("paraphrase1", "paraphrase2"),
("paraphrase1", "paraphrase3"),
("paraphrase2", "paraphrase3")]
Args:
list_of_sentences: the list... | [
"Generates",
"all",
"possible",
"pair",
"combinations",
"for",
"the",
"input",
"list",
"of",
"sentences",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/paraphrase_ms_coco.py#L42-L67 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | image_transformer2d_base | def image_transformer2d_base():
"""Set of hyperparameters."""
hparams = common_hparams.basic_params1()
hparams.hidden_size = 512
hparams.batch_size = 1
hparams.max_length = 256
hparams.dropout = 0.0
hparams.clip_grad_norm = 0. # i.e. no gradient clipping
hparams.optimizer_adam_epsilon = 1e-9
hparams.... | python | def image_transformer2d_base():
"""Set of hyperparameters."""
hparams = common_hparams.basic_params1()
hparams.hidden_size = 512
hparams.batch_size = 1
hparams.max_length = 256
hparams.dropout = 0.0
hparams.clip_grad_norm = 0. # i.e. no gradient clipping
hparams.optimizer_adam_epsilon = 1e-9
hparams.... | [
"def",
"image_transformer2d_base",
"(",
")",
":",
"hparams",
"=",
"common_hparams",
".",
"basic_params1",
"(",
")",
"hparams",
".",
"hidden_size",
"=",
"512",
"hparams",
".",
"batch_size",
"=",
"1",
"hparams",
".",
"max_length",
"=",
"256",
"hparams",
".",
"... | Set of hyperparameters. | [
"Set",
"of",
"hyperparameters",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L367-L432 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | imagetransformer2d_base_8l_8_32_big | def imagetransformer2d_base_8l_8_32_big():
"""hparams fo 8 layer big 2d model for cifar 10."""
hparams = image_transformer2d_base()
hparams.num_heads = 16
hparams.hidden_size = 1024
hparams.filter_size = 2048
hparams.num_decoder_layers = 8
hparams.batch_size = 1
hparams.layer_prepostprocess_dropout = 0.... | python | def imagetransformer2d_base_8l_8_32_big():
"""hparams fo 8 layer big 2d model for cifar 10."""
hparams = image_transformer2d_base()
hparams.num_heads = 16
hparams.hidden_size = 1024
hparams.filter_size = 2048
hparams.num_decoder_layers = 8
hparams.batch_size = 1
hparams.layer_prepostprocess_dropout = 0.... | [
"def",
"imagetransformer2d_base_8l_8_32_big",
"(",
")",
":",
"hparams",
"=",
"image_transformer2d_base",
"(",
")",
"hparams",
".",
"num_heads",
"=",
"16",
"hparams",
".",
"hidden_size",
"=",
"1024",
"hparams",
".",
"filter_size",
"=",
"2048",
"hparams",
".",
"nu... | hparams fo 8 layer big 2d model for cifar 10. | [
"hparams",
"fo",
"8",
"layer",
"big",
"2d",
"model",
"for",
"cifar",
"10",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L485-L497 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | imagetransformer_base_10l_8h_big_uncond_dr03_dan_64_2d | def imagetransformer_base_10l_8h_big_uncond_dr03_dan_64_2d():
"""big 1d model for unconditional generation on imagenet."""
hparams = image_transformer2d_base()
hparams.unconditional = True
hparams.hidden_size = 512
hparams.batch_size = 1
hparams.img_len = 64
hparams.num_heads = 8
hparams.filter_size = 2... | python | def imagetransformer_base_10l_8h_big_uncond_dr03_dan_64_2d():
"""big 1d model for unconditional generation on imagenet."""
hparams = image_transformer2d_base()
hparams.unconditional = True
hparams.hidden_size = 512
hparams.batch_size = 1
hparams.img_len = 64
hparams.num_heads = 8
hparams.filter_size = 2... | [
"def",
"imagetransformer_base_10l_8h_big_uncond_dr03_dan_64_2d",
"(",
")",
":",
"hparams",
"=",
"image_transformer2d_base",
"(",
")",
"hparams",
".",
"unconditional",
"=",
"True",
"hparams",
".",
"hidden_size",
"=",
"512",
"hparams",
".",
"batch_size",
"=",
"1",
"hp... | big 1d model for unconditional generation on imagenet. | [
"big",
"1d",
"model",
"for",
"unconditional",
"generation",
"on",
"imagenet",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L501-L519 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer2d_base | def img2img_transformer2d_base():
"""Base params for img2img 2d attention."""
hparams = image_transformer2d_base()
# learning related flags
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
# This version seems to benefit from a higher learning rate.
hparams.learning_rate =... | python | def img2img_transformer2d_base():
"""Base params for img2img 2d attention."""
hparams = image_transformer2d_base()
# learning related flags
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
# This version seems to benefit from a higher learning rate.
hparams.learning_rate =... | [
"def",
"img2img_transformer2d_base",
"(",
")",
":",
"hparams",
"=",
"image_transformer2d_base",
"(",
")",
"# learning related flags",
"hparams",
".",
"layer_preprocess_sequence",
"=",
"\"n\"",
"hparams",
".",
"layer_postprocess_sequence",
"=",
"\"da\"",
"# This version seem... | Base params for img2img 2d attention. | [
"Base",
"params",
"for",
"img2img",
"2d",
"attention",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L585-L601 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer2d_q3 | def img2img_transformer2d_q3():
"""Current best hparams for local 2d."""
hparams = img2img_transformer2d_q1()
hparams.batch_size = 2
hparams.query_shape = (8, 16)
hparams.memory_flange = (8, 32)
return hparams | python | def img2img_transformer2d_q3():
"""Current best hparams for local 2d."""
hparams = img2img_transformer2d_q1()
hparams.batch_size = 2
hparams.query_shape = (8, 16)
hparams.memory_flange = (8, 32)
return hparams | [
"def",
"img2img_transformer2d_q3",
"(",
")",
":",
"hparams",
"=",
"img2img_transformer2d_q1",
"(",
")",
"hparams",
".",
"batch_size",
"=",
"2",
"hparams",
".",
"query_shape",
"=",
"(",
"8",
",",
"16",
")",
"hparams",
".",
"memory_flange",
"=",
"(",
"8",
",... | Current best hparams for local 2d. | [
"Current",
"best",
"hparams",
"for",
"local",
"2d",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L627-L633 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer_base | def img2img_transformer_base():
"""Base params for local1d attention."""
hparams = image_transformer2d_base()
# learning related flags
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
# This version seems to benefit from a higher learning rate.
hparams.learning_rate = 0.2
... | python | def img2img_transformer_base():
"""Base params for local1d attention."""
hparams = image_transformer2d_base()
# learning related flags
hparams.layer_preprocess_sequence = "n"
hparams.layer_postprocess_sequence = "da"
# This version seems to benefit from a higher learning rate.
hparams.learning_rate = 0.2
... | [
"def",
"img2img_transformer_base",
"(",
")",
":",
"hparams",
"=",
"image_transformer2d_base",
"(",
")",
"# learning related flags",
"hparams",
".",
"layer_preprocess_sequence",
"=",
"\"n\"",
"hparams",
".",
"layer_postprocess_sequence",
"=",
"\"da\"",
"# This version seems ... | Base params for local1d attention. | [
"Base",
"params",
"for",
"local1d",
"attention",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L637-L654 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer_b3 | def img2img_transformer_b3():
"""Current best hparams for local 1d."""
hparams = img2img_transformer_base()
hparams.batch_size = 2
hparams.layer_preprocess_sequence = "none"
hparams.layer_postprocess_sequence = "dan"
hparams.block_length = 128
hparams.sampling_temp = 0.9
return hparams | python | def img2img_transformer_b3():
"""Current best hparams for local 1d."""
hparams = img2img_transformer_base()
hparams.batch_size = 2
hparams.layer_preprocess_sequence = "none"
hparams.layer_postprocess_sequence = "dan"
hparams.block_length = 128
hparams.sampling_temp = 0.9
return hparams | [
"def",
"img2img_transformer_b3",
"(",
")",
":",
"hparams",
"=",
"img2img_transformer_base",
"(",
")",
"hparams",
".",
"batch_size",
"=",
"2",
"hparams",
".",
"layer_preprocess_sequence",
"=",
"\"none\"",
"hparams",
".",
"layer_postprocess_sequence",
"=",
"\"dan\"",
... | Current best hparams for local 1d. | [
"Current",
"best",
"hparams",
"for",
"local",
"1d",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L678-L686 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer_dilated | def img2img_transformer_dilated():
"""Try dilated."""
hparams = img2img_transformer_base()
hparams.add_hparam("num_memory_blocks", 1)
hparams.num_heads = 8
hparams.attention_key_channels = hparams.attention_value_channels = 0
hparams.hidden_size = 512
hparams.filter_size = 2048
hparams.num_decoder_layer... | python | def img2img_transformer_dilated():
"""Try dilated."""
hparams = img2img_transformer_base()
hparams.add_hparam("num_memory_blocks", 1)
hparams.num_heads = 8
hparams.attention_key_channels = hparams.attention_value_channels = 0
hparams.hidden_size = 512
hparams.filter_size = 2048
hparams.num_decoder_layer... | [
"def",
"img2img_transformer_dilated",
"(",
")",
":",
"hparams",
"=",
"img2img_transformer_base",
"(",
")",
"hparams",
".",
"add_hparam",
"(",
"\"num_memory_blocks\"",
",",
"1",
")",
"hparams",
".",
"num_heads",
"=",
"8",
"hparams",
".",
"attention_key_channels",
"... | Try dilated. | [
"Try",
"dilated",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L760-L775 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer_base_tpu | def img2img_transformer_base_tpu():
"""Hparams for training img2img_transformer on tpu."""
hparams = img2img_transformer_base()
update_hparams_for_tpu(hparams)
hparams.batch_size = 2
hparams.num_heads = 4 # heads are expensive on tpu
hparams.num_decoder_layers = 8
hparams.num_encoder_layers = 4
hparam... | python | def img2img_transformer_base_tpu():
"""Hparams for training img2img_transformer on tpu."""
hparams = img2img_transformer_base()
update_hparams_for_tpu(hparams)
hparams.batch_size = 2
hparams.num_heads = 4 # heads are expensive on tpu
hparams.num_decoder_layers = 8
hparams.num_encoder_layers = 4
hparam... | [
"def",
"img2img_transformer_base_tpu",
"(",
")",
":",
"hparams",
"=",
"img2img_transformer_base",
"(",
")",
"update_hparams_for_tpu",
"(",
"hparams",
")",
"hparams",
".",
"batch_size",
"=",
"2",
"hparams",
".",
"num_heads",
"=",
"4",
"# heads are expensive on tpu",
... | Hparams for training img2img_transformer on tpu. | [
"Hparams",
"for",
"training",
"img2img_transformer",
"on",
"tpu",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L794-L803 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer2d_n31 | def img2img_transformer2d_n31():
"""Set of hyperparameters."""
hparams = img2img_transformer2d_base()
hparams.batch_size = 1
hparams.num_encoder_layers = 6
hparams.num_decoder_layers = 12
hparams.num_heads = 8
hparams.query_shape = (16, 32)
hparams.memory_flange = (16, 32)
return hparams | python | def img2img_transformer2d_n31():
"""Set of hyperparameters."""
hparams = img2img_transformer2d_base()
hparams.batch_size = 1
hparams.num_encoder_layers = 6
hparams.num_decoder_layers = 12
hparams.num_heads = 8
hparams.query_shape = (16, 32)
hparams.memory_flange = (16, 32)
return hparams | [
"def",
"img2img_transformer2d_n31",
"(",
")",
":",
"hparams",
"=",
"img2img_transformer2d_base",
"(",
")",
"hparams",
".",
"batch_size",
"=",
"1",
"hparams",
".",
"num_encoder_layers",
"=",
"6",
"hparams",
".",
"num_decoder_layers",
"=",
"12",
"hparams",
".",
"n... | Set of hyperparameters. | [
"Set",
"of",
"hyperparameters",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L829-L838 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer2d_n24 | def img2img_transformer2d_n24():
"""Set of hyperparameters."""
hparams = img2img_transformer2d_base()
hparams.batch_size = 1
hparams.hidden_size = 1024
hparams.filter_size = 2048
hparams.layer_prepostprocess_dropout = 0.2
hparams.num_decoder_layers = 8
hparams.query_shape = (8, 16)
hparams.memory_flan... | python | def img2img_transformer2d_n24():
"""Set of hyperparameters."""
hparams = img2img_transformer2d_base()
hparams.batch_size = 1
hparams.hidden_size = 1024
hparams.filter_size = 2048
hparams.layer_prepostprocess_dropout = 0.2
hparams.num_decoder_layers = 8
hparams.query_shape = (8, 16)
hparams.memory_flan... | [
"def",
"img2img_transformer2d_n24",
"(",
")",
":",
"hparams",
"=",
"img2img_transformer2d_base",
"(",
")",
"hparams",
".",
"batch_size",
"=",
"1",
"hparams",
".",
"hidden_size",
"=",
"1024",
"hparams",
".",
"filter_size",
"=",
"2048",
"hparams",
".",
"layer_prep... | Set of hyperparameters. | [
"Set",
"of",
"hyperparameters",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L842-L852 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer2d_tiny | def img2img_transformer2d_tiny():
"""Tiny params."""
hparams = img2img_transformer2d_base()
hparams.num_decoder_layers = 2
hparams.hidden_size = 128
hparams.batch_size = 4
hparams.max_length = 128
hparams.attention_key_channels = hparams.attention_value_channels = 0
hparams.filter_size = 128
hparams.n... | python | def img2img_transformer2d_tiny():
"""Tiny params."""
hparams = img2img_transformer2d_base()
hparams.num_decoder_layers = 2
hparams.hidden_size = 128
hparams.batch_size = 4
hparams.max_length = 128
hparams.attention_key_channels = hparams.attention_value_channels = 0
hparams.filter_size = 128
hparams.n... | [
"def",
"img2img_transformer2d_tiny",
"(",
")",
":",
"hparams",
"=",
"img2img_transformer2d_base",
"(",
")",
"hparams",
".",
"num_decoder_layers",
"=",
"2",
"hparams",
".",
"hidden_size",
"=",
"128",
"hparams",
".",
"batch_size",
"=",
"4",
"hparams",
".",
"max_le... | Tiny params. | [
"Tiny",
"params",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L880-L892 | train |
tensorflow/tensor2tensor | tensor2tensor/models/image_transformer_2d.py | img2img_transformer_tiny | def img2img_transformer_tiny():
"""Tiny params."""
hparams = img2img_transformer2d_base()
hparams.num_hidden_layers = 2
hparams.hidden_size = 128
hparams.batch_size = 4
hparams.max_length = 128
hparams.attention_key_channels = hparams.attention_value_channels = 0
hparams.filter_size = 128
hparams.num_... | python | def img2img_transformer_tiny():
"""Tiny params."""
hparams = img2img_transformer2d_base()
hparams.num_hidden_layers = 2
hparams.hidden_size = 128
hparams.batch_size = 4
hparams.max_length = 128
hparams.attention_key_channels = hparams.attention_value_channels = 0
hparams.filter_size = 128
hparams.num_... | [
"def",
"img2img_transformer_tiny",
"(",
")",
":",
"hparams",
"=",
"img2img_transformer2d_base",
"(",
")",
"hparams",
".",
"num_hidden_layers",
"=",
"2",
"hparams",
".",
"hidden_size",
"=",
"128",
"hparams",
".",
"batch_size",
"=",
"4",
"hparams",
".",
"max_lengt... | Tiny params. | [
"Tiny",
"params",
"."
] | 272500b6efe353aeb638d2745ed56e519462ca31 | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/image_transformer_2d.py#L896-L907 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.