partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
HParams.set_hparam
Set the value of an existing hyperparameter. This function verifies that the type of the value matches the type of the existing hyperparameter. Args: name: Name of the hyperparameter. value: New value of the hyperparameter. Raises: KeyError: If the hyperparameter doesn't exist. ...
tensor2tensor/utils/hparam.py
def set_hparam(self, name, value): """Set the value of an existing hyperparameter. This function verifies that the type of the value matches the type of the existing hyperparameter. Args: name: Name of the hyperparameter. value: New value of the hyperparameter. Raises: KeyError:...
def set_hparam(self, name, value): """Set the value of an existing hyperparameter. This function verifies that the type of the value matches the type of the existing hyperparameter. Args: name: Name of the hyperparameter. value: New value of the hyperparameter. Raises: KeyError:...
[ "Set", "the", "value", "of", "an", "existing", "hyperparameter", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L443-L468
[ "def", "set_hparam", "(", "self", ",", "name", ",", "value", ")", ":", "param_type", ",", "is_list", "=", "self", ".", "_hparam_types", "[", "name", "]", "if", "isinstance", "(", "value", ",", "list", ")", ":", "if", "not", "is_list", ":", "raise", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
HParams.del_hparam
Removes the hyperparameter with key 'name'. Does nothing if it isn't present. Args: name: Name of the hyperparameter.
tensor2tensor/utils/hparam.py
def del_hparam(self, name): """Removes the hyperparameter with key 'name'. Does nothing if it isn't present. Args: name: Name of the hyperparameter. """ if hasattr(self, name): delattr(self, name) del self._hparam_types[name]
def del_hparam(self, name): """Removes the hyperparameter with key 'name'. Does nothing if it isn't present. Args: name: Name of the hyperparameter. """ if hasattr(self, name): delattr(self, name) del self._hparam_types[name]
[ "Removes", "the", "hyperparameter", "with", "key", "name", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L470-L480
[ "def", "del_hparam", "(", "self", ",", "name", ")", ":", "if", "hasattr", "(", "self", ",", "name", ")", ":", "delattr", "(", "self", ",", "name", ")", "del", "self", ".", "_hparam_types", "[", "name", "]" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
HParams.parse
Override existing hyperparameter values, parsing new values from a string. See parse_values for more detail on the allowed format for values. Args: values: String. Comma separated list of `name=value` pairs where 'value' must follow the syntax described above. Returns: The `HParams` ...
tensor2tensor/utils/hparam.py
def parse(self, values): """Override existing hyperparameter values, parsing new values from a string. See parse_values for more detail on the allowed format for values. Args: values: String. Comma separated list of `name=value` pairs where 'value' must follow the syntax described above. ...
def parse(self, values): """Override existing hyperparameter values, parsing new values from a string. See parse_values for more detail on the allowed format for values. Args: values: String. Comma separated list of `name=value` pairs where 'value' must follow the syntax described above. ...
[ "Override", "existing", "hyperparameter", "values", "parsing", "new", "values", "from", "a", "string", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L482-L504
[ "def", "parse", "(", "self", ",", "values", ")", ":", "type_map", "=", "{", "}", "for", "name", ",", "t", "in", "self", ".", "_hparam_types", ".", "items", "(", ")", ":", "param_type", ",", "_", "=", "t", "type_map", "[", "name", "]", "=", "param...
272500b6efe353aeb638d2745ed56e519462ca31
train
HParams.override_from_dict
Override existing hyperparameter values, parsing new values from a dictionary. Args: values_dict: Dictionary of name:value pairs. Returns: The `HParams` instance. Raises: KeyError: If a hyperparameter in `values_dict` doesn't exist. ValueError: If `values_dict` cannot be parsed.
tensor2tensor/utils/hparam.py
def override_from_dict(self, values_dict): """Override existing hyperparameter values, parsing new values from a dictionary. Args: values_dict: Dictionary of name:value pairs. Returns: The `HParams` instance. Raises: KeyError: If a hyperparameter in `values_dict` doesn't exist. ...
def override_from_dict(self, values_dict): """Override existing hyperparameter values, parsing new values from a dictionary. Args: values_dict: Dictionary of name:value pairs. Returns: The `HParams` instance. Raises: KeyError: If a hyperparameter in `values_dict` doesn't exist. ...
[ "Override", "existing", "hyperparameter", "values", "parsing", "new", "values", "from", "a", "dictionary", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L506-L521
[ "def", "override_from_dict", "(", "self", ",", "values_dict", ")", ":", "for", "name", ",", "value", "in", "values_dict", ".", "items", "(", ")", ":", "self", ".", "set_hparam", "(", "name", ",", "value", ")", "return", "self" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
HParams.to_json
Serializes the hyperparameters into JSON. Args: indent: If a non-negative integer, JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0, or negative, will only insert newlines. `None` (the default) selects the most compact represen...
tensor2tensor/utils/hparam.py
def to_json(self, indent=None, separators=None, sort_keys=False): """Serializes the hyperparameters into JSON. Args: indent: If a non-negative integer, JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0, or negative, will only insert...
def to_json(self, indent=None, separators=None, sort_keys=False): """Serializes the hyperparameters into JSON. Args: indent: If a non-negative integer, JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0, or negative, will only insert...
[ "Serializes", "the", "hyperparameters", "into", "JSON", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L529-L556
[ "def", "to_json", "(", "self", ",", "indent", "=", "None", ",", "separators", "=", "None", ",", "sort_keys", "=", "False", ")", ":", "def", "remove_callables", "(", "x", ")", ":", "\"\"\"Omit callable elements from input with arbitrary nesting.\"\"\"", "if", "isin...
272500b6efe353aeb638d2745ed56e519462ca31
train
HParams.parse_json
Override existing hyperparameter values, parsing new values from a json object. Args: values_json: String containing a json object of name:value pairs. Returns: The `HParams` instance. Raises: KeyError: If a hyperparameter in `values_json` doesn't exist. ValueError: If `values_jso...
tensor2tensor/utils/hparam.py
def parse_json(self, values_json): """Override existing hyperparameter values, parsing new values from a json object. Args: values_json: String containing a json object of name:value pairs. Returns: The `HParams` instance. Raises: KeyError: If a hyperparameter in `values_json` doesn...
def parse_json(self, values_json): """Override existing hyperparameter values, parsing new values from a json object. Args: values_json: String containing a json object of name:value pairs. Returns: The `HParams` instance. Raises: KeyError: If a hyperparameter in `values_json` doesn...
[ "Override", "existing", "hyperparameter", "values", "parsing", "new", "values", "from", "a", "json", "object", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L558-L572
[ "def", "parse_json", "(", "self", ",", "values_json", ")", ":", "values_map", "=", "json", ".", "loads", "(", "values_json", ")", "return", "self", ".", "override_from_dict", "(", "values_map", ")" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
HParams.values
Return the hyperparameter values as a Python dictionary. Returns: A dictionary with hyperparameter names as keys. The values are the hyperparameter values.
tensor2tensor/utils/hparam.py
def values(self): """Return the hyperparameter values as a Python dictionary. Returns: A dictionary with hyperparameter names as keys. The values are the hyperparameter values. """ return {n: getattr(self, n) for n in self._hparam_types.keys()}
def values(self): """Return the hyperparameter values as a Python dictionary. Returns: A dictionary with hyperparameter names as keys. The values are the hyperparameter values. """ return {n: getattr(self, n) for n in self._hparam_types.keys()}
[ "Return", "the", "hyperparameter", "values", "as", "a", "Python", "dictionary", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L574-L581
[ "def", "values", "(", "self", ")", ":", "return", "{", "n", ":", "getattr", "(", "self", ",", "n", ")", "for", "n", "in", "self", ".", "_hparam_types", ".", "keys", "(", ")", "}" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
HParams.get
Returns the value of `key` if it exists, else `default`.
tensor2tensor/utils/hparam.py
def get(self, key, default=None): """Returns the value of `key` if it exists, else `default`.""" if key in self._hparam_types: # Ensure that default is compatible with the parameter type. if default is not None: param_type, is_param_list = self._hparam_types[key] type_str = 'list<%s>...
def get(self, key, default=None): """Returns the value of `key` if it exists, else `default`.""" if key in self._hparam_types: # Ensure that default is compatible with the parameter type. if default is not None: param_type, is_param_list = self._hparam_types[key] type_str = 'list<%s>...
[ "Returns", "the", "value", "of", "key", "if", "it", "exists", "else", "default", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L583-L608
[ "def", "get", "(", "self", ",", "key", ",", "default", "=", "None", ")", ":", "if", "key", "in", "self", ".", "_hparam_types", ":", "# Ensure that default is compatible with the parameter type.", "if", "default", "is", "not", "None", ":", "param_type", ",", "i...
272500b6efe353aeb638d2745ed56e519462ca31
train
HParams._get_kind_name
Returns the field name given parameter type and is_list. Args: param_type: Data type of the hparam. is_list: Whether this is a list. Returns: A string representation of the field name. Raises: ValueError: If parameter type is not recognized.
tensor2tensor/utils/hparam.py
def _get_kind_name(param_type, is_list): """Returns the field name given parameter type and is_list. Args: param_type: Data type of the hparam. is_list: Whether this is a list. Returns: A string representation of the field name. Raises: ValueError: If parameter type is not rec...
def _get_kind_name(param_type, is_list): """Returns the field name given parameter type and is_list. Args: param_type: Data type of the hparam. is_list: Whether this is a list. Returns: A string representation of the field name. Raises: ValueError: If parameter type is not rec...
[ "Returns", "the", "field", "name", "given", "parameter", "type", "and", "is_list", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/hparam.py#L620-L651
[ "def", "_get_kind_name", "(", "param_type", ",", "is_list", ")", ":", "if", "issubclass", "(", "param_type", ",", "bool", ")", ":", "# This check must happen before issubclass(param_type, six.integer_types),", "# since Python considers bool to be a subclass of int.", "typename", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
TransformerModel.process
Returns the visualizations for query. Args: query: The query to process. Returns: A dictionary of results with processing and graph visualizations.
tensor2tensor/insights/transformer_model.py
def process(self, query): """Returns the visualizations for query. Args: query: The query to process. Returns: A dictionary of results with processing and graph visualizations. """ tf.logging.info("Processing new query [%s]" %query) # Create the new TFDBG hook directory. hook_...
def process(self, query): """Returns the visualizations for query. Args: query: The query to process. Returns: A dictionary of results with processing and graph visualizations. """ tf.logging.info("Processing new query [%s]" %query) # Create the new TFDBG hook directory. hook_...
[ "Returns", "the", "visualizations", "for", "query", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/insights/transformer_model.py#L141-L301
[ "def", "process", "(", "self", ",", "query", ")", ":", "tf", ".", "logging", ".", "info", "(", "\"Processing new query [%s]\"", "%", "query", ")", "# Create the new TFDBG hook directory.", "hook_dir", "=", "\"/tmp/t2t_server_dump/request_%d\"", "%", "int", "(", "tim...
272500b6efe353aeb638d2745ed56e519462ca31
train
_default_output_dir
Default output directory.
tensor2tensor/trax/trainer.py
def _default_output_dir(): """Default output directory.""" try: dataset_name = gin.query_parameter("inputs.dataset_name") except ValueError: dataset_name = "random" dir_name = "{model_name}_{dataset_name}_{timestamp}".format( model_name=gin.query_parameter("train.model").configurable.name, d...
def _default_output_dir(): """Default output directory.""" try: dataset_name = gin.query_parameter("inputs.dataset_name") except ValueError: dataset_name = "random" dir_name = "{model_name}_{dataset_name}_{timestamp}".format( model_name=gin.query_parameter("train.model").configurable.name, d...
[ "Default", "output", "directory", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/trainer.py#L48-L62
[ "def", "_default_output_dir", "(", ")", ":", "try", ":", "dataset_name", "=", "gin", ".", "query_parameter", "(", "\"inputs.dataset_name\"", ")", "except", "ValueError", ":", "dataset_name", "=", "\"random\"", "dir_name", "=", "\"{model_name}_{dataset_name}_{timestamp}\...
272500b6efe353aeb638d2745ed56e519462ca31
train
_setup_gin
Setup gin configuration.
tensor2tensor/trax/trainer.py
def _setup_gin(): """Setup gin configuration.""" # Imports for configurables # pylint: disable=g-import-not-at-top,unused-import,g-bad-import-order,reimported,unused-variable from tensor2tensor.trax import models as _trax_models from tensor2tensor.trax import optimizers as _trax_opt # pylint: disable=g-impo...
def _setup_gin(): """Setup gin configuration.""" # Imports for configurables # pylint: disable=g-import-not-at-top,unused-import,g-bad-import-order,reimported,unused-variable from tensor2tensor.trax import models as _trax_models from tensor2tensor.trax import optimizers as _trax_opt # pylint: disable=g-impo...
[ "Setup", "gin", "configuration", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/trainer.py#L65-L81
[ "def", "_setup_gin", "(", ")", ":", "# Imports for configurables", "# pylint: disable=g-import-not-at-top,unused-import,g-bad-import-order,reimported,unused-variable", "from", "tensor2tensor", ".", "trax", "import", "models", "as", "_trax_models", "from", "tensor2tensor", ".", "t...
272500b6efe353aeb638d2745ed56e519462ca31
train
train_and_eval_dataset
Return train and evaluation datasets, feature info and supervised keys. Args: dataset_name: a string, the name of the dataset; if it starts with "v1_" then we'll search T2T Problem registry for it, otherwise we assume it is a dataset from TFDS and load it from there. data_dir: directory where the...
tensor2tensor/v2/t2t.py
def train_and_eval_dataset(dataset_name, data_dir): """Return train and evaluation datasets, feature info and supervised keys. Args: dataset_name: a string, the name of the dataset; if it starts with "v1_" then we'll search T2T Problem registry for it, otherwise we assume it is a dataset from TFDS ...
def train_and_eval_dataset(dataset_name, data_dir): """Return train and evaluation datasets, feature info and supervised keys. Args: dataset_name: a string, the name of the dataset; if it starts with "v1_" then we'll search T2T Problem registry for it, otherwise we assume it is a dataset from TFDS ...
[ "Return", "train", "and", "evaluation", "datasets", "feature", "info", "and", "supervised", "keys", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/v2/t2t.py#L48-L83
[ "def", "train_and_eval_dataset", "(", "dataset_name", ",", "data_dir", ")", ":", "if", "dataset_name", ".", "startswith", "(", "\"v1_\"", ")", ":", "return", "_train_and_eval_dataset_v1", "(", "dataset_name", "[", "3", ":", "]", ",", "data_dir", ")", "dataset_bu...
272500b6efe353aeb638d2745ed56e519462ca31
train
_make_info
Create an info-like tuple for feature given some shapes and vocab size.
tensor2tensor/v2/t2t.py
def _make_info(shape_list, num_classes): """Create an info-like tuple for feature given some shapes and vocab size.""" feature_info = collections.namedtuple("FeatureInfo", ["shape", "num_classes"]) cur_shape = list(shape_list[0]) # We need to merge the provided shapes, put None where they disagree. for shape ...
def _make_info(shape_list, num_classes): """Create an info-like tuple for feature given some shapes and vocab size.""" feature_info = collections.namedtuple("FeatureInfo", ["shape", "num_classes"]) cur_shape = list(shape_list[0]) # We need to merge the provided shapes, put None where they disagree. for shape ...
[ "Create", "an", "info", "-", "like", "tuple", "for", "feature", "given", "some", "shapes", "and", "vocab", "size", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/v2/t2t.py#L86-L98
[ "def", "_make_info", "(", "shape_list", ",", "num_classes", ")", ":", "feature_info", "=", "collections", ".", "namedtuple", "(", "\"FeatureInfo\"", ",", "[", "\"shape\"", ",", "\"num_classes\"", "]", ")", "cur_shape", "=", "list", "(", "shape_list", "[", "0",...
272500b6efe353aeb638d2745ed56e519462ca31
train
_select_features
Select a subset of features from the example dict.
tensor2tensor/v2/t2t.py
def _select_features(example, feature_list=None): """Select a subset of features from the example dict.""" feature_list = feature_list or ["inputs", "targets"] return {f: example[f] for f in feature_list}
def _select_features(example, feature_list=None): """Select a subset of features from the example dict.""" feature_list = feature_list or ["inputs", "targets"] return {f: example[f] for f in feature_list}
[ "Select", "a", "subset", "of", "features", "from", "the", "example", "dict", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/v2/t2t.py#L101-L104
[ "def", "_select_features", "(", "example", ",", "feature_list", "=", "None", ")", ":", "feature_list", "=", "feature_list", "or", "[", "\"inputs\"", ",", "\"targets\"", "]", "return", "{", "f", ":", "example", "[", "f", "]", "for", "f", "in", "feature_list...
272500b6efe353aeb638d2745ed56e519462ca31
train
_train_and_eval_dataset_v1
Return train and evaluation datasets, feature info and supervised keys.
tensor2tensor/v2/t2t.py
def _train_and_eval_dataset_v1(problem_name, data_dir): """Return train and evaluation datasets, feature info and supervised keys.""" problem = problems.problem(problem_name) train_dataset = problem.dataset(tf.estimator.ModeKeys.TRAIN, data_dir) train_dataset = train_dataset.map(_select_features) eval_dataset...
def _train_and_eval_dataset_v1(problem_name, data_dir): """Return train and evaluation datasets, feature info and supervised keys.""" problem = problems.problem(problem_name) train_dataset = problem.dataset(tf.estimator.ModeKeys.TRAIN, data_dir) train_dataset = train_dataset.map(_select_features) eval_dataset...
[ "Return", "train", "and", "evaluation", "datasets", "feature", "info", "and", "supervised", "keys", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/v2/t2t.py#L107-L126
[ "def", "_train_and_eval_dataset_v1", "(", "problem_name", ",", "data_dir", ")", ":", "problem", "=", "problems", ".", "problem", "(", "problem_name", ")", "train_dataset", "=", "problem", ".", "dataset", "(", "tf", ".", "estimator", ".", "ModeKeys", ".", "TRAI...
272500b6efe353aeb638d2745ed56e519462ca31
train
batch_fn
Batching function.
tensor2tensor/v2/t2t.py
def batch_fn(dataset, training, shapes, target_names, batch_size=32, eval_batch_size=32, bucket_batch_length=32, bucket_max_length=256, bucket_min_length=8, bucket_length_step=1.1, buckets=None): """Batching function.""" del target_names # If bucketing is not specified, chec...
def batch_fn(dataset, training, shapes, target_names, batch_size=32, eval_batch_size=32, bucket_batch_length=32, bucket_max_length=256, bucket_min_length=8, bucket_length_step=1.1, buckets=None): """Batching function.""" del target_names # If bucketing is not specified, chec...
[ "Batching", "function", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/v2/t2t.py#L140-L174
[ "def", "batch_fn", "(", "dataset", ",", "training", ",", "shapes", ",", "target_names", ",", "batch_size", "=", "32", ",", "eval_batch_size", "=", "32", ",", "bucket_batch_length", "=", "32", ",", "bucket_max_length", "=", "256", ",", "bucket_min_length", "=",...
272500b6efe353aeb638d2745ed56e519462ca31
train
shuffle_and_batch_data
Shuffle and batch the given dataset.
tensor2tensor/v2/t2t.py
def shuffle_and_batch_data(dataset, target_names, features_info, training): """Shuffle and batch the given dataset.""" def append_targets(example): """Append targets to the example dictionary. Needed for Keras.""" if len(target_names) == 1: return (example, example[target_names[0]]) targets = {} ...
def shuffle_and_batch_data(dataset, target_names, features_info, training): """Shuffle and batch the given dataset.""" def append_targets(example): """Append targets to the example dictionary. Needed for Keras.""" if len(target_names) == 1: return (example, example[target_names[0]]) targets = {} ...
[ "Shuffle", "and", "batch", "the", "given", "dataset", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/v2/t2t.py#L177-L195
[ "def", "shuffle_and_batch_data", "(", "dataset", ",", "target_names", ",", "features_info", ",", "training", ")", ":", "def", "append_targets", "(", "example", ")", ":", "\"\"\"Append targets to the example dictionary. Needed for Keras.\"\"\"", "if", "len", "(", "target_n...
272500b6efe353aeb638d2745ed56e519462ca31
train
optimize_fn
Compile the model in Keras.
tensor2tensor/v2/t2t.py
def optimize_fn(model, optimizer=None, learning_rate_schedule=None, loss=None, metrics=None): """Compile the model in Keras.""" learning_rate_schedule = learning_rate_schedule or T2TLearningRateSchedule() if optimizer: optimizer = optimizer(learn...
def optimize_fn(model, optimizer=None, learning_rate_schedule=None, loss=None, metrics=None): """Compile the model in Keras.""" learning_rate_schedule = learning_rate_schedule or T2TLearningRateSchedule() if optimizer: optimizer = optimizer(learn...
[ "Compile", "the", "model", "in", "Keras", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/v2/t2t.py#L233-L253
[ "def", "optimize_fn", "(", "model", ",", "optimizer", "=", "None", ",", "learning_rate_schedule", "=", "None", ",", "loss", "=", "None", ",", "metrics", "=", "None", ")", ":", "learning_rate_schedule", "=", "learning_rate_schedule", "or", "T2TLearningRateSchedule"...
272500b6efe353aeb638d2745ed56e519462ca31
train
train_fn
Train the given model on the given dataset. Args: data_dir: Directory where the data is located. output_dir: Directory where to put the logs and checkpoints. model_class: The model class to train. dataset: The name of the dataset to train on. input_names: List of strings with the names of the fea...
tensor2tensor/v2/t2t.py
def train_fn(data_dir=None, output_dir=None, model_class=gin.REQUIRED, dataset=gin.REQUIRED, input_names=None, target_names=None, train_steps=1000, eval_steps=1, eval_frequency=100): """Train the given model on the given dataset. Args: data_dir: Directory where the data i...
def train_fn(data_dir=None, output_dir=None, model_class=gin.REQUIRED, dataset=gin.REQUIRED, input_names=None, target_names=None, train_steps=1000, eval_steps=1, eval_frequency=100): """Train the given model on the given dataset. Args: data_dir: Directory where the data i...
[ "Train", "the", "given", "model", "on", "the", "given", "dataset", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/v2/t2t.py#L259-L324
[ "def", "train_fn", "(", "data_dir", "=", "None", ",", "output_dir", "=", "None", ",", "model_class", "=", "gin", ".", "REQUIRED", ",", "dataset", "=", "gin", ".", "REQUIRED", ",", "input_names", "=", "None", ",", "target_names", "=", "None", ",", "train_...
272500b6efe353aeb638d2745ed56e519462ca31
train
t2t_train
Main function to train the given model on the given dataset. Args: model_name: The name of the model to train. dataset_name: The name of the dataset to train on. data_dir: Directory where the data is located. output_dir: Directory where to put the logs and checkpoints. config_file: the gin config...
tensor2tensor/v2/t2t.py
def t2t_train(model_name, dataset_name, data_dir=None, output_dir=None, config_file=None, config=None): """Main function to train the given model on the given dataset. Args: model_name: The name of the model to train. dataset_name: The name of the dataset to train on. data_dir: Directory ...
def t2t_train(model_name, dataset_name, data_dir=None, output_dir=None, config_file=None, config=None): """Main function to train the given model on the given dataset. Args: model_name: The name of the model to train. dataset_name: The name of the dataset to train on. data_dir: Directory ...
[ "Main", "function", "to", "train", "the", "given", "model", "on", "the", "given", "dataset", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/v2/t2t.py#L327-L347
[ "def", "t2t_train", "(", "model_name", ",", "dataset_name", ",", "data_dir", "=", "None", ",", "output_dir", "=", "None", ",", "config_file", "=", "None", ",", "config", "=", "None", ")", ":", "if", "model_name", "not", "in", "_MODEL_REGISTRY", ":", "raise...
272500b6efe353aeb638d2745ed56e519462ca31
train
decode
Decode from estimator. Interactive, from file, or from dataset.
tensor2tensor/bin/t2t_decoder.py
def decode(estimator, hparams, decode_hp): """Decode from estimator. Interactive, from file, or from dataset.""" if FLAGS.decode_interactive: if estimator.config.use_tpu: raise ValueError("TPU can only decode from dataset.") decoding.decode_interactively(estimator, hparams, decode_hp, ...
def decode(estimator, hparams, decode_hp): """Decode from estimator. Interactive, from file, or from dataset.""" if FLAGS.decode_interactive: if estimator.config.use_tpu: raise ValueError("TPU can only decode from dataset.") decoding.decode_interactively(estimator, hparams, decode_hp, ...
[ "Decode", "from", "estimator", ".", "Interactive", "from", "file", "or", "from", "dataset", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/bin/t2t_decoder.py#L82-L104
[ "def", "decode", "(", "estimator", ",", "hparams", ",", "decode_hp", ")", ":", "if", "FLAGS", ".", "decode_interactive", ":", "if", "estimator", ".", "config", ".", "use_tpu", ":", "raise", "ValueError", "(", "\"TPU can only decode from dataset.\"", ")", "decodi...
272500b6efe353aeb638d2745ed56e519462ca31
train
score_file
Score each line in a file and return the scores.
tensor2tensor/bin/t2t_decoder.py
def score_file(filename): """Score each line in a file and return the scores.""" # Prepare model. hparams = create_hparams() encoders = registry.problem(FLAGS.problem).feature_encoders(FLAGS.data_dir) has_inputs = "inputs" in encoders # Prepare features for feeding into the model. if has_inputs: inpu...
def score_file(filename): """Score each line in a file and return the scores.""" # Prepare model. hparams = create_hparams() encoders = registry.problem(FLAGS.problem).feature_encoders(FLAGS.data_dir) has_inputs = "inputs" in encoders # Prepare features for feeding into the model. if has_inputs: inpu...
[ "Score", "each", "line", "in", "a", "file", "and", "return", "the", "scores", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/bin/t2t_decoder.py#L107-L164
[ "def", "score_file", "(", "filename", ")", ":", "# Prepare model.", "hparams", "=", "create_hparams", "(", ")", "encoders", "=", "registry", ".", "problem", "(", "FLAGS", ".", "problem", ")", ".", "feature_encoders", "(", "FLAGS", ".", "data_dir", ")", "has_...
272500b6efe353aeb638d2745ed56e519462ca31
train
time_to_channels
Put time dimension on channels in an embedded video.
tensor2tensor/models/research/autoencoders.py
def time_to_channels(embedded_video): """Put time dimension on channels in an embedded video.""" video_shape = common_layers.shape_list(embedded_video) if len(video_shape) != 5: raise ValueError("Assuming videos given as tensors in the format " "[batch, time, height, width, channels] but ...
def time_to_channels(embedded_video): """Put time dimension on channels in an embedded video.""" video_shape = common_layers.shape_list(embedded_video) if len(video_shape) != 5: raise ValueError("Assuming videos given as tensors in the format " "[batch, time, height, width, channels] but ...
[ "Put", "time", "dimension", "on", "channels", "in", "an", "embedded", "video", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L38-L49
[ "def", "time_to_channels", "(", "embedded_video", ")", ":", "video_shape", "=", "common_layers", ".", "shape_list", "(", "embedded_video", ")", "if", "len", "(", "video_shape", ")", "!=", "5", ":", "raise", "ValueError", "(", "\"Assuming videos given as tensors in t...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_basic
Basic autoencoder model.
tensor2tensor/models/research/autoencoders.py
def autoencoder_basic(): """Basic autoencoder model.""" hparams = common_hparams.basic_params1() hparams.optimizer = "adam" hparams.learning_rate_constant = 0.0002 hparams.learning_rate_warmup_steps = 500 hparams.learning_rate_schedule = "constant * linear_warmup" hparams.label_smoothing = 0.0 hparams.b...
def autoencoder_basic(): """Basic autoencoder model.""" hparams = common_hparams.basic_params1() hparams.optimizer = "adam" hparams.learning_rate_constant = 0.0002 hparams.learning_rate_warmup_steps = 500 hparams.learning_rate_schedule = "constant * linear_warmup" hparams.label_smoothing = 0.0 hparams.b...
[ "Basic", "autoencoder", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1027-L1069
[ "def", "autoencoder_basic", "(", ")", ":", "hparams", "=", "common_hparams", ".", "basic_params1", "(", ")", "hparams", ".", "optimizer", "=", "\"adam\"", "hparams", ".", "learning_rate_constant", "=", "0.0002", "hparams", ".", "learning_rate_warmup_steps", "=", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_autoregressive
Autoregressive autoencoder model.
tensor2tensor/models/research/autoencoders.py
def autoencoder_autoregressive(): """Autoregressive autoencoder model.""" hparams = autoencoder_basic() hparams.add_hparam("autoregressive_forget_base", False) hparams.add_hparam("autoregressive_mode", "none") hparams.add_hparam("autoregressive_decode_steps", 0) hparams.add_hparam("autoregressive_eval_pure_...
def autoencoder_autoregressive(): """Autoregressive autoencoder model.""" hparams = autoencoder_basic() hparams.add_hparam("autoregressive_forget_base", False) hparams.add_hparam("autoregressive_mode", "none") hparams.add_hparam("autoregressive_decode_steps", 0) hparams.add_hparam("autoregressive_eval_pure_...
[ "Autoregressive", "autoencoder", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1073-L1081
[ "def", "autoencoder_autoregressive", "(", ")", ":", "hparams", "=", "autoencoder_basic", "(", ")", "hparams", ".", "add_hparam", "(", "\"autoregressive_forget_base\"", ",", "False", ")", "hparams", ".", "add_hparam", "(", "\"autoregressive_mode\"", ",", "\"none\"", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_residual
Residual autoencoder model.
tensor2tensor/models/research/autoencoders.py
def autoencoder_residual(): """Residual autoencoder model.""" hparams = autoencoder_autoregressive() hparams.optimizer = "Adafactor" hparams.clip_grad_norm = 1.0 hparams.learning_rate_constant = 0.5 hparams.learning_rate_warmup_steps = 500 hparams.learning_rate_schedule = "constant * linear_warmup * rsqrt...
def autoencoder_residual(): """Residual autoencoder model.""" hparams = autoencoder_autoregressive() hparams.optimizer = "Adafactor" hparams.clip_grad_norm = 1.0 hparams.learning_rate_constant = 0.5 hparams.learning_rate_warmup_steps = 500 hparams.learning_rate_schedule = "constant * linear_warmup * rsqrt...
[ "Residual", "autoencoder", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1085-L1103
[ "def", "autoencoder_residual", "(", ")", ":", "hparams", "=", "autoencoder_autoregressive", "(", ")", "hparams", ".", "optimizer", "=", "\"Adafactor\"", "hparams", ".", "clip_grad_norm", "=", "1.0", "hparams", ".", "learning_rate_constant", "=", "0.5", "hparams", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_residual_text
Residual autoencoder model for text.
tensor2tensor/models/research/autoencoders.py
def autoencoder_residual_text(): """Residual autoencoder model for text.""" hparams = autoencoder_residual() hparams.bottleneck_bits = 32 hparams.batch_size = 1024 hparams.hidden_size = 64 hparams.max_hidden_size = 512 hparams.bottleneck_noise = 0.0 hparams.bottom = { "inputs": modalities.identity...
def autoencoder_residual_text(): """Residual autoencoder model for text.""" hparams = autoencoder_residual() hparams.bottleneck_bits = 32 hparams.batch_size = 1024 hparams.hidden_size = 64 hparams.max_hidden_size = 512 hparams.bottleneck_noise = 0.0 hparams.bottom = { "inputs": modalities.identity...
[ "Residual", "autoencoder", "model", "for", "text", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1107-L1124
[ "def", "autoencoder_residual_text", "(", ")", ":", "hparams", "=", "autoencoder_residual", "(", ")", "hparams", ".", "bottleneck_bits", "=", "32", "hparams", ".", "batch_size", "=", "1024", "hparams", ".", "hidden_size", "=", "64", "hparams", ".", "max_hidden_si...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_basic_discrete
Basic autoencoder model.
tensor2tensor/models/research/autoencoders.py
def autoencoder_basic_discrete(): """Basic autoencoder model.""" hparams = autoencoder_autoregressive() hparams.num_hidden_layers = 5 hparams.hidden_size = 64 hparams.bottleneck_bits = 1024 hparams.bottleneck_noise = 0.1 hparams.add_hparam("discretize_warmup_steps", 16000) return hparams
def autoencoder_basic_discrete(): """Basic autoencoder model.""" hparams = autoencoder_autoregressive() hparams.num_hidden_layers = 5 hparams.hidden_size = 64 hparams.bottleneck_bits = 1024 hparams.bottleneck_noise = 0.1 hparams.add_hparam("discretize_warmup_steps", 16000) return hparams
[ "Basic", "autoencoder", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1128-L1136
[ "def", "autoencoder_basic_discrete", "(", ")", ":", "hparams", "=", "autoencoder_autoregressive", "(", ")", "hparams", ".", "num_hidden_layers", "=", "5", "hparams", ".", "hidden_size", "=", "64", "hparams", ".", "bottleneck_bits", "=", "1024", "hparams", ".", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_residual_discrete
Residual discrete autoencoder model.
tensor2tensor/models/research/autoencoders.py
def autoencoder_residual_discrete(): """Residual discrete autoencoder model.""" hparams = autoencoder_residual() hparams.bottleneck_bits = 1024 hparams.bottleneck_noise = 0.05 hparams.add_hparam("discretize_warmup_steps", 16000) hparams.add_hparam("bottleneck_kind", "tanh_discrete") hparams.add_hparam("is...
def autoencoder_residual_discrete(): """Residual discrete autoencoder model.""" hparams = autoencoder_residual() hparams.bottleneck_bits = 1024 hparams.bottleneck_noise = 0.05 hparams.add_hparam("discretize_warmup_steps", 16000) hparams.add_hparam("bottleneck_kind", "tanh_discrete") hparams.add_hparam("is...
[ "Residual", "discrete", "autoencoder", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1140-L1153
[ "def", "autoencoder_residual_discrete", "(", ")", ":", "hparams", "=", "autoencoder_residual", "(", ")", "hparams", ".", "bottleneck_bits", "=", "1024", "hparams", ".", "bottleneck_noise", "=", "0.05", "hparams", ".", "add_hparam", "(", "\"discretize_warmup_steps\"", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_residual_discrete_big
Residual discrete autoencoder model, big version.
tensor2tensor/models/research/autoencoders.py
def autoencoder_residual_discrete_big(): """Residual discrete autoencoder model, big version.""" hparams = autoencoder_residual_discrete() hparams.hidden_size = 128 hparams.max_hidden_size = 4096 hparams.bottleneck_noise = 0.1 hparams.residual_dropout = 0.4 return hparams
def autoencoder_residual_discrete_big(): """Residual discrete autoencoder model, big version.""" hparams = autoencoder_residual_discrete() hparams.hidden_size = 128 hparams.max_hidden_size = 4096 hparams.bottleneck_noise = 0.1 hparams.residual_dropout = 0.4 return hparams
[ "Residual", "discrete", "autoencoder", "model", "big", "version", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1157-L1164
[ "def", "autoencoder_residual_discrete_big", "(", ")", ":", "hparams", "=", "autoencoder_residual_discrete", "(", ")", "hparams", ".", "hidden_size", "=", "128", "hparams", ".", "max_hidden_size", "=", "4096", "hparams", ".", "bottleneck_noise", "=", "0.1", "hparams"...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_ordered_discrete
Ordered discrete autoencoder model.
tensor2tensor/models/research/autoencoders.py
def autoencoder_ordered_discrete(): """Ordered discrete autoencoder model.""" hparams = autoencoder_residual_discrete() hparams.bottleneck_noise = 0.05 # Use 0.8 for ordered. hparams.gan_loss_factor = 0.05 hparams.add_hparam("unordered", True) return hparams
def autoencoder_ordered_discrete(): """Ordered discrete autoencoder model.""" hparams = autoencoder_residual_discrete() hparams.bottleneck_noise = 0.05 # Use 0.8 for ordered. hparams.gan_loss_factor = 0.05 hparams.add_hparam("unordered", True) return hparams
[ "Ordered", "discrete", "autoencoder", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1168-L1174
[ "def", "autoencoder_ordered_discrete", "(", ")", ":", "hparams", "=", "autoencoder_residual_discrete", "(", ")", "hparams", ".", "bottleneck_noise", "=", "0.05", "# Use 0.8 for ordered.", "hparams", ".", "gan_loss_factor", "=", "0.05", "hparams", ".", "add_hparam", "(...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_ordered_discrete_image64
Ordered discrete autoencoder model.
tensor2tensor/models/research/autoencoders.py
def autoencoder_ordered_discrete_image64(): """Ordered discrete autoencoder model.""" hparams = autoencoder_ordered_discrete() hparams.batch_size = 32 hparams.num_hidden_layers = 6 hparams.bottleneck_warmup_steps *= 2 hparams.gan_codes_warmup_steps *= 2 return hparams
def autoencoder_ordered_discrete_image64(): """Ordered discrete autoencoder model.""" hparams = autoencoder_ordered_discrete() hparams.batch_size = 32 hparams.num_hidden_layers = 6 hparams.bottleneck_warmup_steps *= 2 hparams.gan_codes_warmup_steps *= 2 return hparams
[ "Ordered", "discrete", "autoencoder", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1178-L1186
[ "def", "autoencoder_ordered_discrete_image64", "(", ")", ":", "hparams", "=", "autoencoder_ordered_discrete", "(", ")", "hparams", ".", "batch_size", "=", "32", "hparams", ".", "num_hidden_layers", "=", "6", "hparams", ".", "bottleneck_warmup_steps", "*=", "2", "hpa...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_ordered_text
Ordered discrete autoencoder model for text.
tensor2tensor/models/research/autoencoders.py
def autoencoder_ordered_text(): """Ordered discrete autoencoder model for text.""" hparams = autoencoder_ordered_discrete() hparams.bottleneck_bits = 1024 hparams.bottleneck_shared_bits = 1024-64 hparams.bottleneck_shared_bits_start_warmup = 75000 hparams.bottleneck_shared_bits_stop_warmup = 275000 hparam...
def autoencoder_ordered_text(): """Ordered discrete autoencoder model for text.""" hparams = autoencoder_ordered_discrete() hparams.bottleneck_bits = 1024 hparams.bottleneck_shared_bits = 1024-64 hparams.bottleneck_shared_bits_start_warmup = 75000 hparams.bottleneck_shared_bits_stop_warmup = 275000 hparam...
[ "Ordered", "discrete", "autoencoder", "model", "for", "text", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1214-L1234
[ "def", "autoencoder_ordered_text", "(", ")", ":", "hparams", "=", "autoencoder_ordered_discrete", "(", ")", "hparams", ".", "bottleneck_bits", "=", "1024", "hparams", ".", "bottleneck_shared_bits", "=", "1024", "-", "64", "hparams", ".", "bottleneck_shared_bits_start_...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_ordered_text_small
Ordered discrete autoencoder model for text, small version.
tensor2tensor/models/research/autoencoders.py
def autoencoder_ordered_text_small(): """Ordered discrete autoencoder model for text, small version.""" hparams = autoencoder_ordered_text() hparams.bottleneck_bits = 32 hparams.num_hidden_layers = 3 hparams.hidden_size = 64 hparams.max_hidden_size = 512 hparams.bottleneck_noise = 0.0 hparams.autoregres...
def autoencoder_ordered_text_small(): """Ordered discrete autoencoder model for text, small version.""" hparams = autoencoder_ordered_text() hparams.bottleneck_bits = 32 hparams.num_hidden_layers = 3 hparams.hidden_size = 64 hparams.max_hidden_size = 512 hparams.bottleneck_noise = 0.0 hparams.autoregres...
[ "Ordered", "discrete", "autoencoder", "model", "for", "text", "small", "version", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1238-L1248
[ "def", "autoencoder_ordered_text_small", "(", ")", ":", "hparams", "=", "autoencoder_ordered_text", "(", ")", "hparams", ".", "bottleneck_bits", "=", "32", "hparams", ".", "num_hidden_layers", "=", "3", "hparams", ".", "hidden_size", "=", "64", "hparams", ".", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_discrete_pong
Discrete autoencoder model for compressing pong frames.
tensor2tensor/models/research/autoencoders.py
def autoencoder_discrete_pong(): """Discrete autoencoder model for compressing pong frames.""" hparams = autoencoder_ordered_discrete() hparams.num_hidden_layers = 3 hparams.bottleneck_bits = 24 hparams.batch_size = 2 hparams.gan_loss_factor = 0.01 hparams.bottleneck_l2_factor = 0.001 hparams.add_hparam...
def autoencoder_discrete_pong(): """Discrete autoencoder model for compressing pong frames.""" hparams = autoencoder_ordered_discrete() hparams.num_hidden_layers = 3 hparams.bottleneck_bits = 24 hparams.batch_size = 2 hparams.gan_loss_factor = 0.01 hparams.bottleneck_l2_factor = 0.001 hparams.add_hparam...
[ "Discrete", "autoencoder", "model", "for", "compressing", "pong", "frames", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1261-L1270
[ "def", "autoencoder_discrete_pong", "(", ")", ":", "hparams", "=", "autoencoder_ordered_discrete", "(", ")", "hparams", ".", "num_hidden_layers", "=", "3", "hparams", ".", "bottleneck_bits", "=", "24", "hparams", ".", "batch_size", "=", "2", "hparams", ".", "gan...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_discrete_tiny
Discrete autoencoder model for compressing pong frames for testing.
tensor2tensor/models/research/autoencoders.py
def autoencoder_discrete_tiny(): """Discrete autoencoder model for compressing pong frames for testing.""" hparams = autoencoder_ordered_discrete() hparams.num_hidden_layers = 2 hparams.bottleneck_bits = 24 hparams.batch_size = 2 hparams.gan_loss_factor = 0. hparams.bottleneck_l2_factor = 0.001 hparams....
def autoencoder_discrete_tiny(): """Discrete autoencoder model for compressing pong frames for testing.""" hparams = autoencoder_ordered_discrete() hparams.num_hidden_layers = 2 hparams.bottleneck_bits = 24 hparams.batch_size = 2 hparams.gan_loss_factor = 0. hparams.bottleneck_l2_factor = 0.001 hparams....
[ "Discrete", "autoencoder", "model", "for", "compressing", "pong", "frames", "for", "testing", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1274-L1286
[ "def", "autoencoder_discrete_tiny", "(", ")", ":", "hparams", "=", "autoencoder_ordered_discrete", "(", ")", "hparams", ".", "num_hidden_layers", "=", "2", "hparams", ".", "bottleneck_bits", "=", "24", "hparams", ".", "batch_size", "=", "2", "hparams", ".", "gan...
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_discrete_cifar
Discrete autoencoder model for compressing cifar.
tensor2tensor/models/research/autoencoders.py
def autoencoder_discrete_cifar(): """Discrete autoencoder model for compressing cifar.""" hparams = autoencoder_ordered_discrete() hparams.bottleneck_noise = 0.0 hparams.bottleneck_bits = 90 hparams.num_hidden_layers = 2 hparams.hidden_size = 256 hparams.num_residual_layers = 4 hparams.batch_size = 32 ...
def autoencoder_discrete_cifar(): """Discrete autoencoder model for compressing cifar.""" hparams = autoencoder_ordered_discrete() hparams.bottleneck_noise = 0.0 hparams.bottleneck_bits = 90 hparams.num_hidden_layers = 2 hparams.hidden_size = 256 hparams.num_residual_layers = 4 hparams.batch_size = 32 ...
[ "Discrete", "autoencoder", "model", "for", "compressing", "cifar", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1290-L1300
[ "def", "autoencoder_discrete_cifar", "(", ")", ":", "hparams", "=", "autoencoder_ordered_discrete", "(", ")", "hparams", ".", "bottleneck_noise", "=", "0.0", "hparams", ".", "bottleneck_bits", "=", "90", "hparams", ".", "num_hidden_layers", "=", "2", "hparams", "....
272500b6efe353aeb638d2745ed56e519462ca31
train
autoencoder_range
Tuning grid of the main autoencoder params.
tensor2tensor/models/research/autoencoders.py
def autoencoder_range(rhp): """Tuning grid of the main autoencoder params.""" rhp.set_float("dropout", 0.01, 0.3) rhp.set_float("gan_loss_factor", 0.01, 0.1) rhp.set_float("bottleneck_l2_factor", 0.001, 0.1, scale=rhp.LOG_SCALE) rhp.set_discrete("bottleneck_warmup_steps", [200, 2000]) rhp.set_float("gumbel_...
def autoencoder_range(rhp): """Tuning grid of the main autoencoder params.""" rhp.set_float("dropout", 0.01, 0.3) rhp.set_float("gan_loss_factor", 0.01, 0.1) rhp.set_float("bottleneck_l2_factor", 0.001, 0.1, scale=rhp.LOG_SCALE) rhp.set_discrete("bottleneck_warmup_steps", [200, 2000]) rhp.set_float("gumbel_...
[ "Tuning", "grid", "of", "the", "main", "autoencoder", "params", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/autoencoders.py#L1304-L1311
[ "def", "autoencoder_range", "(", "rhp", ")", ":", "rhp", ".", "set_float", "(", "\"dropout\"", ",", "0.01", ",", "0.3", ")", "rhp", ".", "set_float", "(", "\"gan_loss_factor\"", ",", "0.01", ",", "0.1", ")", "rhp", ".", "set_float", "(", "\"bottleneck_l2_f...
272500b6efe353aeb638d2745ed56e519462ca31
train
image_encoder
A stack of self attention layers.
tensor2tensor/models/research/vqa_attention.py
def image_encoder(image_feat, hparams, name="image_encoder", save_weights_to=None, make_image_summary=True): """A stack of self attention layers.""" x = image_feat with tf.variable_scope(name): for layer in range(hparams.num_encoder_laye...
def image_encoder(image_feat, hparams, name="image_encoder", save_weights_to=None, make_image_summary=True): """A stack of self attention layers.""" x = image_feat with tf.variable_scope(name): for layer in range(hparams.num_encoder_laye...
[ "A", "stack", "of", "self", "attention", "layers", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_attention.py#L182-L232
[ "def", "image_encoder", "(", "image_feat", ",", "hparams", ",", "name", "=", "\"image_encoder\"", ",", "save_weights_to", "=", "None", ",", "make_image_summary", "=", "True", ")", ":", "x", "=", "image_feat", "with", "tf", ".", "variable_scope", "(", "name", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
question_encoder
Question encoder, run LSTM encoder and get the last output as encoding.
tensor2tensor/models/research/vqa_attention.py
def question_encoder(question, hparams, name="encoder"): """Question encoder, run LSTM encoder and get the last output as encoding.""" with tf.variable_scope(name, "encoder", values=[question]): question = common_layers.flatten4d3d(question) padding = common_attention.embedding_to_padding(question) leng...
def question_encoder(question, hparams, name="encoder"): """Question encoder, run LSTM encoder and get the last output as encoding.""" with tf.variable_scope(name, "encoder", values=[question]): question = common_layers.flatten4d3d(question) padding = common_attention.embedding_to_padding(question) leng...
[ "Question", "encoder", "run", "LSTM", "encoder", "and", "get", "the", "last", "output", "as", "encoding", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_attention.py#L245-L295
[ "def", "question_encoder", "(", "question", ",", "hparams", ",", "name", "=", "\"encoder\"", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "\"encoder\"", ",", "values", "=", "[", "question", "]", ")", ":", "question", "=", "common_layers...
272500b6efe353aeb638d2745ed56e519462ca31
train
attn
Attention on image feature with question as query.
tensor2tensor/models/research/vqa_attention.py
def attn(image_feat, query, hparams, name="attn"): """Attention on image feature with question as query.""" with tf.variable_scope(name, "attn", values=[image_feat, query]): attn_dim = hparams.attn_dim num_glimps = hparams.num_glimps num_channels = common_layers.shape_list(image_feat)[-1] if len(com...
def attn(image_feat, query, hparams, name="attn"): """Attention on image feature with question as query.""" with tf.variable_scope(name, "attn", values=[image_feat, query]): attn_dim = hparams.attn_dim num_glimps = hparams.num_glimps num_channels = common_layers.shape_list(image_feat)[-1] if len(com...
[ "Attention", "on", "image", "feature", "with", "question", "as", "query", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_attention.py#L298-L318
[ "def", "attn", "(", "image_feat", ",", "query", ",", "hparams", ",", "name", "=", "\"attn\"", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "\"attn\"", ",", "values", "=", "[", "image_feat", ",", "query", "]", ")", ":", "attn_dim", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
mlp
Multi layer perceptron with dropout and relu activation.
tensor2tensor/models/research/vqa_attention.py
def mlp(feature, hparams, name="mlp"): """Multi layer perceptron with dropout and relu activation.""" with tf.variable_scope(name, "mlp", values=[feature]): num_mlp_layers = hparams.num_mlp_layers mlp_dim = hparams.mlp_dim for _ in range(num_mlp_layers): feature = common_layers.dense(feature, mlp_...
def mlp(feature, hparams, name="mlp"): """Multi layer perceptron with dropout and relu activation.""" with tf.variable_scope(name, "mlp", values=[feature]): num_mlp_layers = hparams.num_mlp_layers mlp_dim = hparams.mlp_dim for _ in range(num_mlp_layers): feature = common_layers.dense(feature, mlp_...
[ "Multi", "layer", "perceptron", "with", "dropout", "and", "relu", "activation", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_attention.py#L321-L329
[ "def", "mlp", "(", "feature", ",", "hparams", ",", "name", "=", "\"mlp\"", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "\"mlp\"", ",", "values", "=", "[", "feature", "]", ")", ":", "num_mlp_layers", "=", "hparams", ".", "num_mlp_la...
272500b6efe353aeb638d2745ed56e519462ca31
train
vqa_attention_base
VQA attention baseline hparams.
tensor2tensor/models/research/vqa_attention.py
def vqa_attention_base(): """VQA attention baseline hparams.""" hparams = common_hparams.basic_params1() hparams.batch_size = 128 hparams.use_fixed_batch_size = True, hparams.optimizer = "adam" hparams.optimizer_adam_beta1 = 0.9 hparams.optimizer_adam_beta2 = 0.999 hparams.optimizer_adam_epsilon = 1e-8 ...
def vqa_attention_base(): """VQA attention baseline hparams.""" hparams = common_hparams.basic_params1() hparams.batch_size = 128 hparams.use_fixed_batch_size = True, hparams.optimizer = "adam" hparams.optimizer_adam_beta1 = 0.9 hparams.optimizer_adam_beta2 = 0.999 hparams.optimizer_adam_epsilon = 1e-8 ...
[ "VQA", "attention", "baseline", "hparams", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_attention.py#L333-L400
[ "def", "vqa_attention_base", "(", ")", ":", "hparams", "=", "common_hparams", ".", "basic_params1", "(", ")", "hparams", ".", "batch_size", "=", "128", "hparams", ".", "use_fixed_batch_size", "=", "True", ",", "hparams", ".", "optimizer", "=", "\"adam\"", "hpa...
272500b6efe353aeb638d2745ed56e519462ca31
train
vqa_attention_base_range
Small range of hyperparameters.
tensor2tensor/models/research/vqa_attention.py
def vqa_attention_base_range(rhp): """Small range of hyperparameters.""" # After starting from base, set intervals for some parameters. rhp.set_float("learning_rate", 0.1, 1.0, scale=rhp.LOG_SCALE) rhp.set_float("clip_grad_norm", 0.1, 10, scale=rhp.LOG_SCALE) rhp.set_discrete("batch_size", [128, 256, 512, 102...
def vqa_attention_base_range(rhp): """Small range of hyperparameters.""" # After starting from base, set intervals for some parameters. rhp.set_float("learning_rate", 0.1, 1.0, scale=rhp.LOG_SCALE) rhp.set_float("clip_grad_norm", 0.1, 10, scale=rhp.LOG_SCALE) rhp.set_discrete("batch_size", [128, 256, 512, 102...
[ "Small", "range", "of", "hyperparameters", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/vqa_attention.py#L580-L587
[ "def", "vqa_attention_base_range", "(", "rhp", ")", ":", "# After starting from base, set intervals for some parameters.", "rhp", ".", "set_float", "(", "\"learning_rate\"", ",", "0.1", ",", "1.0", ",", "scale", "=", "rhp", ".", "LOG_SCALE", ")", "rhp", ".", "set_fl...
272500b6efe353aeb638d2745ed56e519462ca31
train
History.append
Append (step, value) pair to history for the given mode and metric.
tensor2tensor/trax/history.py
def append(self, mode, metric, step, value): """Append (step, value) pair to history for the given mode and metric.""" if mode not in self._values: self._values[mode] = collections.defaultdict(list) self._values[mode][metric].append((step, value))
def append(self, mode, metric, step, value): """Append (step, value) pair to history for the given mode and metric.""" if mode not in self._values: self._values[mode] = collections.defaultdict(list) self._values[mode][metric].append((step, value))
[ "Append", "(", "step", "value", ")", "pair", "to", "history", "for", "the", "given", "mode", "and", "metric", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/history.py#L52-L56
[ "def", "append", "(", "self", ",", "mode", ",", "metric", ",", "step", ",", "value", ")", ":", "if", "mode", "not", "in", "self", ".", "_values", ":", "self", ".", "_values", "[", "mode", "]", "=", "collections", ".", "defaultdict", "(", "list", ")...
272500b6efe353aeb638d2745ed56e519462ca31
train
History.get
Get the history for the given metric and mode.
tensor2tensor/trax/history.py
def get(self, mode, metric): """Get the history for the given metric and mode.""" if mode not in self._values: logging.info("Metric %s not found for mode %s", metric, mode) return [] return list(self._values[mode][metric])
def get(self, mode, metric): """Get the history for the given metric and mode.""" if mode not in self._values: logging.info("Metric %s not found for mode %s", metric, mode) return [] return list(self._values[mode][metric])
[ "Get", "the", "history", "for", "the", "given", "metric", "and", "mode", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/history.py#L58-L63
[ "def", "get", "(", "self", ",", "mode", ",", "metric", ")", ":", "if", "mode", "not", "in", "self", ".", "_values", ":", "logging", ".", "info", "(", "\"Metric %s not found for mode %s\"", ",", "metric", ",", "mode", ")", "return", "[", "]", "return", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
History.metrics_for_mode
Metrics available for a given mode.
tensor2tensor/trax/history.py
def metrics_for_mode(self, mode): """Metrics available for a given mode.""" if mode not in self._values: logging.info("Mode %s not found", mode) return [] return sorted(list(self._values[mode].keys()))
def metrics_for_mode(self, mode): """Metrics available for a given mode.""" if mode not in self._values: logging.info("Mode %s not found", mode) return [] return sorted(list(self._values[mode].keys()))
[ "Metrics", "available", "for", "a", "given", "mode", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/history.py#L70-L75
[ "def", "metrics_for_mode", "(", "self", ",", "mode", ")", ":", "if", "mode", "not", "in", "self", ".", "_values", ":", "logging", ".", "info", "(", "\"Mode %s not found\"", ",", "mode", ")", "return", "[", "]", "return", "sorted", "(", "list", "(", "se...
272500b6efe353aeb638d2745ed56e519462ca31
train
batch_norm_relu
Performs a batch normalization followed by a ReLU. Args: inputs: `Tensor` of shape `[batch, channels, ...]`. is_training: `bool` for whether the model is training. relu: `bool` if False, omits the ReLU operation. init_zero: `bool` if True, initializes scale parameter of batch normalization wi...
tensor2tensor/models/resnet.py
def batch_norm_relu(inputs, is_training, relu=True, init_zero=False, data_format="channels_first"): """Performs a batch normalization followed by a ReLU. Args: inputs: `Tensor` of shape `[batch, channels, ...]`. is_training: `b...
def batch_norm_relu(inputs, is_training, relu=True, init_zero=False, data_format="channels_first"): """Performs a batch normalization followed by a ReLU. Args: inputs: `Tensor` of shape `[batch, channels, ...]`. is_training: `b...
[ "Performs", "a", "batch", "normalization", "followed", "by", "a", "ReLU", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L41-L81
[ "def", "batch_norm_relu", "(", "inputs", ",", "is_training", ",", "relu", "=", "True", ",", "init_zero", "=", "False", ",", "data_format", "=", "\"channels_first\"", ")", ":", "if", "init_zero", ":", "gamma_initializer", "=", "tf", ".", "zeros_initializer", "(...
272500b6efe353aeb638d2745ed56e519462ca31
train
conv2d_fixed_padding
Strided 2-D convolution with explicit padding. The padding is consistent and is based only on `kernel_size`, not on the dimensions of `inputs` (as opposed to using `tf.layers.conv2d` alone). Args: inputs: `Tensor` of size `[batch, channels, height_in, width_in]`. filters: `int` number of filters in the ...
tensor2tensor/models/resnet.py
def conv2d_fixed_padding(inputs, filters, kernel_size, strides, data_format="channels_first", use_td=False, targeting_rate=None, keep_prob=None, ...
def conv2d_fixed_padding(inputs, filters, kernel_size, strides, data_format="channels_first", use_td=False, targeting_rate=None, keep_prob=None, ...
[ "Strided", "2", "-", "D", "convolution", "with", "explicit", "padding", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L112-L188
[ "def", "conv2d_fixed_padding", "(", "inputs", ",", "filters", ",", "kernel_size", ",", "strides", ",", "data_format", "=", "\"channels_first\"", ",", "use_td", "=", "False", ",", "targeting_rate", "=", "None", ",", "keep_prob", "=", "None", ",", "is_training", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
residual_block
Standard building block for residual networks with BN before convolutions. Args: inputs: `Tensor` of size `[batch, channels, height, width]`. filters: `int` number of filters for the first two convolutions. Note that the third and final convolution will use 4 times as many filters. is_training: `...
tensor2tensor/models/resnet.py
def residual_block(inputs, filters, is_training, projection_shortcut, strides, final_block, data_format="channels_first", use_td=False, targeting_rate=None, ...
def residual_block(inputs, filters, is_training, projection_shortcut, strides, final_block, data_format="channels_first", use_td=False, targeting_rate=None, ...
[ "Standard", "building", "block", "for", "residual", "networks", "with", "BN", "before", "convolutions", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L191-L257
[ "def", "residual_block", "(", "inputs", ",", "filters", ",", "is_training", ",", "projection_shortcut", ",", "strides", ",", "final_block", ",", "data_format", "=", "\"channels_first\"", ",", "use_td", "=", "False", ",", "targeting_rate", "=", "None", ",", "keep...
272500b6efe353aeb638d2745ed56e519462ca31
train
bottleneck_block
Bottleneck block variant for residual networks with BN after convolutions. Args: inputs: `Tensor` of size `[batch, channels, height, width]`. filters: `int` number of filters for the first two convolutions. Note that the third and final convolution will use 4 times as many filters. is_training: `...
tensor2tensor/models/resnet.py
def bottleneck_block(inputs, filters, is_training, projection_shortcut, strides, final_block, data_format="channels_first", use_td=False, targeting_rate...
def bottleneck_block(inputs, filters, is_training, projection_shortcut, strides, final_block, data_format="channels_first", use_td=False, targeting_rate...
[ "Bottleneck", "block", "variant", "for", "residual", "networks", "with", "BN", "after", "convolutions", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L260-L345
[ "def", "bottleneck_block", "(", "inputs", ",", "filters", ",", "is_training", ",", "projection_shortcut", ",", "strides", ",", "final_block", ",", "data_format", "=", "\"channels_first\"", ",", "use_td", "=", "False", ",", "targeting_rate", "=", "None", ",", "ke...
272500b6efe353aeb638d2745ed56e519462ca31
train
block_layer
Creates one layer of blocks for the ResNet model. Args: inputs: `Tensor` of size `[batch, channels, height, width]`. filters: `int` number of filters for the first convolution of the layer. block_fn: `function` for the block to use within the model blocks: `int` number of blocks contained in the laye...
tensor2tensor/models/resnet.py
def block_layer(inputs, filters, block_fn, blocks, strides, is_training, name, data_format="channels_first", use_td=False, targeting_rate=None, keep_prob=None):...
def block_layer(inputs, filters, block_fn, blocks, strides, is_training, name, data_format="channels_first", use_td=False, targeting_rate=None, keep_prob=None):...
[ "Creates", "one", "layer", "of", "blocks", "for", "the", "ResNet", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L348-L424
[ "def", "block_layer", "(", "inputs", ",", "filters", ",", "block_fn", ",", "blocks", ",", "strides", ",", "is_training", ",", "name", ",", "data_format", "=", "\"channels_first\"", ",", "use_td", "=", "False", ",", "targeting_rate", "=", "None", ",", "keep_p...
272500b6efe353aeb638d2745ed56e519462ca31
train
resnet_v2
Resnet model. Args: inputs: `Tensor` images. block_fn: `function` for the block to use within the model. Either `residual_block` or `bottleneck_block`. layer_blocks: list of 3 or 4 `int`s denoting the number of blocks to include in each of the 3 or 4 block groups. Each group consists of blo...
tensor2tensor/models/resnet.py
def resnet_v2(inputs, block_fn, layer_blocks, filters, data_format="channels_first", is_training=False, is_cifar=False, use_td=False, targeting_rate=None, keep_prob=None): """Resnet model. ...
def resnet_v2(inputs, block_fn, layer_blocks, filters, data_format="channels_first", is_training=False, is_cifar=False, use_td=False, targeting_rate=None, keep_prob=None): """Resnet model. ...
[ "Resnet", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L427-L511
[ "def", "resnet_v2", "(", "inputs", ",", "block_fn", ",", "layer_blocks", ",", "filters", ",", "data_format", "=", "\"channels_first\"", ",", "is_training", "=", "False", ",", "is_cifar", "=", "False", ",", "use_td", "=", "False", ",", "targeting_rate", "=", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
resnet_imagenet_34_td_weight_05_05
Set of hyperparameters.
tensor2tensor/models/resnet.py
def resnet_imagenet_34_td_weight_05_05(): """Set of hyperparameters.""" hp = resnet_imagenet_34() hp.use_td = "weight" hp.targeting_rate = 0.5 hp.keep_prob = 0.5 return hp
def resnet_imagenet_34_td_weight_05_05(): """Set of hyperparameters.""" hp = resnet_imagenet_34() hp.use_td = "weight" hp.targeting_rate = 0.5 hp.keep_prob = 0.5 return hp
[ "Set", "of", "hyperparameters", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L679-L686
[ "def", "resnet_imagenet_34_td_weight_05_05", "(", ")", ":", "hp", "=", "resnet_imagenet_34", "(", ")", "hp", ".", "use_td", "=", "\"weight\"", "hp", ".", "targeting_rate", "=", "0.5", "hp", ".", "keep_prob", "=", "0.5", "return", "hp" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
resnet_imagenet_34_td_unit_05_05
Set of hyperparameters.
tensor2tensor/models/resnet.py
def resnet_imagenet_34_td_unit_05_05(): """Set of hyperparameters.""" hp = resnet_imagenet_34() hp.use_td = "unit" hp.targeting_rate = 0.5 hp.keep_prob = 0.5 return hp
def resnet_imagenet_34_td_unit_05_05(): """Set of hyperparameters.""" hp = resnet_imagenet_34() hp.use_td = "unit" hp.targeting_rate = 0.5 hp.keep_prob = 0.5 return hp
[ "Set", "of", "hyperparameters", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L690-L697
[ "def", "resnet_imagenet_34_td_unit_05_05", "(", ")", ":", "hp", "=", "resnet_imagenet_34", "(", ")", "hp", ".", "use_td", "=", "\"unit\"", "hp", ".", "targeting_rate", "=", "0.5", "hp", ".", "keep_prob", "=", "0.5", "return", "hp" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
resnet_imagenet_34_td_unit_no_drop
Set of hyperparameters.
tensor2tensor/models/resnet.py
def resnet_imagenet_34_td_unit_no_drop(): """Set of hyperparameters.""" hp = resnet_imagenet_34() hp.use_td = "unit" hp.targeting_rate = 0.0 hp.keep_prob = 1.0 return hp
def resnet_imagenet_34_td_unit_no_drop(): """Set of hyperparameters.""" hp = resnet_imagenet_34() hp.use_td = "unit" hp.targeting_rate = 0.0 hp.keep_prob = 1.0 return hp
[ "Set", "of", "hyperparameters", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L701-L708
[ "def", "resnet_imagenet_34_td_unit_no_drop", "(", ")", ":", "hp", "=", "resnet_imagenet_34", "(", ")", "hp", ".", "use_td", "=", "\"unit\"", "hp", ".", "targeting_rate", "=", "0.0", "hp", ".", "keep_prob", "=", "1.0", "return", "hp" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
resnet_cifar_15
Set of hyperparameters.
tensor2tensor/models/resnet.py
def resnet_cifar_15(): """Set of hyperparameters.""" hp = resnet_base() hp.block_fn = "residual" hp.is_cifar = True hp.layer_sizes = [2, 2, 2] hp.filter_sizes = [16, 32, 64, 128] return hp
def resnet_cifar_15(): """Set of hyperparameters.""" hp = resnet_base() hp.block_fn = "residual" hp.is_cifar = True hp.layer_sizes = [2, 2, 2] hp.filter_sizes = [16, 32, 64, 128] return hp
[ "Set", "of", "hyperparameters", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/resnet.py#L719-L727
[ "def", "resnet_cifar_15", "(", ")", ":", "hp", "=", "resnet_base", "(", ")", "hp", ".", "block_fn", "=", "\"residual\"", "hp", ".", "is_cifar", "=", "True", "hp", ".", "layer_sizes", "=", "[", "2", ",", "2", ",", "2", "]", "hp", ".", "filter_sizes", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
_len_lcs
Returns the length of the Longest Common Subsequence between two seqs. Source: http://www.algorithmist.com/index.php/Longest_Common_Subsequence Args: x: sequence of words y: sequence of words Returns integer: Length of LCS between x and y
tensor2tensor/utils/rouge.py
def _len_lcs(x, y): """Returns the length of the Longest Common Subsequence between two seqs. Source: http://www.algorithmist.com/index.php/Longest_Common_Subsequence Args: x: sequence of words y: sequence of words Returns integer: Length of LCS between x and y """ table = _lcs(x, y) n, m =...
def _len_lcs(x, y): """Returns the length of the Longest Common Subsequence between two seqs. Source: http://www.algorithmist.com/index.php/Longest_Common_Subsequence Args: x: sequence of words y: sequence of words Returns integer: Length of LCS between x and y """ table = _lcs(x, y) n, m =...
[ "Returns", "the", "length", "of", "the", "Longest", "Common", "Subsequence", "between", "two", "seqs", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/rouge.py#L33-L47
[ "def", "_len_lcs", "(", "x", ",", "y", ")", ":", "table", "=", "_lcs", "(", "x", ",", "y", ")", "n", ",", "m", "=", "len", "(", "x", ")", ",", "len", "(", "y", ")", "return", "table", "[", "n", ",", "m", "]" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
_lcs
Computes the length of the LCS between two seqs. The implementation below uses a DP programming algorithm and runs in O(nm) time where n = len(x) and m = len(y). Source: http://www.algorithmist.com/index.php/Longest_Common_Subsequence Args: x: collection of words y: collection of words Returns: ...
tensor2tensor/utils/rouge.py
def _lcs(x, y): """Computes the length of the LCS between two seqs. The implementation below uses a DP programming algorithm and runs in O(nm) time where n = len(x) and m = len(y). Source: http://www.algorithmist.com/index.php/Longest_Common_Subsequence Args: x: collection of words y: collection of ...
def _lcs(x, y): """Computes the length of the LCS between two seqs. The implementation below uses a DP programming algorithm and runs in O(nm) time where n = len(x) and m = len(y). Source: http://www.algorithmist.com/index.php/Longest_Common_Subsequence Args: x: collection of words y: collection of ...
[ "Computes", "the", "length", "of", "the", "LCS", "between", "two", "seqs", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/rouge.py#L50-L74
[ "def", "_lcs", "(", "x", ",", "y", ")", ":", "n", ",", "m", "=", "len", "(", "x", ")", ",", "len", "(", "y", ")", "table", "=", "{", "}", "for", "i", "in", "range", "(", "n", "+", "1", ")", ":", "for", "j", "in", "range", "(", "m", "+...
272500b6efe353aeb638d2745ed56e519462ca31
train
rouge_l_sentence_level
Computes ROUGE-L (sentence level) of two collections of sentences. Source: https://www.microsoft.com/en-us/research/publication/ rouge-a-package-for-automatic-evaluation-of-summaries/ Calculated according to: R_lcs = LCS(X,Y)/m P_lcs = LCS(X,Y)/n F_lcs = ((1 + beta^2)*R_lcs*P_lcs) / (R_lcs + (beta^2) * P_...
tensor2tensor/utils/rouge.py
def rouge_l_sentence_level(eval_sentences, ref_sentences): """Computes ROUGE-L (sentence level) of two collections of sentences. Source: https://www.microsoft.com/en-us/research/publication/ rouge-a-package-for-automatic-evaluation-of-summaries/ Calculated according to: R_lcs = LCS(X,Y)/m P_lcs = LCS(X,Y)...
def rouge_l_sentence_level(eval_sentences, ref_sentences): """Computes ROUGE-L (sentence level) of two collections of sentences. Source: https://www.microsoft.com/en-us/research/publication/ rouge-a-package-for-automatic-evaluation-of-summaries/ Calculated according to: R_lcs = LCS(X,Y)/m P_lcs = LCS(X,Y)...
[ "Computes", "ROUGE", "-", "L", "(", "sentence", "level", ")", "of", "two", "collections", "of", "sentences", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/rouge.py#L100-L131
[ "def", "rouge_l_sentence_level", "(", "eval_sentences", ",", "ref_sentences", ")", ":", "f1_scores", "=", "[", "]", "for", "eval_sentence", ",", "ref_sentence", "in", "zip", "(", "eval_sentences", ",", "ref_sentences", ")", ":", "m", "=", "len", "(", "ref_sent...
272500b6efe353aeb638d2745ed56e519462ca31
train
rouge_l_fscore
ROUGE scores computation between labels and predictions. This is an approximate ROUGE scoring method since we do not glue word pieces or decode the ids and tokenize the output. Args: predictions: tensor, model predictions labels: tensor, gold output. Returns: rouge_l_fscore: approx rouge-l f1 sco...
tensor2tensor/utils/rouge.py
def rouge_l_fscore(predictions, labels, **unused_kwargs): """ROUGE scores computation between labels and predictions. This is an approximate ROUGE scoring method since we do not glue word pieces or decode the ids and tokenize the output. Args: predictions: tensor, model predictions labels: tensor, gol...
def rouge_l_fscore(predictions, labels, **unused_kwargs): """ROUGE scores computation between labels and predictions. This is an approximate ROUGE scoring method since we do not glue word pieces or decode the ids and tokenize the output. Args: predictions: tensor, model predictions labels: tensor, gol...
[ "ROUGE", "scores", "computation", "between", "labels", "and", "predictions", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/rouge.py#L134-L153
[ "def", "rouge_l_fscore", "(", "predictions", ",", "labels", ",", "*", "*", "unused_kwargs", ")", ":", "outputs", "=", "tf", ".", "to_int32", "(", "tf", ".", "argmax", "(", "predictions", ",", "axis", "=", "-", "1", ")", ")", "# Convert the outputs and labe...
272500b6efe353aeb638d2745ed56e519462ca31
train
_get_ngrams
Calculates n-grams. Args: n: which n-grams to calculate text: An array of tokens Returns: A set of n-grams
tensor2tensor/utils/rouge.py
def _get_ngrams(n, text): """Calculates n-grams. Args: n: which n-grams to calculate text: An array of tokens Returns: A set of n-grams """ ngram_set = set() text_length = len(text) max_index_ngram_start = text_length - n for i in range(max_index_ngram_start + 1): ngram_set.add(tuple(t...
def _get_ngrams(n, text): """Calculates n-grams. Args: n: which n-grams to calculate text: An array of tokens Returns: A set of n-grams """ ngram_set = set() text_length = len(text) max_index_ngram_start = text_length - n for i in range(max_index_ngram_start + 1): ngram_set.add(tuple(t...
[ "Calculates", "n", "-", "grams", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/rouge.py#L156-L171
[ "def", "_get_ngrams", "(", "n", ",", "text", ")", ":", "ngram_set", "=", "set", "(", ")", "text_length", "=", "len", "(", "text", ")", "max_index_ngram_start", "=", "text_length", "-", "n", "for", "i", "in", "range", "(", "max_index_ngram_start", "+", "1...
272500b6efe353aeb638d2745ed56e519462ca31
train
rouge_2_fscore
ROUGE-2 F1 score computation between labels and predictions. This is an approximate ROUGE scoring method since we do not glue word pieces or decode the ids and tokenize the output. Args: predictions: tensor, model predictions labels: tensor, gold output. Returns: rouge2_fscore: approx rouge-2 f1 ...
tensor2tensor/utils/rouge.py
def rouge_2_fscore(predictions, labels, **unused_kwargs): """ROUGE-2 F1 score computation between labels and predictions. This is an approximate ROUGE scoring method since we do not glue word pieces or decode the ids and tokenize the output. Args: predictions: tensor, model predictions labels: tensor,...
def rouge_2_fscore(predictions, labels, **unused_kwargs): """ROUGE-2 F1 score computation between labels and predictions. This is an approximate ROUGE scoring method since we do not glue word pieces or decode the ids and tokenize the output. Args: predictions: tensor, model predictions labels: tensor,...
[ "ROUGE", "-", "2", "F1", "score", "computation", "between", "labels", "and", "predictions", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/rouge.py#L217-L236
[ "def", "rouge_2_fscore", "(", "predictions", ",", "labels", ",", "*", "*", "unused_kwargs", ")", ":", "outputs", "=", "tf", ".", "to_int32", "(", "tf", ".", "argmax", "(", "predictions", ",", "axis", "=", "-", "1", ")", ")", "# Convert the outputs and labe...
272500b6efe353aeb638d2745ed56e519462ca31
train
normalize_example_nlp
Normalize the examples from different tasks so they can be merged. This function is specific to NLP tasks and normalizes them so that in the end the example only has "targets" and "task_id". For tasks that originally have inputs, this is done by appending task_id to the inputs and prepending targets, so normal...
tensor2tensor/data_generators/multi_problem.py
def normalize_example_nlp(task, example, is_infer, vocab_type, vocab_offset, max_input_length, max_target_length, fixed_train_length): """Normalize the examples from different tasks so they can be merged. This function is specific to NLP tasks and normalizes them...
def normalize_example_nlp(task, example, is_infer, vocab_type, vocab_offset, max_input_length, max_target_length, fixed_train_length): """Normalize the examples from different tasks so they can be merged. This function is specific to NLP tasks and normalizes them...
[ "Normalize", "the", "examples", "from", "different", "tasks", "so", "they", "can", "be", "merged", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem.py#L38-L108
[ "def", "normalize_example_nlp", "(", "task", ",", "example", ",", "is_infer", ",", "vocab_type", ",", "vocab_offset", ",", "max_input_length", ",", "max_target_length", ",", "fixed_train_length", ")", ":", "if", "task", ".", "has_inputs", ":", "example", "[", "\...
272500b6efe353aeb638d2745ed56e519462ca31
train
flatten_zip_dataset
A list of examples to a dataset containing mixed examples. Given a list of `n` dataset examples, flatten them by converting each element into a dataset and concatenating them to convert into a single dataset. Args: *args: A list containing one example each from `n` different datasets. Returns: flat...
tensor2tensor/data_generators/multi_problem.py
def flatten_zip_dataset(*args): """A list of examples to a dataset containing mixed examples. Given a list of `n` dataset examples, flatten them by converting each element into a dataset and concatenating them to convert into a single dataset. Args: *args: A list containing one example each from `n` dif...
def flatten_zip_dataset(*args): """A list of examples to a dataset containing mixed examples. Given a list of `n` dataset examples, flatten them by converting each element into a dataset and concatenating them to convert into a single dataset. Args: *args: A list containing one example each from `n` dif...
[ "A", "list", "of", "examples", "to", "a", "dataset", "containing", "mixed", "examples", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem.py#L111-L128
[ "def", "flatten_zip_dataset", "(", "*", "args", ")", ":", "flattened", "=", "tf", ".", "data", ".", "Dataset", ".", "from_tensors", "(", "args", "[", "0", "]", ")", "for", "ex", "in", "args", "[", "1", ":", "]", ":", "flattened", "=", "flattened", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
aggregate_task_losses
Multiproblem loss function.
tensor2tensor/data_generators/multi_problem.py
def aggregate_task_losses(hparams, problem_hparams, logits, feature_name, feature): """Multiproblem loss function.""" # If no reweighting, we want the default loss to mimic the LM loss. if not hparams.multipro...
def aggregate_task_losses(hparams, problem_hparams, logits, feature_name, feature): """Multiproblem loss function.""" # If no reweighting, we want the default loss to mimic the LM loss. if not hparams.multipro...
[ "Multiproblem", "loss", "function", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem.py#L419-L522
[ "def", "aggregate_task_losses", "(", "hparams", ",", "problem_hparams", ",", "logits", ",", "feature_name", ",", "feature", ")", ":", "# If no reweighting, we want the default loss to mimic the LM loss.", "if", "not", "hparams", ".", "multiproblem_reweight_label_loss", ":", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
aggregate_task_lm_losses
LM loss for multiproblems.
tensor2tensor/data_generators/multi_problem.py
def aggregate_task_lm_losses(hparams, problem_hparams, logits, feature_name, feature): """LM loss for multiproblems.""" summaries = [] vocab_size = problem_hparams.vocab_size[feature_name] if voca...
def aggregate_task_lm_losses(hparams, problem_hparams, logits, feature_name, feature): """LM loss for multiproblems.""" summaries = [] vocab_size = problem_hparams.vocab_size[feature_name] if voca...
[ "LM", "loss", "for", "multiproblems", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem.py#L525-L553
[ "def", "aggregate_task_lm_losses", "(", "hparams", ",", "problem_hparams", ",", "logits", ",", "feature_name", ",", "feature", ")", ":", "summaries", "=", "[", "]", "vocab_size", "=", "problem_hparams", ".", "vocab_size", "[", "feature_name", "]", "if", "vocab_s...
272500b6efe353aeb638d2745ed56e519462ca31
train
MultiProblem.normalize_example
Normalize the examples from different tasks so they can be merged.
tensor2tensor/data_generators/multi_problem.py
def normalize_example(self, task, example, encoder, hparams, is_infer): """Normalize the examples from different tasks so they can be merged.""" # Here we use the default function for NLP tasks that makes everything # a part of "targets" feature. Override in your subclasses for other uses. vocab_offset ...
def normalize_example(self, task, example, encoder, hparams, is_infer): """Normalize the examples from different tasks so they can be merged.""" # Here we use the default function for NLP tasks that makes everything # a part of "targets" feature. Override in your subclasses for other uses. vocab_offset ...
[ "Normalize", "the", "examples", "from", "different", "tasks", "so", "they", "can", "be", "merged", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem.py#L145-L154
[ "def", "normalize_example", "(", "self", ",", "task", ",", "example", ",", "encoder", ",", "hparams", ",", "is_infer", ")", ":", "# Here we use the default function for NLP tasks that makes everything", "# a part of \"targets\" feature. Override in your subclasses for other uses.",...
272500b6efe353aeb638d2745ed56e519462ca31
train
MultiProblem.update_task_ids
Generate task_ids for each problem. These ids correspond to the index of the task in the task_list. Args: encoder_vocab_size: the size of the vocab which is used to compute the index offset.
tensor2tensor/data_generators/multi_problem.py
def update_task_ids(self, encoder_vocab_size): """Generate task_ids for each problem. These ids correspond to the index of the task in the task_list. Args: encoder_vocab_size: the size of the vocab which is used to compute the index offset. """ for idx, task in enumerate(self.task_li...
def update_task_ids(self, encoder_vocab_size): """Generate task_ids for each problem. These ids correspond to the index of the task in the task_list. Args: encoder_vocab_size: the size of the vocab which is used to compute the index offset. """ for idx, task in enumerate(self.task_li...
[ "Generate", "task_ids", "for", "each", "problem", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem.py#L385-L397
[ "def", "update_task_ids", "(", "self", ",", "encoder_vocab_size", ")", ":", "for", "idx", ",", "task", "in", "enumerate", "(", "self", ".", "task_list", ")", ":", "task", ".", "set_task_id", "(", "idx", "+", "encoder_vocab_size", ")", "tf", ".", "logging",...
272500b6efe353aeb638d2745ed56e519462ca31
train
MultiProblem.get_max_num_classes
Compute the maximum number of classes any subtask has. This is useful for modifying the size of the softmax to include the output labels for the classification tasks. Currently, labels from different tasks are overloaded. Returns: num: Highest number of output classes in any text classification ...
tensor2tensor/data_generators/multi_problem.py
def get_max_num_classes(self): """Compute the maximum number of classes any subtask has. This is useful for modifying the size of the softmax to include the output labels for the classification tasks. Currently, labels from different tasks are overloaded. Returns: num: Highest number of outp...
def get_max_num_classes(self): """Compute the maximum number of classes any subtask has. This is useful for modifying the size of the softmax to include the output labels for the classification tasks. Currently, labels from different tasks are overloaded. Returns: num: Highest number of outp...
[ "Compute", "the", "maximum", "number", "of", "classes", "any", "subtask", "has", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem.py#L399-L416
[ "def", "get_max_num_classes", "(", "self", ")", ":", "num", "=", "0", "for", "task", "in", "self", ".", "task_list", ":", "if", "hasattr", "(", "task", ",", "\"num_classes\"", ")", ":", "if", "num", "<", "task", ".", "num_classes", ":", "num", "=", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
RecurrentMemory.pre_attention
Called prior to self-attention, to incorporate memory items. Args: segment: an integer Tensor with shape [batch] query_antecedent: a Tensor with shape [batch, length_q, channels] memory_antecedent: must be None. Attention normally allows this to be a Tensor with shape [batch, length_m, ch...
tensor2tensor/layers/transformer_memory.py
def pre_attention(self, segment, query_antecedent, memory_antecedent, bias): """Called prior to self-attention, to incorporate memory items. Args: segment: an integer Tensor with shape [batch] query_antecedent: a Tensor with shape [batch, length_q, channels] memory_antecedent: must be None. A...
def pre_attention(self, segment, query_antecedent, memory_antecedent, bias): """Called prior to self-attention, to incorporate memory items. Args: segment: an integer Tensor with shape [batch] query_antecedent: a Tensor with shape [batch, length_q, channels] memory_antecedent: must be None. A...
[ "Called", "prior", "to", "self", "-", "attention", "to", "incorporate", "memory", "items", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L31-L45
[ "def", "pre_attention", "(", "self", ",", "segment", ",", "query_antecedent", ",", "memory_antecedent", ",", "bias", ")", ":", "del", "segment", "return", "None", ",", "query_antecedent", ",", "memory_antecedent", ",", "bias" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
RecentTokensMemory.pre_attention
Called prior to self-attention, to incorporate memory items. Args: segment: an integer Tensor with shape [batch] query_antecedent: a Tensor with shape [batch, length_q, channels] memory_antecedent: must be None. Attention normally allows this to be a Tensor with shape [batch, length_m, ch...
tensor2tensor/layers/transformer_memory.py
def pre_attention(self, segment, query_antecedent, memory_antecedent, bias): """Called prior to self-attention, to incorporate memory items. Args: segment: an integer Tensor with shape [batch] query_antecedent: a Tensor with shape [batch, length_q, channels] memory_antecedent: must be None. A...
def pre_attention(self, segment, query_antecedent, memory_antecedent, bias): """Called prior to self-attention, to incorporate memory items. Args: segment: an integer Tensor with shape [batch] query_antecedent: a Tensor with shape [batch, length_q, channels] memory_antecedent: must be None. A...
[ "Called", "prior", "to", "self", "-", "attention", "to", "incorporate", "memory", "items", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L110-L168
[ "def", "pre_attention", "(", "self", ",", "segment", ",", "query_antecedent", ",", "memory_antecedent", ",", "bias", ")", ":", "assert", "memory_antecedent", "is", "None", ",", "\"We only support language modeling\"", "# In eval mode, batch size may be variable", "memory_ba...
272500b6efe353aeb638d2745ed56e519462ca31
train
RecentTokensMemory.post_attention
Called after self-attention. The memory can be updated here. Args: token: Data returned by pre_attention, which can be used to carry over state related to the current memory operation. x: a Tensor of data after self-attention and feed-forward Returns: a (possibly modified) version of ...
tensor2tensor/layers/transformer_memory.py
def post_attention(self, token, x): """Called after self-attention. The memory can be updated here. Args: token: Data returned by pre_attention, which can be used to carry over state related to the current memory operation. x: a Tensor of data after self-attention and feed-forward Retur...
def post_attention(self, token, x): """Called after self-attention. The memory can be updated here. Args: token: Data returned by pre_attention, which can be used to carry over state related to the current memory operation. x: a Tensor of data after self-attention and feed-forward Retur...
[ "Called", "after", "self", "-", "attention", ".", "The", "memory", "can", "be", "updated", "here", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L170-L185
[ "def", "post_attention", "(", "self", ",", "token", ",", "x", ")", ":", "with", "tf", ".", "control_dependencies", "(", "[", "self", ".", "previous_segment", ".", "assign", "(", "token", "[", "0", "]", ")", ",", "self", ".", "previous_vals", ".", "assi...
272500b6efe353aeb638d2745ed56e519462ca31
train
TransformerMemory._norm
Compute the safe norm.
tensor2tensor/layers/transformer_memory.py
def _norm(self, x): """Compute the safe norm.""" return tf.sqrt(tf.reduce_sum(tf.square(x), keepdims=True, axis=-1) + 1e-7)
def _norm(self, x): """Compute the safe norm.""" return tf.sqrt(tf.reduce_sum(tf.square(x), keepdims=True, axis=-1) + 1e-7)
[ "Compute", "the", "safe", "norm", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L226-L228
[ "def", "_norm", "(", "self", ",", "x", ")", ":", "return", "tf", ".", "sqrt", "(", "tf", ".", "reduce_sum", "(", "tf", ".", "square", "(", "x", ")", ",", "keepdims", "=", "True", ",", "axis", "=", "-", "1", ")", "+", "1e-7", ")" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
TransformerMemory._address_content
Address the memory based on content similarity. Args: x: a tensor in the shape of [batch_size, length, depth]. Returns: the logits for each memory entry [batch_size, length, memory_size].
tensor2tensor/layers/transformer_memory.py
def _address_content(self, x): """Address the memory based on content similarity. Args: x: a tensor in the shape of [batch_size, length, depth]. Returns: the logits for each memory entry [batch_size, length, memory_size]. """ mem_keys = tf.layers.dense(self.mem_vals, self.key_depth, ...
def _address_content(self, x): """Address the memory based on content similarity. Args: x: a tensor in the shape of [batch_size, length, depth]. Returns: the logits for each memory entry [batch_size, length, memory_size]. """ mem_keys = tf.layers.dense(self.mem_vals, self.key_depth, ...
[ "Address", "the", "memory", "based", "on", "content", "similarity", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L230-L249
[ "def", "_address_content", "(", "self", ",", "x", ")", ":", "mem_keys", "=", "tf", ".", "layers", ".", "dense", "(", "self", ".", "mem_vals", ",", "self", ".", "key_depth", ",", "bias_initializer", "=", "tf", ".", "constant_initializer", "(", "1.0", ")",...
272500b6efe353aeb638d2745ed56e519462ca31
train
TransformerMemory.read
Read from the memory. An external component can use the results via a simple MLP, e.g., fn(x W_x + retrieved_mem W_m). Args: x: a tensor in the shape of [batch_size, length, depth]. Returns: access_logits: the logits for accessing the memory in shape of [batch_size, length, memor...
tensor2tensor/layers/transformer_memory.py
def read(self, x): """Read from the memory. An external component can use the results via a simple MLP, e.g., fn(x W_x + retrieved_mem W_m). Args: x: a tensor in the shape of [batch_size, length, depth]. Returns: access_logits: the logits for accessing the memory in shape of ...
def read(self, x): """Read from the memory. An external component can use the results via a simple MLP, e.g., fn(x W_x + retrieved_mem W_m). Args: x: a tensor in the shape of [batch_size, length, depth]. Returns: access_logits: the logits for accessing the memory in shape of ...
[ "Read", "from", "the", "memory", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L251-L270
[ "def", "read", "(", "self", ",", "x", ")", ":", "access_logits", "=", "self", ".", "_address_content", "(", "x", ")", "weights", "=", "tf", ".", "nn", ".", "softmax", "(", "access_logits", ")", "retrieved_mem", "=", "tf", ".", "reduce_sum", "(", "tf", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
TransformerMemory.write
Write to the memory based on a combination of similarity and least used. Based on arXiv:1607.00036v2 [cs.LG]. Args: x: a tensor in the shape of [batch_size, length, depth]. access_logits: the logits for accessing the memory. Returns: the update op.
tensor2tensor/layers/transformer_memory.py
def write(self, x, access_logits): """Write to the memory based on a combination of similarity and least used. Based on arXiv:1607.00036v2 [cs.LG]. Args: x: a tensor in the shape of [batch_size, length, depth]. access_logits: the logits for accessing the memory. Returns: the update o...
def write(self, x, access_logits): """Write to the memory based on a combination of similarity and least used. Based on arXiv:1607.00036v2 [cs.LG]. Args: x: a tensor in the shape of [batch_size, length, depth]. access_logits: the logits for accessing the memory. Returns: the update o...
[ "Write", "to", "the", "memory", "based", "on", "a", "combination", "of", "similarity", "and", "least", "used", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L272-L303
[ "def", "write", "(", "self", ",", "x", ",", "access_logits", ")", ":", "gamma", "=", "tf", ".", "layers", ".", "dense", "(", "x", ",", "1", ",", "activation", "=", "tf", ".", "sigmoid", ",", "name", "=", "\"gamma\"", ")", "write_logits", "=", "acce...
272500b6efe353aeb638d2745ed56e519462ca31
train
TransformerMemory.reset
Reset the entries in the memory. Args: entries_to_reset: a 1D tensor. Returns: the reset op.
tensor2tensor/layers/transformer_memory.py
def reset(self, entries_to_reset): """Reset the entries in the memory. Args: entries_to_reset: a 1D tensor. Returns: the reset op. """ num_updates = tf.size(entries_to_reset) update_vals = tf.scatter_update( self.mem_vals, entries_to_reset, tf.tile(tf.expand_dims( ...
def reset(self, entries_to_reset): """Reset the entries in the memory. Args: entries_to_reset: a 1D tensor. Returns: the reset op. """ num_updates = tf.size(entries_to_reset) update_vals = tf.scatter_update( self.mem_vals, entries_to_reset, tf.tile(tf.expand_dims( ...
[ "Reset", "the", "entries", "in", "the", "memory", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L317-L337
[ "def", "reset", "(", "self", ",", "entries_to_reset", ")", ":", "num_updates", "=", "tf", ".", "size", "(", "entries_to_reset", ")", "update_vals", "=", "tf", ".", "scatter_update", "(", "self", ".", "mem_vals", ",", "entries_to_reset", ",", "tf", ".", "ti...
272500b6efe353aeb638d2745ed56e519462ca31
train
TransformerMemory.pre_attention
Called prior to self-attention, to incorporate memory items. Args: segment_number: an integer Tensor with shape [batch] query_antecedent: a Tensor with shape [batch, length_q, channels] memory_antecedent: must be None. Attention normally allows this to be a Tensor with shape [batch, lengt...
tensor2tensor/layers/transformer_memory.py
def pre_attention(self, segment_number, query_antecedent, memory_antecedent, bias): """Called prior to self-attention, to incorporate memory items. Args: segment_number: an integer Tensor with shape [batch] query_antecedent: a Tensor with shape [batch, length_q, channels] ...
def pre_attention(self, segment_number, query_antecedent, memory_antecedent, bias): """Called prior to self-attention, to incorporate memory items. Args: segment_number: an integer Tensor with shape [batch] query_antecedent: a Tensor with shape [batch, length_q, channels] ...
[ "Called", "prior", "to", "self", "-", "attention", "to", "incorporate", "memory", "items", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L339-L371
[ "def", "pre_attention", "(", "self", ",", "segment_number", ",", "query_antecedent", ",", "memory_antecedent", ",", "bias", ")", ":", "with", "tf", ".", "variable_scope", "(", "self", ".", "name", "+", "\"/pre_attention\"", ",", "reuse", "=", "tf", ".", "AUT...
272500b6efe353aeb638d2745ed56e519462ca31
train
TransformerMemory.post_attention
Called after self-attention. The memory can be updated here. Args: token: Data returned by pre_attention, which can be used to carry over state related to the current memory operation. x: a Tensor of data after self-attention and feed-forward Returns: a (possibly modified) version of ...
tensor2tensor/layers/transformer_memory.py
def post_attention(self, token, x): """Called after self-attention. The memory can be updated here. Args: token: Data returned by pre_attention, which can be used to carry over state related to the current memory operation. x: a Tensor of data after self-attention and feed-forward Retur...
def post_attention(self, token, x): """Called after self-attention. The memory can be updated here. Args: token: Data returned by pre_attention, which can be used to carry over state related to the current memory operation. x: a Tensor of data after self-attention and feed-forward Retur...
[ "Called", "after", "self", "-", "attention", ".", "The", "memory", "can", "be", "updated", "here", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/transformer_memory.py#L373-L393
[ "def", "post_attention", "(", "self", ",", "token", ",", "x", ")", ":", "with", "tf", ".", "variable_scope", "(", "self", ".", "name", "+", "\"/post_attention\"", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "depth", "=", "common_layers", ".", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
_define_train
Define the training setup.
tensor2tensor/rl/ppo_learner.py
def _define_train( train_env, ppo_hparams, eval_env_fn=None, sampling_temp=1.0, **collect_kwargs ): """Define the training setup.""" memory, collect_summary, train_initialization = ( _define_collect( train_env, ppo_hparams, "ppo_train", eval_phase=Fa...
def _define_train( train_env, ppo_hparams, eval_env_fn=None, sampling_temp=1.0, **collect_kwargs ): """Define the training setup.""" memory, collect_summary, train_initialization = ( _define_collect( train_env, ppo_hparams, "ppo_train", eval_phase=Fa...
[ "Define", "the", "training", "setup", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/rl/ppo_learner.py#L151-L186
[ "def", "_define_train", "(", "train_env", ",", "ppo_hparams", ",", "eval_env_fn", "=", "None", ",", "sampling_temp", "=", "1.0", ",", "*", "*", "collect_kwargs", ")", ":", "memory", ",", "collect_summary", ",", "train_initialization", "=", "(", "_define_collect"...
272500b6efe353aeb638d2745ed56e519462ca31
train
_run_train
Train.
tensor2tensor/rl/ppo_learner.py
def _run_train(ppo_hparams, event_dir, model_dir, restarter, train_summary_op, eval_summary_op, initializers, report_fn=None, model_save_fn=None): """Train.""" summary_writer = tf.summary.FileWrit...
def _run_train(ppo_hparams, event_dir, model_dir, restarter, train_summary_op, eval_summary_op, initializers, report_fn=None, model_save_fn=None): """Train.""" summary_writer = tf.summary.FileWrit...
[ "Train", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/rl/ppo_learner.py#L189-L251
[ "def", "_run_train", "(", "ppo_hparams", ",", "event_dir", ",", "model_dir", ",", "restarter", ",", "train_summary_op", ",", "eval_summary_op", ",", "initializers", ",", "report_fn", "=", "None", ",", "model_save_fn", "=", "None", ")", ":", "summary_writer", "="...
272500b6efe353aeb638d2745ed56e519462ca31
train
_rollout_metadata
Metadata for rollouts.
tensor2tensor/rl/ppo_learner.py
def _rollout_metadata(batch_env): """Metadata for rollouts.""" batch_env_shape = batch_env.observ.get_shape().as_list() batch_size = [batch_env_shape[0]] shapes_types_names = [ # TODO(piotrmilos): possibly retrieve the observation type for batch_env (batch_size + batch_env_shape[1:], batch_env.obser...
def _rollout_metadata(batch_env): """Metadata for rollouts.""" batch_env_shape = batch_env.observ.get_shape().as_list() batch_size = [batch_env_shape[0]] shapes_types_names = [ # TODO(piotrmilos): possibly retrieve the observation type for batch_env (batch_size + batch_env_shape[1:], batch_env.obser...
[ "Metadata", "for", "rollouts", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/rl/ppo_learner.py#L254-L268
[ "def", "_rollout_metadata", "(", "batch_env", ")", ":", "batch_env_shape", "=", "batch_env", ".", "observ", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "batch_size", "=", "[", "batch_env_shape", "[", "0", "]", "]", "shapes_types_names", "=", "[", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
_define_collect
Collect trajectories. Args: batch_env: Batch environment. ppo_hparams: PPO hparams, defined in tensor2tensor.models.research.rl. scope: var scope. frame_stack_size: Number of last observations to feed into the policy. eval_phase: TODO(koz4k): Write docstring. sampling_temp: Sampling temperatu...
tensor2tensor/rl/ppo_learner.py
def _define_collect(batch_env, ppo_hparams, scope, frame_stack_size, eval_phase, sampling_temp, force_beginning_resets): """Collect trajectories. Args: batch_env: Batch environment. ppo_hparams: PPO hparams, defined in tensor2tensor.models.research.rl. scope: var scope. frame_st...
def _define_collect(batch_env, ppo_hparams, scope, frame_stack_size, eval_phase, sampling_temp, force_beginning_resets): """Collect trajectories. Args: batch_env: Batch environment. ppo_hparams: PPO hparams, defined in tensor2tensor.models.research.rl. scope: var scope. frame_st...
[ "Collect", "trajectories", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/rl/ppo_learner.py#L310-L515
[ "def", "_define_collect", "(", "batch_env", ",", "ppo_hparams", ",", "scope", ",", "frame_stack_size", ",", "eval_phase", ",", "sampling_temp", ",", "force_beginning_resets", ")", ":", "epoch_length", "=", "ppo_hparams", ".", "epoch_length", "to_initialize", "=", "[...
272500b6efe353aeb638d2745ed56e519462ca31
train
deconv2d
Deconvolution layer.
tensor2tensor/models/vanilla_gan.py
def deconv2d( input_, output_shape, k_h, k_w, d_h, d_w, stddev=0.02, name="deconv2d"): """Deconvolution layer.""" with tf.variable_scope(name): w = tf.get_variable( "w", [k_h, k_w, output_shape[-1], input_.get_shape()[-1]], initializer=tf.random_normal_initializer(stddev=stddev)) deconv ...
def deconv2d( input_, output_shape, k_h, k_w, d_h, d_w, stddev=0.02, name="deconv2d"): """Deconvolution layer.""" with tf.variable_scope(name): w = tf.get_variable( "w", [k_h, k_w, output_shape[-1], input_.get_shape()[-1]], initializer=tf.random_normal_initializer(stddev=stddev)) deconv ...
[ "Deconvolution", "layer", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/vanilla_gan.py#L37-L48
[ "def", "deconv2d", "(", "input_", ",", "output_shape", ",", "k_h", ",", "k_w", ",", "d_h", ",", "d_w", ",", "stddev", "=", "0.02", ",", "name", "=", "\"deconv2d\"", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ")", ":", "w", "=", "tf...
272500b6efe353aeb638d2745ed56e519462ca31
train
sliced_gan
Basic parameters for a vanilla_gan.
tensor2tensor/models/vanilla_gan.py
def sliced_gan(): """Basic parameters for a vanilla_gan.""" hparams = common_hparams.basic_params1() hparams.optimizer = "adam" hparams.learning_rate_constant = 0.0002 hparams.learning_rate_warmup_steps = 500 hparams.learning_rate_schedule = "constant * linear_warmup" hparams.label_smoothing = 0.0 hpara...
def sliced_gan(): """Basic parameters for a vanilla_gan.""" hparams = common_hparams.basic_params1() hparams.optimizer = "adam" hparams.learning_rate_constant = 0.0002 hparams.learning_rate_warmup_steps = 500 hparams.learning_rate_schedule = "constant * linear_warmup" hparams.label_smoothing = 0.0 hpara...
[ "Basic", "parameters", "for", "a", "vanilla_gan", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/vanilla_gan.py#L199-L217
[ "def", "sliced_gan", "(", ")", ":", "hparams", "=", "common_hparams", ".", "basic_params1", "(", ")", "hparams", ".", "optimizer", "=", "\"adam\"", "hparams", ".", "learning_rate_constant", "=", "0.0002", "hparams", ".", "learning_rate_warmup_steps", "=", "500", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
AbstractGAN.discriminator
Discriminator architecture based on InfoGAN. Args: x: input images, shape [bs, h, w, channels] is_training: boolean, are we in train or eval model. reuse: boolean, should params be re-used. Returns: out_logit: the output logits (before sigmoid).
tensor2tensor/models/vanilla_gan.py
def discriminator(self, x, is_training, reuse=False): """Discriminator architecture based on InfoGAN. Args: x: input images, shape [bs, h, w, channels] is_training: boolean, are we in train or eval model. reuse: boolean, should params be re-used. Returns: out_logit: the output logi...
def discriminator(self, x, is_training, reuse=False): """Discriminator architecture based on InfoGAN. Args: x: input images, shape [bs, h, w, channels] is_training: boolean, are we in train or eval model. reuse: boolean, should params be re-used. Returns: out_logit: the output logi...
[ "Discriminator", "architecture", "based", "on", "InfoGAN", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/vanilla_gan.py#L58-L93
[ "def", "discriminator", "(", "self", ",", "x", ",", "is_training", ",", "reuse", "=", "False", ")", ":", "hparams", "=", "self", ".", "hparams", "with", "tf", ".", "variable_scope", "(", "\"discriminator\"", ",", "reuse", "=", "reuse", ",", "initializer", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
AbstractGAN.generator
Generator outputting image in [0, 1].
tensor2tensor/models/vanilla_gan.py
def generator(self, z, is_training, out_shape): """Generator outputting image in [0, 1].""" hparams = self.hparams height, width, c_dim = out_shape batch_size = hparams.batch_size with tf.variable_scope( "generator", initializer=tf.random_normal_initializer(stddev=0.02)): net =...
def generator(self, z, is_training, out_shape): """Generator outputting image in [0, 1].""" hparams = self.hparams height, width, c_dim = out_shape batch_size = hparams.batch_size with tf.variable_scope( "generator", initializer=tf.random_normal_initializer(stddev=0.02)): net =...
[ "Generator", "outputting", "image", "in", "[", "0", "1", "]", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/vanilla_gan.py#L95-L121
[ "def", "generator", "(", "self", ",", "z", ",", "is_training", ",", "out_shape", ")", ":", "hparams", "=", "self", ".", "hparams", "height", ",", "width", ",", "c_dim", "=", "out_shape", "batch_size", "=", "hparams", ".", "batch_size", "with", "tf", ".",...
272500b6efe353aeb638d2745ed56e519462ca31
train
AbstractGAN.body
Body of the model. Args: features: a dictionary with the tensors. Returns: A pair (predictions, losses) where predictions is the generated image and losses is a dictionary of losses (that get added for the final loss).
tensor2tensor/models/vanilla_gan.py
def body(self, features): """Body of the model. Args: features: a dictionary with the tensors. Returns: A pair (predictions, losses) where predictions is the generated image and losses is a dictionary of losses (that get added for the final loss). """ features["targets"] = featur...
def body(self, features): """Body of the model. Args: features: a dictionary with the tensors. Returns: A pair (predictions, losses) where predictions is the generated image and losses is a dictionary of losses (that get added for the final loss). """ features["targets"] = featur...
[ "Body", "of", "the", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/vanilla_gan.py#L127-L160
[ "def", "body", "(", "self", ",", "features", ")", ":", "features", "[", "\"targets\"", "]", "=", "features", "[", "\"inputs\"", "]", "is_training", "=", "self", ".", "hparams", ".", "mode", "==", "tf", ".", "estimator", ".", "ModeKeys", ".", "TRAIN", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
inputs
Make Inputs for built-in datasets. Args: num_devices: how many devices to build the inputs for. dataset_name: a TFDS or T2T dataset name. If it's a T2T dataset name, prefix with "t2t_". data_dir: data directory. input_name: optional, name of the inputs from the dictionary. num_chunks: optio...
tensor2tensor/trax/inputs.py
def inputs(num_devices, dataset_name, data_dir=None, input_name=None, num_chunks=0, append_targets=False): """Make Inputs for built-in datasets. Args: num_devices: how many devices to build the inputs for. dataset_name: a TFDS or T2T dataset name. If it's a T2T dataset name, prefix with "t...
def inputs(num_devices, dataset_name, data_dir=None, input_name=None, num_chunks=0, append_targets=False): """Make Inputs for built-in datasets. Args: num_devices: how many devices to build the inputs for. dataset_name: a TFDS or T2T dataset name. If it's a T2T dataset name, prefix with "t...
[ "Make", "Inputs", "for", "built", "-", "in", "datasets", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/inputs.py#L58-L95
[ "def", "inputs", "(", "num_devices", ",", "dataset_name", ",", "data_dir", "=", "None", ",", "input_name", "=", "None", ",", "num_chunks", "=", "0", ",", "append_targets", "=", "False", ")", ":", "assert", "data_dir", ",", "\"Must provide a data directory\"", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
random_inputs
Make random Inputs for debugging. Args: num_devices: how many devices to build the inputs for. input_shape: the shape of inputs (including batch dimension). input_dtype: the type of the inputs (int32 by default). input_range: the range of inputs (defaults to (0, 255)). output_shape: the shape of ...
tensor2tensor/trax/inputs.py
def random_inputs( num_devices, input_shape=gin.REQUIRED, input_dtype=np.int32, input_range=(0, 255), output_shape=gin.REQUIRED, output_dtype=np.int32, output_range=(0, 9)): """Make random Inputs for debugging. Args: num_devices: how many devices to build the inputs for. input_shape: the shape ...
def random_inputs( num_devices, input_shape=gin.REQUIRED, input_dtype=np.int32, input_range=(0, 255), output_shape=gin.REQUIRED, output_dtype=np.int32, output_range=(0, 9)): """Make random Inputs for debugging. Args: num_devices: how many devices to build the inputs for. input_shape: the shape ...
[ "Make", "random", "Inputs", "for", "debugging", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/inputs.py#L99-L143
[ "def", "random_inputs", "(", "num_devices", ",", "input_shape", "=", "gin", ".", "REQUIRED", ",", "input_dtype", "=", "np", ".", "int32", ",", "input_range", "=", "(", "0", ",", "255", ")", ",", "output_shape", "=", "gin", ".", "REQUIRED", ",", "output_d...
272500b6efe353aeb638d2745ed56e519462ca31
train
dataset_to_stream
Takes a tf.Dataset and creates a numpy stream of ready batches.
tensor2tensor/trax/inputs.py
def dataset_to_stream(dataset, input_name, num_chunks=0, append_targets=False): """Takes a tf.Dataset and creates a numpy stream of ready batches.""" for example in tfds.as_numpy(dataset): inp, out = example[0][input_name], example[1] if len(out.shape) > 1 and out.shape[-1] == 1: out = np.squeeze(out,...
def dataset_to_stream(dataset, input_name, num_chunks=0, append_targets=False): """Takes a tf.Dataset and creates a numpy stream of ready batches.""" for example in tfds.as_numpy(dataset): inp, out = example[0][input_name], example[1] if len(out.shape) > 1 and out.shape[-1] == 1: out = np.squeeze(out,...
[ "Takes", "a", "tf", ".", "Dataset", "and", "creates", "a", "numpy", "stream", "of", "ready", "batches", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/inputs.py#L146-L157
[ "def", "dataset_to_stream", "(", "dataset", ",", "input_name", ",", "num_chunks", "=", "0", ",", "append_targets", "=", "False", ")", ":", "for", "example", "in", "tfds", ".", "as_numpy", "(", "dataset", ")", ":", "inp", ",", "out", "=", "example", "[", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
_train_and_eval_dataset_v1
Return train and evaluation datasets, feature info and supervised keys.
tensor2tensor/trax/inputs.py
def _train_and_eval_dataset_v1(problem_name, data_dir): """Return train and evaluation datasets, feature info and supervised keys.""" assert not tf.executing_eagerly(), "tf.eager mode must be turned off." problem = t2t_problems.problem(problem_name) train_dataset = problem.dataset(tf.estimator.ModeKeys.TRAIN, d...
def _train_and_eval_dataset_v1(problem_name, data_dir): """Return train and evaluation datasets, feature info and supervised keys.""" assert not tf.executing_eagerly(), "tf.eager mode must be turned off." problem = t2t_problems.problem(problem_name) train_dataset = problem.dataset(tf.estimator.ModeKeys.TRAIN, d...
[ "Return", "train", "and", "evaluation", "datasets", "feature", "info", "and", "supervised", "keys", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/inputs.py#L229-L257
[ "def", "_train_and_eval_dataset_v1", "(", "problem_name", ",", "data_dir", ")", ":", "assert", "not", "tf", ".", "executing_eagerly", "(", ")", ",", "\"tf.eager mode must be turned off.\"", "problem", "=", "t2t_problems", ".", "problem", "(", "problem_name", ")", "t...
272500b6efe353aeb638d2745ed56e519462ca31
train
batch_fun
Batching function.
tensor2tensor/trax/inputs.py
def batch_fun(dataset, training, shapes, target_names, num_devices, batch_size_per_device=32, batch_size=None, eval_batch_size=32, bucket_length=32, buckets=None, batch_shuffle_size=128, max_eval_length=None): """Batching function.""" del target_names # Batch size is batc...
def batch_fun(dataset, training, shapes, target_names, num_devices, batch_size_per_device=32, batch_size=None, eval_batch_size=32, bucket_length=32, buckets=None, batch_shuffle_size=128, max_eval_length=None): """Batching function.""" del target_names # Batch size is batc...
[ "Batching", "function", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/inputs.py#L262-L316
[ "def", "batch_fun", "(", "dataset", ",", "training", ",", "shapes", ",", "target_names", ",", "num_devices", ",", "batch_size_per_device", "=", "32", ",", "batch_size", "=", "None", ",", "eval_batch_size", "=", "32", ",", "bucket_length", "=", "32", ",", "bu...
272500b6efe353aeb638d2745ed56e519462ca31
train
lm1b_preprocess
Preprocessing for LM1B: filter out targets exceeding maximum length.
tensor2tensor/trax/inputs.py
def lm1b_preprocess(dataset, training, max_target_length=-1, max_eval_target_length=-1): """Preprocessing for LM1B: filter out targets exceeding maximum length.""" def target_right_length(_, target): return tf.less(tf.shape(target)[0], max_target_length + 1) def eval_target_right_length(...
def lm1b_preprocess(dataset, training, max_target_length=-1, max_eval_target_length=-1): """Preprocessing for LM1B: filter out targets exceeding maximum length.""" def target_right_length(_, target): return tf.less(tf.shape(target)[0], max_target_length + 1) def eval_target_right_length(...
[ "Preprocessing", "for", "LM1B", ":", "filter", "out", "targets", "exceeding", "maximum", "length", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/inputs.py#L337-L353
[ "def", "lm1b_preprocess", "(", "dataset", ",", "training", ",", "max_target_length", "=", "-", "1", ",", "max_eval_target_length", "=", "-", "1", ")", ":", "def", "target_right_length", "(", "_", ",", "target", ")", ":", "return", "tf", ".", "less", "(", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
shuffle_and_batch_data
Shuffle and batch the given dataset.
tensor2tensor/trax/inputs.py
def shuffle_and_batch_data(dataset, target_names, features_info, training, num_devices, shuffle_buffer_size=1024, preprocess_fun=no_preprocess): """Shuffle ...
def shuffle_and_batch_data(dataset, target_names, features_info, training, num_devices, shuffle_buffer_size=1024, preprocess_fun=no_preprocess): """Shuffle ...
[ "Shuffle", "and", "batch", "the", "given", "dataset", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/inputs.py#L357-L385
[ "def", "shuffle_and_batch_data", "(", "dataset", ",", "target_names", ",", "features_info", ",", "training", ",", "num_devices", ",", "shuffle_buffer_size", "=", "1024", ",", "preprocess_fun", "=", "no_preprocess", ")", ":", "def", "append_targets", "(", "example", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
_train_and_eval_batches
Return train and eval batches with input name and shape.
tensor2tensor/trax/inputs.py
def _train_and_eval_batches(dataset, data_dir, input_name, num_devices): """Return train and eval batches with input name and shape.""" (train_data, eval_data, features_info, keys) = train_and_eval_dataset( dataset, data_dir) input_names, target_names = keys[0], keys[1] train_batches = shuffle_and_batch_d...
def _train_and_eval_batches(dataset, data_dir, input_name, num_devices): """Return train and eval batches with input name and shape.""" (train_data, eval_data, features_info, keys) = train_and_eval_dataset( dataset, data_dir) input_names, target_names = keys[0], keys[1] train_batches = shuffle_and_batch_d...
[ "Return", "train", "and", "eval", "batches", "with", "input", "name", "and", "shape", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/inputs.py#L388-L405
[ "def", "_train_and_eval_batches", "(", "dataset", ",", "data_dir", ",", "input_name", ",", "num_devices", ")", ":", "(", "train_data", ",", "eval_data", ",", "features_info", ",", "keys", ")", "=", "train_and_eval_dataset", "(", "dataset", ",", "data_dir", ")", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
get_multi_dataset
Returns a Dataset that samples records from one or more Datasets. Args: datasets: A list of one or more Dataset objects to sample from. pmf: A tensor of shape [len(datasets)], the probabilities to sample each dataset with. This tensor is often constructed with the global_step. If this is None, we...
tensor2tensor/data_generators/multi_problem_v2.py
def get_multi_dataset(datasets, pmf=None): """Returns a Dataset that samples records from one or more Datasets. Args: datasets: A list of one or more Dataset objects to sample from. pmf: A tensor of shape [len(datasets)], the probabilities to sample each dataset with. This tensor is often constructed...
def get_multi_dataset(datasets, pmf=None): """Returns a Dataset that samples records from one or more Datasets. Args: datasets: A list of one or more Dataset objects to sample from. pmf: A tensor of shape [len(datasets)], the probabilities to sample each dataset with. This tensor is often constructed...
[ "Returns", "a", "Dataset", "that", "samples", "records", "from", "one", "or", "more", "Datasets", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem_v2.py#L205-L223
[ "def", "get_multi_dataset", "(", "datasets", ",", "pmf", "=", "None", ")", ":", "pmf", "=", "tf", ".", "fill", "(", "[", "len", "(", "datasets", ")", "]", ",", "1.0", "/", "len", "(", "datasets", ")", ")", "if", "pmf", "is", "None", "else", "pmf"...
272500b6efe353aeb638d2745ed56e519462ca31
train
get_schedule_distribution
Computes the pmf of a schedule given the global_step. Args: schedule: A schedule tuple, see encode_schedule for details. global_step: A scalar tensor, the step to query the schedule. Returns: A 1-D tensor of probs, the sampling distribution of the global_step.
tensor2tensor/data_generators/multi_problem_v2.py
def get_schedule_distribution(schedule, global_step=None): """Computes the pmf of a schedule given the global_step. Args: schedule: A schedule tuple, see encode_schedule for details. global_step: A scalar tensor, the step to query the schedule. Returns: A 1-D tensor of probs, the sampling distributi...
def get_schedule_distribution(schedule, global_step=None): """Computes the pmf of a schedule given the global_step. Args: schedule: A schedule tuple, see encode_schedule for details. global_step: A scalar tensor, the step to query the schedule. Returns: A 1-D tensor of probs, the sampling distributi...
[ "Computes", "the", "pmf", "of", "a", "schedule", "given", "the", "global_step", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/multi_problem_v2.py#L226-L253
[ "def", "get_schedule_distribution", "(", "schedule", ",", "global_step", "=", "None", ")", ":", "interpolation", ",", "steps", ",", "pmfs", "=", "schedule", "if", "len", "(", "pmfs", ")", "==", "1", ":", "# py_func doesn't seem to work on TPU - at least get the cons...
272500b6efe353aeb638d2745ed56e519462ca31