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
dataset_generator
Generate example dicts.
tensor2tensor/data_generators/gene_expression.py
def dataset_generator(filepath, dataset, chunk_size=1, start_idx=None, end_idx=None): """Generate example dicts.""" encoder = dna_encoder.DNAEncoder(chunk_size=chunk_size) with h5py.File(filepath, "r") as h5_file: # Get in...
def dataset_generator(filepath, dataset, chunk_size=1, start_idx=None, end_idx=None): """Generate example dicts.""" encoder = dna_encoder.DNAEncoder(chunk_size=chunk_size) with h5py.File(filepath, "r") as h5_file: # Get in...
[ "Generate", "example", "dicts", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/gene_expression.py#L232-L260
[ "def", "dataset_generator", "(", "filepath", ",", "dataset", ",", "chunk_size", "=", "1", ",", "start_idx", "=", "None", ",", "end_idx", "=", "None", ")", ":", "encoder", "=", "dna_encoder", ".", "DNAEncoder", "(", "chunk_size", "=", "chunk_size", ")", "wi...
272500b6efe353aeb638d2745ed56e519462ca31
train
to_example_dict
Convert single h5 record to an example dict.
tensor2tensor/data_generators/gene_expression.py
def to_example_dict(encoder, inputs, mask, outputs): """Convert single h5 record to an example dict.""" # Inputs bases = [] input_ids = [] last_idx = -1 for row in np.argwhere(inputs): idx, base_id = row idx, base_id = int(idx), int(base_id) assert idx > last_idx # if not, means 2 True values i...
def to_example_dict(encoder, inputs, mask, outputs): """Convert single h5 record to an example dict.""" # Inputs bases = [] input_ids = [] last_idx = -1 for row in np.argwhere(inputs): idx, base_id = row idx, base_id = int(idx), int(base_id) assert idx > last_idx # if not, means 2 True values i...
[ "Convert", "single", "h5", "record", "to", "an", "example", "dict", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/gene_expression.py#L263-L295
[ "def", "to_example_dict", "(", "encoder", ",", "inputs", ",", "mask", ",", "outputs", ")", ":", "# Inputs", "bases", "=", "[", "]", "input_ids", "=", "[", "]", "last_idx", "=", "-", "1", "for", "row", "in", "np", ".", "argwhere", "(", "inputs", ")", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
linear_interpolate
Linearly interpolate between two tensors at coeff. Args: tensor1: 4-D Tensor, shape=(NHWC) tensor2: 4-D Tensor, shape=(NHWC) coeffs: list of floats. Returns: interp_latents: 5-D Tensor, with interp_latents[i] representing interpolations at coeffs[i]. shape=(l...
tensor2tensor/models/research/glow_ops.py
def linear_interpolate(tensor1, tensor2, coeffs): """Linearly interpolate between two tensors at coeff. Args: tensor1: 4-D Tensor, shape=(NHWC) tensor2: 4-D Tensor, shape=(NHWC) coeffs: list of floats. Returns: interp_latents: 5-D Tensor, with interp_latents[i] representing in...
def linear_interpolate(tensor1, tensor2, coeffs): """Linearly interpolate between two tensors at coeff. Args: tensor1: 4-D Tensor, shape=(NHWC) tensor2: 4-D Tensor, shape=(NHWC) coeffs: list of floats. Returns: interp_latents: 5-D Tensor, with interp_latents[i] representing in...
[ "Linearly", "interpolate", "between", "two", "tensors", "at", "coeff", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L34-L50
[ "def", "linear_interpolate", "(", "tensor1", ",", "tensor2", ",", "coeffs", ")", ":", "interp_tensors", "=", "[", "]", "for", "coeff", "in", "coeffs", ":", "interp_tensor", "=", "tensor1", "+", "coeff", "*", "(", "tensor2", "-", "tensor1", ")", "interp_ten...
272500b6efe353aeb638d2745ed56e519462ca31
train
linear_interpolate_rank
Linearly interpolate channel at "rank" between two tensors. The channels are ranked according to their L2 norm between tensor1[channel] and tensor2[channel]. Args: tensor1: 4-D Tensor, NHWC tensor2: 4-D Tensor, NHWC coeffs: list of floats. rank: integer. Returns: interp_latents: list of in...
tensor2tensor/models/research/glow_ops.py
def linear_interpolate_rank(tensor1, tensor2, coeffs, rank=1): """Linearly interpolate channel at "rank" between two tensors. The channels are ranked according to their L2 norm between tensor1[channel] and tensor2[channel]. Args: tensor1: 4-D Tensor, NHWC tensor2: 4-D Tensor, NHWC coeffs: list of ...
def linear_interpolate_rank(tensor1, tensor2, coeffs, rank=1): """Linearly interpolate channel at "rank" between two tensors. The channels are ranked according to their L2 norm between tensor1[channel] and tensor2[channel]. Args: tensor1: 4-D Tensor, NHWC tensor2: 4-D Tensor, NHWC coeffs: list of ...
[ "Linearly", "interpolate", "channel", "at", "rank", "between", "two", "tensors", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L53-L82
[ "def", "linear_interpolate_rank", "(", "tensor1", ",", "tensor2", ",", "coeffs", ",", "rank", "=", "1", ")", ":", "# sum across space, max across channels.", "_", ",", "_", ",", "_", ",", "num_channels", "=", "common_layers", ".", "shape_list", "(", "tensor1", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
postprocess
Converts x from [-0.5, 0.5], to [0, 255]. Args: x: 3-D or 4-D Tensor normalized between [-0.5, 0.5] n_bits_x: Number of bits representing each pixel of the output. Defaults to 8, to default to 256 possible values. Returns: x: 3-D or 4-D Tensor representing images or videos.
tensor2tensor/models/research/glow_ops.py
def postprocess(x, n_bits_x=8): """Converts x from [-0.5, 0.5], to [0, 255]. Args: x: 3-D or 4-D Tensor normalized between [-0.5, 0.5] n_bits_x: Number of bits representing each pixel of the output. Defaults to 8, to default to 256 possible values. Returns: x: 3-D or 4-D Tensor represen...
def postprocess(x, n_bits_x=8): """Converts x from [-0.5, 0.5], to [0, 255]. Args: x: 3-D or 4-D Tensor normalized between [-0.5, 0.5] n_bits_x: Number of bits representing each pixel of the output. Defaults to 8, to default to 256 possible values. Returns: x: 3-D or 4-D Tensor represen...
[ "Converts", "x", "from", "[", "-", "0", ".", "5", "0", ".", "5", "]", "to", "[", "0", "255", "]", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L85-L99
[ "def", "postprocess", "(", "x", ",", "n_bits_x", "=", "8", ")", ":", "x", "=", "tf", ".", "where", "(", "tf", ".", "is_finite", "(", "x", ")", ",", "x", ",", "tf", ".", "ones_like", "(", "x", ")", ")", "x", "=", "tf", ".", "clip_by_value", "(...
272500b6efe353aeb638d2745ed56e519462ca31
train
get_cond_latents_at_level
Returns a single or list of conditional latents at level 'level'.
tensor2tensor/models/research/glow_ops.py
def get_cond_latents_at_level(cond_latents, level, hparams): """Returns a single or list of conditional latents at level 'level'.""" if cond_latents: if hparams.latent_dist_encoder in ["conv_net", "conv3d_net"]: return [cond_latent[level] for cond_latent in cond_latents] elif hparams.latent_dist_encod...
def get_cond_latents_at_level(cond_latents, level, hparams): """Returns a single or list of conditional latents at level 'level'.""" if cond_latents: if hparams.latent_dist_encoder in ["conv_net", "conv3d_net"]: return [cond_latent[level] for cond_latent in cond_latents] elif hparams.latent_dist_encod...
[ "Returns", "a", "single", "or", "list", "of", "conditional", "latents", "at", "level", "level", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L141-L147
[ "def", "get_cond_latents_at_level", "(", "cond_latents", ",", "level", ",", "hparams", ")", ":", "if", "cond_latents", ":", "if", "hparams", ".", "latent_dist_encoder", "in", "[", "\"conv_net\"", ",", "\"conv3d_net\"", "]", ":", "return", "[", "cond_latent", "["...
272500b6efe353aeb638d2745ed56e519462ca31
train
check_cond_latents
Shape checking for cond_latents.
tensor2tensor/models/research/glow_ops.py
def check_cond_latents(cond_latents, hparams): """Shape checking for cond_latents.""" if cond_latents is None: return if not isinstance(cond_latents[0], list): cond_latents = [cond_latents] exp_num_latents = hparams.num_cond_latents if hparams.latent_dist_encoder == "conv_net": exp_num_latents += ...
def check_cond_latents(cond_latents, hparams): """Shape checking for cond_latents.""" if cond_latents is None: return if not isinstance(cond_latents[0], list): cond_latents = [cond_latents] exp_num_latents = hparams.num_cond_latents if hparams.latent_dist_encoder == "conv_net": exp_num_latents += ...
[ "Shape", "checking", "for", "cond_latents", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L150-L165
[ "def", "check_cond_latents", "(", "cond_latents", ",", "hparams", ")", ":", "if", "cond_latents", "is", "None", ":", "return", "if", "not", "isinstance", "(", "cond_latents", "[", "0", "]", ",", "list", ")", ":", "cond_latents", "=", "[", "cond_latents", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
get_variable_ddi
Wrapper for data-dependent initialization.
tensor2tensor/models/research/glow_ops.py
def get_variable_ddi(name, shape, initial_value, dtype=tf.float32, init=False, trainable=True): """Wrapper for data-dependent initialization.""" # If init is a tf bool: w is assigned dynamically at runtime. # If init is a python bool: then w is determined during graph construction. w = tf.g...
def get_variable_ddi(name, shape, initial_value, dtype=tf.float32, init=False, trainable=True): """Wrapper for data-dependent initialization.""" # If init is a tf bool: w is assigned dynamically at runtime. # If init is a python bool: then w is determined during graph construction. w = tf.g...
[ "Wrapper", "for", "data", "-", "dependent", "initialization", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L169-L180
[ "def", "get_variable_ddi", "(", "name", ",", "shape", ",", "initial_value", ",", "dtype", "=", "tf", ".", "float32", ",", "init", "=", "False", ",", "trainable", "=", "True", ")", ":", "# If init is a tf bool: w is assigned dynamically at runtime.", "# If init is a ...
272500b6efe353aeb638d2745ed56e519462ca31
train
get_dropout
Dropout x with dropout_rate = rate. Apply zero dropout during init or prediction time. Args: x: 4-D Tensor, shape=(NHWC). rate: Dropout rate. init: Initialization. Returns: x: activations after dropout.
tensor2tensor/models/research/glow_ops.py
def get_dropout(x, rate=0.0, init=True): """Dropout x with dropout_rate = rate. Apply zero dropout during init or prediction time. Args: x: 4-D Tensor, shape=(NHWC). rate: Dropout rate. init: Initialization. Returns: x: activations after dropout. """ if init or rate == 0: return x re...
def get_dropout(x, rate=0.0, init=True): """Dropout x with dropout_rate = rate. Apply zero dropout during init or prediction time. Args: x: 4-D Tensor, shape=(NHWC). rate: Dropout rate. init: Initialization. Returns: x: activations after dropout. """ if init or rate == 0: return x re...
[ "Dropout", "x", "with", "dropout_rate", "=", "rate", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L184-L198
[ "def", "get_dropout", "(", "x", ",", "rate", "=", "0.0", ",", "init", "=", "True", ")", ":", "if", "init", "or", "rate", "==", "0", ":", "return", "x", "return", "tf", ".", "layers", ".", "dropout", "(", "x", ",", "rate", "=", "rate", ",", "tra...
272500b6efe353aeb638d2745ed56e519462ca31
train
actnorm_3d
Applies actnorm to each time-step independently. There are a total of 2*n_channels*n_steps parameters learnt. Args: name: variable scope. x: 5-D Tensor, (NTHWC) logscale_factor: Increases the learning rate of the scale by logscale_factor. Returns: x: 5-D Tensor, (NTHWC) with...
tensor2tensor/models/research/glow_ops.py
def actnorm_3d(name, x, logscale_factor=3.): """Applies actnorm to each time-step independently. There are a total of 2*n_channels*n_steps parameters learnt. Args: name: variable scope. x: 5-D Tensor, (NTHWC) logscale_factor: Increases the learning rate of the scale by logscale_...
def actnorm_3d(name, x, logscale_factor=3.): """Applies actnorm to each time-step independently. There are a total of 2*n_channels*n_steps parameters learnt. Args: name: variable scope. x: 5-D Tensor, (NTHWC) logscale_factor: Increases the learning rate of the scale by logscale_...
[ "Applies", "actnorm", "to", "each", "time", "-", "step", "independently", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L202-L222
[ "def", "actnorm_3d", "(", "name", ",", "x", ",", "logscale_factor", "=", "3.", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "x", "=", "tf", ".", "unstack", "(", "x", ",", "axis", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
actnorm
x_{ij} = s x x_{ij} + b. Per-channel scaling and bias. If init is set to True, the scaling and bias are initialized such that the mean and variance of the output activations of the first minibatch are zero and one respectively. Args: name: variable scope. x: input logscale_factor: Used in actnorm_...
tensor2tensor/models/research/glow_ops.py
def actnorm(name, x, logscale_factor=3., reverse=False, init=False, trainable=True): """x_{ij} = s x x_{ij} + b. Per-channel scaling and bias. If init is set to True, the scaling and bias are initialized such that the mean and variance of the output activations of the first minibatch are zero and o...
def actnorm(name, x, logscale_factor=3., reverse=False, init=False, trainable=True): """x_{ij} = s x x_{ij} + b. Per-channel scaling and bias. If init is set to True, the scaling and bias are initialized such that the mean and variance of the output activations of the first minibatch are zero and o...
[ "x_", "{", "ij", "}", "=", "s", "x", "x_", "{", "ij", "}", "+", "b", ".", "Per", "-", "channel", "scaling", "and", "bias", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L226-L261
[ "def", "actnorm", "(", "name", ",", "x", ",", "logscale_factor", "=", "3.", ",", "reverse", "=", "False", ",", "init", "=", "False", ",", "trainable", "=", "True", ")", ":", "var_arg_scope", "=", "arg_scope", "(", "[", "get_variable_ddi", "]", ",", "tr...
272500b6efe353aeb638d2745ed56e519462ca31
train
actnorm_center
Add a bias to x. Initialize such that the output of the first minibatch is zero centered per channel. Args: name: scope x: 2-D or 4-D Tensor. reverse: Forward or backward operation. init: data-dependent initialization. Returns: x_center: (x + b), if reverse is True and (x - b) otherwise.
tensor2tensor/models/research/glow_ops.py
def actnorm_center(name, x, reverse=False, init=False): """Add a bias to x. Initialize such that the output of the first minibatch is zero centered per channel. Args: name: scope x: 2-D or 4-D Tensor. reverse: Forward or backward operation. init: data-dependent initialization. Returns: ...
def actnorm_center(name, x, reverse=False, init=False): """Add a bias to x. Initialize such that the output of the first minibatch is zero centered per channel. Args: name: scope x: 2-D or 4-D Tensor. reverse: Forward or backward operation. init: data-dependent initialization. Returns: ...
[ "Add", "a", "bias", "to", "x", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L265-L296
[ "def", "actnorm_center", "(", "name", ",", "x", ",", "reverse", "=", "False", ",", "init", "=", "False", ")", ":", "shape", "=", "common_layers", ".", "shape_list", "(", "x", ")", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
actnorm_scale
Per-channel scaling of x.
tensor2tensor/models/research/glow_ops.py
def actnorm_scale(name, x, logscale_factor=3., reverse=False, init=False): """Per-channel scaling of x.""" x_shape = common_layers.shape_list(x) with tf.variable_scope(name, reuse=tf.AUTO_REUSE): # Variance initialization logic. assert len(x_shape) == 2 or len(x_shape) == 4 if len(x_shape) == 2: ...
def actnorm_scale(name, x, logscale_factor=3., reverse=False, init=False): """Per-channel scaling of x.""" x_shape = common_layers.shape_list(x) with tf.variable_scope(name, reuse=tf.AUTO_REUSE): # Variance initialization logic. assert len(x_shape) == 2 or len(x_shape) == 4 if len(x_shape) == 2: ...
[ "Per", "-", "channel", "scaling", "of", "x", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L300-L331
[ "def", "actnorm_scale", "(", "name", ",", "x", ",", "logscale_factor", "=", "3.", ",", "reverse", "=", "False", ",", "init", "=", "False", ")", ":", "x_shape", "=", "common_layers", ".", "shape_list", "(", "x", ")", "with", "tf", ".", "variable_scope", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
invertible_1x1_conv
1X1 convolution on x. The 1X1 convolution is parametrized as P*L*(U + sign(s)*exp(log(s))) where 1. P is a permutation matrix. 2. L is a lower triangular matrix with diagonal entries unity. 3. U is a upper triangular matrix where the diagonal entries zero. 4. s is a vector. sign(s) and P are fixed and the...
tensor2tensor/models/research/glow_ops.py
def invertible_1x1_conv(name, x, reverse=False): """1X1 convolution on x. The 1X1 convolution is parametrized as P*L*(U + sign(s)*exp(log(s))) where 1. P is a permutation matrix. 2. L is a lower triangular matrix with diagonal entries unity. 3. U is a upper triangular matrix where the diagonal entries zero. ...
def invertible_1x1_conv(name, x, reverse=False): """1X1 convolution on x. The 1X1 convolution is parametrized as P*L*(U + sign(s)*exp(log(s))) where 1. P is a permutation matrix. 2. L is a lower triangular matrix with diagonal entries unity. 3. U is a upper triangular matrix where the diagonal entries zero. ...
[ "1X1", "convolution", "on", "x", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L335-L401
[ "def", "invertible_1x1_conv", "(", "name", ",", "x", ",", "reverse", "=", "False", ")", ":", "_", ",", "height", ",", "width", ",", "channels", "=", "common_layers", ".", "shape_list", "(", "x", ")", "w_shape", "=", "[", "channels", ",", "channels", "]...
272500b6efe353aeb638d2745ed56e519462ca31
train
add_edge_bias
Pad x and concatenates an edge bias across the depth of x. The edge bias can be thought of as a binary feature which is unity when the filter is being convolved over an edge and zero otherwise. Args: x: Input tensor, shape (NHWC) filter_size: filter_size to determine padding. Returns: x_pad: Input...
tensor2tensor/models/research/glow_ops.py
def add_edge_bias(x, filter_size): """Pad x and concatenates an edge bias across the depth of x. The edge bias can be thought of as a binary feature which is unity when the filter is being convolved over an edge and zero otherwise. Args: x: Input tensor, shape (NHWC) filter_size: filter_size to determ...
def add_edge_bias(x, filter_size): """Pad x and concatenates an edge bias across the depth of x. The edge bias can be thought of as a binary feature which is unity when the filter is being convolved over an edge and zero otherwise. Args: x: Input tensor, shape (NHWC) filter_size: filter_size to determ...
[ "Pad", "x", "and", "concatenates", "an", "edge", "bias", "across", "the", "depth", "of", "x", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L404-L426
[ "def", "add_edge_bias", "(", "x", ",", "filter_size", ")", ":", "x_shape", "=", "common_layers", ".", "shape_list", "(", "x", ")", "if", "filter_size", "[", "0", "]", "==", "1", "and", "filter_size", "[", "1", "]", "==", "1", ":", "return", "x", "a",...
272500b6efe353aeb638d2745ed56e519462ca31
train
time_pad
Pad left across time and pad valid across the spatial components. Also concats a binary feature that indicates if a feature is padded or not. Args: x: 5-D Tensor, (NTHWC) filter_size: list of ints dilations: list of ints, dilations - 1 specifies the number of holes between two filter el...
tensor2tensor/models/research/glow_ops.py
def time_pad(x, filter_size, dilations): """Pad left across time and pad valid across the spatial components. Also concats a binary feature that indicates if a feature is padded or not. Args: x: 5-D Tensor, (NTHWC) filter_size: list of ints dilations: list of ints, dilations - 1 specifies the number...
def time_pad(x, filter_size, dilations): """Pad left across time and pad valid across the spatial components. Also concats a binary feature that indicates if a feature is padded or not. Args: x: 5-D Tensor, (NTHWC) filter_size: list of ints dilations: list of ints, dilations - 1 specifies the number...
[ "Pad", "left", "across", "time", "and", "pad", "valid", "across", "the", "spatial", "components", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L429-L461
[ "def", "time_pad", "(", "x", ",", "filter_size", ",", "dilations", ")", ":", "x_shape", "=", "common_layers", ".", "shape_list", "(", "x", ")", "if", "filter_size", "==", "[", "1", ",", "1", ",", "1", "]", ":", "return", "x", "_", ",", "h", ",", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
conv
Convolutional layer with edge bias padding and optional actnorm. If x is 5-dimensional, actnorm is applied independently across every time-step. Args: name: variable scope. x: 4-D Tensor or 5-D Tensor of shape NHWC or NTHWC output_channels: Number of output channels. filter_size: list of ints, i...
tensor2tensor/models/research/glow_ops.py
def conv(name, x, output_channels, filter_size=None, stride=None, logscale_factor=3.0, apply_actnorm=True, conv_init="default", dilations=None): """Convolutional layer with edge bias padding and optional actnorm. If x is 5-dimensional, actnorm is applied independently across every time-step. ...
def conv(name, x, output_channels, filter_size=None, stride=None, logscale_factor=3.0, apply_actnorm=True, conv_init="default", dilations=None): """Convolutional layer with edge bias padding and optional actnorm. If x is 5-dimensional, actnorm is applied independently across every time-step. ...
[ "Convolutional", "layer", "with", "edge", "bias", "padding", "and", "optional", "actnorm", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L465-L544
[ "def", "conv", "(", "name", ",", "x", ",", "output_channels", ",", "filter_size", "=", "None", ",", "stride", "=", "None", ",", "logscale_factor", "=", "3.0", ",", "apply_actnorm", "=", "True", ",", "conv_init", "=", "\"default\"", ",", "dilations", "=", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
conv_block
2 layer conv block used in the affine coupling layer. Args: name: variable scope. x: 4-D or 5-D Tensor. mid_channels: Output channels of the second layer. dilations: Optional, list of integers. activation: relu or gatu. If relu, the second layer is relu(W*x) If gatu, the second layer ...
tensor2tensor/models/research/glow_ops.py
def conv_block(name, x, mid_channels, dilations=None, activation="relu", dropout=0.0): """2 layer conv block used in the affine coupling layer. Args: name: variable scope. x: 4-D or 5-D Tensor. mid_channels: Output channels of the second layer. dilations: Optional, list of integers. ...
def conv_block(name, x, mid_channels, dilations=None, activation="relu", dropout=0.0): """2 layer conv block used in the affine coupling layer. Args: name: variable scope. x: 4-D or 5-D Tensor. mid_channels: Output channels of the second layer. dilations: Optional, list of integers. ...
[ "2", "layer", "conv", "block", "used", "in", "the", "affine", "coupling", "layer", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L548-L603
[ "def", "conv_block", "(", "name", ",", "x", ",", "mid_channels", ",", "dilations", "=", "None", ",", "activation", "=", "\"relu\"", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
dilated_conv_stack
Dilated convolutional stack. Features at different rates are computed independently using a 3 layer convolutional stack and added. Args: name: variable scope. x: 5-D Tensor. mid_channels: Number of output channels of the first layer in the conv stack. output_channels: Number of...
tensor2tensor/models/research/glow_ops.py
def dilated_conv_stack(name, x, mid_channels, output_channels, dilation_rates, activation="relu", dropout=0.0): """Dilated convolutional stack. Features at different rates are computed independently using a 3 layer convolutional stack and added. Args: name: va...
def dilated_conv_stack(name, x, mid_channels, output_channels, dilation_rates, activation="relu", dropout=0.0): """Dilated convolutional stack. Features at different rates are computed independently using a 3 layer convolutional stack and added. Args: name: va...
[ "Dilated", "convolutional", "stack", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L606-L634
[ "def", "dilated_conv_stack", "(", "name", ",", "x", ",", "mid_channels", ",", "output_channels", ",", "dilation_rates", ",", "activation", "=", "\"relu\"", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
conv_stack
3-layer convolutional stack. Args: name: variable scope. x: 5-D Tensor. mid_channels: Number of output channels of the first layer. output_channels: Number of output channels. dilations: Dilations to apply in the first 3x3 layer and the last 3x3 layer. By default, apply no dilation...
tensor2tensor/models/research/glow_ops.py
def conv_stack(name, x, mid_channels, output_channels, dilations=None, activation="relu", dropout=0.0): """3-layer convolutional stack. Args: name: variable scope. x: 5-D Tensor. mid_channels: Number of output channels of the first layer. output_channels: Number of output channels. ...
def conv_stack(name, x, mid_channels, output_channels, dilations=None, activation="relu", dropout=0.0): """3-layer convolutional stack. Args: name: variable scope. x: 5-D Tensor. mid_channels: Number of output channels of the first layer. output_channels: Number of output channels. ...
[ "3", "-", "layer", "convolutional", "stack", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L638-L665
[ "def", "conv_stack", "(", "name", ",", "x", ",", "mid_channels", ",", "output_channels", ",", "dilations", "=", "None", ",", "activation", "=", "\"relu\"", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reus...
272500b6efe353aeb638d2745ed56e519462ca31
train
additive_coupling
Reversible additive coupling layer. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). mid_channels: number of channels in the coupling layer. reverse: Forward or reverse operation. activation: "relu" or "gatu" dropout: default, 0.0 Returns: output: 4-D Tensor, shape=(NHWC) ob...
tensor2tensor/models/research/glow_ops.py
def additive_coupling(name, x, mid_channels=512, reverse=False, activation="relu", dropout=0.0): """Reversible additive coupling layer. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). mid_channels: number of channels in the coupling layer. reverse: Forward or reverse ...
def additive_coupling(name, x, mid_channels=512, reverse=False, activation="relu", dropout=0.0): """Reversible additive coupling layer. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). mid_channels: number of channels in the coupling layer. reverse: Forward or reverse ...
[ "Reversible", "additive", "coupling", "layer", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L669-L696
[ "def", "additive_coupling", "(", "name", ",", "x", ",", "mid_channels", "=", "512", ",", "reverse", "=", "False", ",", "activation", "=", "\"relu\"", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
affine_coupling
Reversible affine coupling layer. Args: name: variable scope. x: 4-D Tensor. mid_channels: number of channels in the coupling layer. activation: Can be either "relu" or "gatu". reverse: Forward or reverse operation. dropout: default, 0.0 Returns: output: x shifted and scaled by an affin...
tensor2tensor/models/research/glow_ops.py
def affine_coupling(name, x, mid_channels=512, activation="relu", reverse=False, dropout=0.0): """Reversible affine coupling layer. Args: name: variable scope. x: 4-D Tensor. mid_channels: number of channels in the coupling layer. activation: Can be either "relu" or "gatu". ...
def affine_coupling(name, x, mid_channels=512, activation="relu", reverse=False, dropout=0.0): """Reversible affine coupling layer. Args: name: variable scope. x: 4-D Tensor. mid_channels: number of channels in the coupling layer. activation: Can be either "relu" or "gatu". ...
[ "Reversible", "affine", "coupling", "layer", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L700-L738
[ "def", "affine_coupling", "(", "name", ",", "x", ",", "mid_channels", "=", "512", ",", "activation", "=", "\"relu\"", ",", "reverse", "=", "False", ",", "dropout", "=", "0.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=...
272500b6efe353aeb638d2745ed56e519462ca31
train
squeeze
Block-wise spatial squeezing of x to increase the number of channels. Args: name: Used for variable scoping. x: 4-D Tensor of shape (batch_size X H X W X C) factor: Factor by which the spatial dimensions should be squeezed. reverse: Squueze or unsqueeze operation. Returns: x: 4-D Tensor of sha...
tensor2tensor/models/research/glow_ops.py
def squeeze(name, x, factor=2, reverse=True): """Block-wise spatial squeezing of x to increase the number of channels. Args: name: Used for variable scoping. x: 4-D Tensor of shape (batch_size X H X W X C) factor: Factor by which the spatial dimensions should be squeezed. reverse: Squueze or unsque...
def squeeze(name, x, factor=2, reverse=True): """Block-wise spatial squeezing of x to increase the number of channels. Args: name: Used for variable scoping. x: 4-D Tensor of shape (batch_size X H X W X C) factor: Factor by which the spatial dimensions should be squeezed. reverse: Squueze or unsque...
[ "Block", "-", "wise", "spatial", "squeezing", "of", "x", "to", "increase", "the", "number", "of", "channels", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L742-L776
[ "def", "squeeze", "(", "name", ",", "x", ",", "factor", "=", "2", ",", "reverse", "=", "True", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "shape", "=", "common_layers", ".", "sh...
272500b6efe353aeb638d2745ed56e519462ca31
train
get_dilation_rates
Get a list of valid dilation rates. Args: hparams: HParams. width: spatial dimension. Ensures that the effective filter size is not larger than the spatial dimension. Returns: allowed_dilations: A list of dilation rates.
tensor2tensor/models/research/glow_ops.py
def get_dilation_rates(hparams, width): """Get a list of valid dilation rates. Args: hparams: HParams. width: spatial dimension. Ensures that the effective filter size is not larger than the spatial dimension. Returns: allowed_dilations: A list of dilation rates. """ # dil_rate=1 means...
def get_dilation_rates(hparams, width): """Get a list of valid dilation rates. Args: hparams: HParams. width: spatial dimension. Ensures that the effective filter size is not larger than the spatial dimension. Returns: allowed_dilations: A list of dilation rates. """ # dil_rate=1 means...
[ "Get", "a", "list", "of", "valid", "dilation", "rates", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L779-L800
[ "def", "get_dilation_rates", "(", "hparams", ",", "width", ")", ":", "# dil_rate=1 means no dilation.", "allowed_dilations", "=", "[", "[", "1", "]", "*", "5", "]", "apply_dilations", "=", "hparams", ".", "get", "(", "\"latent_apply_dilations\"", ",", "False", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
temporal_latent_to_dist
Network that maps a time-indexed list of 3-D latents to a gaussian. Args: name: variable scope. x: List of 4-D Tensors indexed by time, (NHWC) hparams: tf.contrib.training.Hparams. output_channels: int, Number of channels of the output gaussian mean. Returns: dist: tfp.distributions.Normal
tensor2tensor/models/research/glow_ops.py
def temporal_latent_to_dist(name, x, hparams, output_channels=None): """Network that maps a time-indexed list of 3-D latents to a gaussian. Args: name: variable scope. x: List of 4-D Tensors indexed by time, (NHWC) hparams: tf.contrib.training.Hparams. output_channels: int, Number of channels of th...
def temporal_latent_to_dist(name, x, hparams, output_channels=None): """Network that maps a time-indexed list of 3-D latents to a gaussian. Args: name: variable scope. x: List of 4-D Tensors indexed by time, (NHWC) hparams: tf.contrib.training.Hparams. output_channels: int, Number of channels of th...
[ "Network", "that", "maps", "a", "time", "-", "indexed", "list", "of", "3", "-", "D", "latents", "to", "a", "gaussian", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L804-L843
[ "def", "temporal_latent_to_dist", "(", "name", ",", "x", ",", "hparams", ",", "output_channels", "=", "None", ")", ":", "_", ",", "_", ",", "width", ",", "_", ",", "res_channels", "=", "common_layers", ".", "shape_list", "(", "x", ")", "if", "output_chan...
272500b6efe353aeb638d2745ed56e519462ca31
train
single_conv_dist
A 3x3 convolution mapping x to a standard normal distribution at init. Args: name: variable scope. x: 4-D Tensor. output_channels: number of channels of the mean and std.
tensor2tensor/models/research/glow_ops.py
def single_conv_dist(name, x, output_channels=None): """A 3x3 convolution mapping x to a standard normal distribution at init. Args: name: variable scope. x: 4-D Tensor. output_channels: number of channels of the mean and std. """ with tf.variable_scope(name, reuse=tf.AUTO_REUSE): x_shape = com...
def single_conv_dist(name, x, output_channels=None): """A 3x3 convolution mapping x to a standard normal distribution at init. Args: name: variable scope. x: 4-D Tensor. output_channels: number of channels of the mean and std. """ with tf.variable_scope(name, reuse=tf.AUTO_REUSE): x_shape = com...
[ "A", "3x3", "convolution", "mapping", "x", "to", "a", "standard", "normal", "distribution", "at", "init", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L847-L863
[ "def", "single_conv_dist", "(", "name", ",", "x", ",", "output_channels", "=", "None", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "x_shape", "=", "common_layers", ".", "shape_list", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
latent_to_dist
Map latent to the mean and log-scale of a Gaussian. Args: name: variable scope. x: 4-D Tensor of shape (NHWC) hparams: HParams. latent_architecture - can be "single_conv", "glow_nn" or "glow_resnet", default = single_conv latent_encoder_depth - int, depth of archit...
tensor2tensor/models/research/glow_ops.py
def latent_to_dist(name, x, hparams, output_channels=None): """Map latent to the mean and log-scale of a Gaussian. Args: name: variable scope. x: 4-D Tensor of shape (NHWC) hparams: HParams. latent_architecture - can be "single_conv", "glow_nn" or "glow_resnet", defaul...
def latent_to_dist(name, x, hparams, output_channels=None): """Map latent to the mean and log-scale of a Gaussian. Args: name: variable scope. x: 4-D Tensor of shape (NHWC) hparams: HParams. latent_architecture - can be "single_conv", "glow_nn" or "glow_resnet", defaul...
[ "Map", "latent", "to", "the", "mean", "and", "log", "-", "scale", "of", "a", "Gaussian", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L867-L925
[ "def", "latent_to_dist", "(", "name", ",", "x", ",", "hparams", ",", "output_channels", "=", "None", ")", ":", "architecture", "=", "hparams", ".", "get", "(", "\"latent_architecture\"", ",", "\"single_conv\"", ")", "depth", "=", "hparams", ".", "get", "(", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
noise_op
Adds isotropic gaussian-noise to each latent. Args: latents: 4-D or 5-D tensor, shape=(NTHWC) or (NHWC). hparams: HParams. Returns: latents: latents with isotropic gaussian noise appended.
tensor2tensor/models/research/glow_ops.py
def noise_op(latents, hparams): """Adds isotropic gaussian-noise to each latent. Args: latents: 4-D or 5-D tensor, shape=(NTHWC) or (NHWC). hparams: HParams. Returns: latents: latents with isotropic gaussian noise appended. """ if hparams.latent_noise == 0 or hparams.mode != tf.estimator.ModeKeys...
def noise_op(latents, hparams): """Adds isotropic gaussian-noise to each latent. Args: latents: 4-D or 5-D tensor, shape=(NTHWC) or (NHWC). hparams: HParams. Returns: latents: latents with isotropic gaussian noise appended. """ if hparams.latent_noise == 0 or hparams.mode != tf.estimator.ModeKeys...
[ "Adds", "isotropic", "gaussian", "-", "noise", "to", "each", "latent", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L929-L941
[ "def", "noise_op", "(", "latents", ",", "hparams", ")", ":", "if", "hparams", ".", "latent_noise", "==", "0", "or", "hparams", ".", "mode", "!=", "tf", ".", "estimator", ".", "ModeKeys", ".", "TRAIN", ":", "return", "latents", "latent_shape", "=", "commo...
272500b6efe353aeb638d2745ed56e519462ca31
train
merge_level_and_latent_dist
Merge level_dist and latent_dist. new_dist ~ N(level_dist.mean + latent_dis.mean, std) where std is determined according to merge_std. Args: level_dist: instance of tfp.distributions.Normal latent_dist: instance of tfp.distributions.Normal merge_std: can be "prev_level", "prev_step" or "normal". R...
tensor2tensor/models/research/glow_ops.py
def merge_level_and_latent_dist(level_dist, latent_dist, merge_std="prev_level"): """Merge level_dist and latent_dist. new_dist ~ N(level_dist.mean + latent_dis.mean, std) where std is determined according to merge_std. Args: level_dist: instance of tfp.distributions.Normal...
def merge_level_and_latent_dist(level_dist, latent_dist, merge_std="prev_level"): """Merge level_dist and latent_dist. new_dist ~ N(level_dist.mean + latent_dis.mean, std) where std is determined according to merge_std. Args: level_dist: instance of tfp.distributions.Normal...
[ "Merge", "level_dist", "and", "latent_dist", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L945-L972
[ "def", "merge_level_and_latent_dist", "(", "level_dist", ",", "latent_dist", ",", "merge_std", "=", "\"prev_level\"", ")", ":", "level_mean", ",", "level_std", "=", "level_dist", ".", "loc", ",", "level_dist", ".", "scale", "latent_mean", ",", "latent_std", "=", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
level_cond_prior
Returns a conditional prior for each level. Args: prior_dist: Distribution conditioned on the previous levels. z: Tensor, output of the previous levels. latent: Tensor or a list of tensors to condition the latent_distribution. hparams: next_frame_glow hparams. state: Current LSTM state. Used only...
tensor2tensor/models/research/glow_ops.py
def level_cond_prior(prior_dist, z, latent, hparams, state): """Returns a conditional prior for each level. Args: prior_dist: Distribution conditioned on the previous levels. z: Tensor, output of the previous levels. latent: Tensor or a list of tensors to condition the latent_distribution. hparams:...
def level_cond_prior(prior_dist, z, latent, hparams, state): """Returns a conditional prior for each level. Args: prior_dist: Distribution conditioned on the previous levels. z: Tensor, output of the previous levels. latent: Tensor or a list of tensors to condition the latent_distribution. hparams:...
[ "Returns", "a", "conditional", "prior", "for", "each", "level", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L976-L1044
[ "def", "level_cond_prior", "(", "prior_dist", ",", "z", ",", "latent", ",", "hparams", ",", "state", ")", ":", "latent_dist_encoder", "=", "hparams", ".", "get", "(", "\"latent_dist_encoder\"", ",", "None", ")", "latent_skip", "=", "hparams", ".", "get", "("...
272500b6efe353aeb638d2745ed56e519462ca31
train
compute_prior
Distribution on z_t conditioned on z_{t-1} and latent. Args: name: variable scope. z: 4-D Tensor. latent: optional, if hparams.latent_dist_encoder == "pointwise", this is a list of 4-D Tensors of length hparams.num_cond_latents. else, this is just a 4-D Tensor ...
tensor2tensor/models/research/glow_ops.py
def compute_prior(name, z, latent, hparams, condition=False, state=None, temperature=1.0): """Distribution on z_t conditioned on z_{t-1} and latent. Args: name: variable scope. z: 4-D Tensor. latent: optional, if hparams.latent_dist_encoder == "pointwise", this is a list ...
def compute_prior(name, z, latent, hparams, condition=False, state=None, temperature=1.0): """Distribution on z_t conditioned on z_{t-1} and latent. Args: name: variable scope. z: 4-D Tensor. latent: optional, if hparams.latent_dist_encoder == "pointwise", this is a list ...
[ "Distribution", "on", "z_t", "conditioned", "on", "z_", "{", "t", "-", "1", "}", "and", "latent", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1048-L1088
[ "def", "compute_prior", "(", "name", ",", "z", ",", "latent", ",", "hparams", ",", "condition", "=", "False", ",", "state", "=", "None", ",", "temperature", "=", "1.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "t...
272500b6efe353aeb638d2745ed56e519462ca31
train
split
Splits / concatenates x into x1 and x2 across number of channels. For the forward pass, x2 is assumed be gaussian, i.e P(x2 | x1) ~ N(mu, sigma) where mu and sigma are the outputs of a network conditioned on x1 and optionally on cond_latents. For the reverse pass, x2 is determined from mu(x1) and sigma(x1). ...
tensor2tensor/models/research/glow_ops.py
def split(name, x, reverse=False, eps=None, eps_std=None, cond_latents=None, hparams=None, state=None, condition=False, temperature=1.0): """Splits / concatenates x into x1 and x2 across number of channels. For the forward pass, x2 is assumed be gaussian, i.e P(x2 | x1) ~ N(mu, sigma) where mu and sigm...
def split(name, x, reverse=False, eps=None, eps_std=None, cond_latents=None, hparams=None, state=None, condition=False, temperature=1.0): """Splits / concatenates x into x1 and x2 across number of channels. For the forward pass, x2 is assumed be gaussian, i.e P(x2 | x1) ~ N(mu, sigma) where mu and sigm...
[ "Splits", "/", "concatenates", "x", "into", "x1", "and", "x2", "across", "number", "of", "channels", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1092-L1152
[ "def", "split", "(", "name", ",", "x", ",", "reverse", "=", "False", ",", "eps", "=", "None", ",", "eps_std", "=", "None", ",", "cond_latents", "=", "None", ",", "hparams", "=", "None", ",", "state", "=", "None", ",", "condition", "=", "False", ","...
272500b6efe353aeb638d2745ed56e519462ca31
train
revnet_step
One step of glow generative flow. Actnorm + invertible 1X1 conv + affine_coupling. Args: name: used for variable scope. x: input hparams: coupling_width is the only hparam that is being used in this function. reverse: forward or reverse pass. Returns: z: Output of one step of re...
tensor2tensor/models/research/glow_ops.py
def revnet_step(name, x, hparams, reverse=True): """One step of glow generative flow. Actnorm + invertible 1X1 conv + affine_coupling. Args: name: used for variable scope. x: input hparams: coupling_width is the only hparam that is being used in this function. reverse: forward or re...
def revnet_step(name, x, hparams, reverse=True): """One step of glow generative flow. Actnorm + invertible 1X1 conv + affine_coupling. Args: name: used for variable scope. x: input hparams: coupling_width is the only hparam that is being used in this function. reverse: forward or re...
[ "One", "step", "of", "glow", "generative", "flow", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1156-L1193
[ "def", "revnet_step", "(", "name", ",", "x", ",", "hparams", ",", "reverse", "=", "True", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "if", "hparams", ".", "coupling", "==", "\"add...
272500b6efe353aeb638d2745ed56e519462ca31
train
revnet
hparams.depth' steps of generative flow. Args: name: variable scope for the revnet block. x: 4-D Tensor, shape=(NHWC). hparams: HParams. reverse: bool, forward or backward pass. Returns: x: 4-D Tensor, shape=(NHWC). objective: float.
tensor2tensor/models/research/glow_ops.py
def revnet(name, x, hparams, reverse=True): """'hparams.depth' steps of generative flow. Args: name: variable scope for the revnet block. x: 4-D Tensor, shape=(NHWC). hparams: HParams. reverse: bool, forward or backward pass. Returns: x: 4-D Tensor, shape=(NHWC). objective: float. """ ...
def revnet(name, x, hparams, reverse=True): """'hparams.depth' steps of generative flow. Args: name: variable scope for the revnet block. x: 4-D Tensor, shape=(NHWC). hparams: HParams. reverse: bool, forward or backward pass. Returns: x: 4-D Tensor, shape=(NHWC). objective: float. """ ...
[ "hparams", ".", "depth", "steps", "of", "generative", "flow", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1196-L1218
[ "def", "revnet", "(", "name", ",", "x", ",", "hparams", ",", "reverse", "=", "True", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "steps", "=", "np", ".", "arange", "(", "hparams"...
272500b6efe353aeb638d2745ed56e519462ca31
train
scale_gaussian_prior
Returns N(s^i * z^i, std^i) where s^i and std^i are pre-component. s^i is a learnable parameter with identity initialization. std^i is optionally learnable with identity initialization. Args: name: variable scope. z: input_tensor logscale_factor: equivalent to scaling up the learning_rate by a facto...
tensor2tensor/models/research/glow_ops.py
def scale_gaussian_prior(name, z, logscale_factor=3.0, trainable=True): """Returns N(s^i * z^i, std^i) where s^i and std^i are pre-component. s^i is a learnable parameter with identity initialization. std^i is optionally learnable with identity initialization. Args: name: variable scope. z: input_tens...
def scale_gaussian_prior(name, z, logscale_factor=3.0, trainable=True): """Returns N(s^i * z^i, std^i) where s^i and std^i are pre-component. s^i is a learnable parameter with identity initialization. std^i is optionally learnable with identity initialization. Args: name: variable scope. z: input_tens...
[ "Returns", "N", "(", "s^i", "*", "z^i", "std^i", ")", "where", "s^i", "and", "std^i", "are", "pre", "-", "component", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1222-L1245
[ "def", "scale_gaussian_prior", "(", "name", ",", "z", ",", "logscale_factor", "=", "3.0", ",", "trainable", "=", "True", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "z_shape", "=", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
top_prior
Unconditional prior distribution. Args: name: variable scope z_shape: Shape of the mean / scale of the prior distribution. learn_prior: Possible options are "normal" and "single_conv". If set to "single_conv", the gaussian is parametrized by a single convolutional layer ...
tensor2tensor/models/research/glow_ops.py
def top_prior(name, z_shape, learn_prior="normal", temperature=1.0): """Unconditional prior distribution. Args: name: variable scope z_shape: Shape of the mean / scale of the prior distribution. learn_prior: Possible options are "normal" and "single_conv". If set to "single_conv", the ...
def top_prior(name, z_shape, learn_prior="normal", temperature=1.0): """Unconditional prior distribution. Args: name: variable scope z_shape: Shape of the mean / scale of the prior distribution. learn_prior: Possible options are "normal" and "single_conv". If set to "single_conv", the ...
[ "Unconditional", "prior", "distribution", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1249-L1276
[ "def", "top_prior", "(", "name", ",", "z_shape", ",", "learn_prior", "=", "\"normal\"", ",", "temperature", "=", "1.0", ")", ":", "with", "tf", ".", "variable_scope", "(", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "h", "=", "tf", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
uniform_binning_correction
Replaces x^i with q^i(x) = U(x, x + 1.0 / 256.0). Args: x: 4-D Tensor of shape (NHWC) n_bits: optional. Returns: x: x ~ U(x, x + 1.0 / 256) objective: Equivalent to -q(x)*log(q(x)).
tensor2tensor/models/research/glow_ops.py
def uniform_binning_correction(x, n_bits=8): """Replaces x^i with q^i(x) = U(x, x + 1.0 / 256.0). Args: x: 4-D Tensor of shape (NHWC) n_bits: optional. Returns: x: x ~ U(x, x + 1.0 / 256) objective: Equivalent to -q(x)*log(q(x)). """ n_bins = 2**n_bits batch_size, height, width, n_channels ...
def uniform_binning_correction(x, n_bits=8): """Replaces x^i with q^i(x) = U(x, x + 1.0 / 256.0). Args: x: 4-D Tensor of shape (NHWC) n_bits: optional. Returns: x: x ~ U(x, x + 1.0 / 256) objective: Equivalent to -q(x)*log(q(x)). """ n_bins = 2**n_bits batch_size, height, width, n_channels ...
[ "Replaces", "x^i", "with", "q^i", "(", "x", ")", "=", "U", "(", "x", "x", "+", "1", ".", "0", "/", "256", ".", "0", ")", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1279-L1297
[ "def", "uniform_binning_correction", "(", "x", ",", "n_bits", "=", "8", ")", ":", "n_bins", "=", "2", "**", "n_bits", "batch_size", ",", "height", ",", "width", ",", "n_channels", "=", "common_layers", ".", "shape_list", "(", "x", ")", "hwc", "=", "float...
272500b6efe353aeb638d2745ed56e519462ca31
train
encoder_decoder
Glow encoder-decoder. n_levels of (Squeeze + Flow + Split.) operations. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). hparams: HParams. eps: Stores (glow(x) - mu) / sigma during the forward pass. Used only to test if the network is reversible. reverse: Forward or reverse pass....
tensor2tensor/models/research/glow_ops.py
def encoder_decoder(name, x, hparams, eps=None, reverse=False, cond_latents=None, condition=False, states=None, temperature=1.0): """Glow encoder-decoder. n_levels of (Squeeze + Flow + Split.) operations. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). h...
def encoder_decoder(name, x, hparams, eps=None, reverse=False, cond_latents=None, condition=False, states=None, temperature=1.0): """Glow encoder-decoder. n_levels of (Squeeze + Flow + Split.) operations. Args: name: variable scope. x: 4-D Tensor, shape=(NHWC). h...
[ "Glow", "encoder", "-", "decoder", ".", "n_levels", "of", "(", "Squeeze", "+", "Flow", "+", "Split", ".", ")", "operations", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/glow_ops.py#L1301-L1392
[ "def", "encoder_decoder", "(", "name", ",", "x", ",", "hparams", ",", "eps", "=", "None", ",", "reverse", "=", "False", ",", "cond_latents", "=", "None", ",", "condition", "=", "False", ",", "states", "=", "None", ",", "temperature", "=", "1.0", ")", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
bfloat16_activations_var_getter
A custom getter function for float32 parameters and bfloat16 activations. Args: getter: custom getter *args: arguments **kwargs: keyword arguments Returns: variables with the correct dtype. Raises: KeyError: if "dtype" is not provided as a kwarg.
tensor2tensor/utils/quantization.py
def bfloat16_activations_var_getter(getter, *args, **kwargs): """A custom getter function for float32 parameters and bfloat16 activations. Args: getter: custom getter *args: arguments **kwargs: keyword arguments Returns: variables with the correct dtype. Raises: KeyError: if "dtype" is not ...
def bfloat16_activations_var_getter(getter, *args, **kwargs): """A custom getter function for float32 parameters and bfloat16 activations. Args: getter: custom getter *args: arguments **kwargs: keyword arguments Returns: variables with the correct dtype. Raises: KeyError: if "dtype" is not ...
[ "A", "custom", "getter", "function", "for", "float32", "parameters", "and", "bfloat16", "activations", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L25-L48
[ "def", "bfloat16_activations_var_getter", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "requested_dtype", "=", "kwargs", "[", "\"dtype\"", "]", "if", "requested_dtype", "==", "tf", ".", "bfloat16", ":", "kwargs", "[", "\"dtype\"", "]",...
272500b6efe353aeb638d2745ed56e519462ca31
train
float16_activations_var_getter
A custom getter function for float32 parameters and float16 activations. This function ensures the following: 1. All variables requested with type fp16 are stored as type fp32. 2. All variables requested with type fp32 are returned as type fp16. See https://docs.nvidia.com/deeplearning/sdk/mixed-precision-...
tensor2tensor/utils/quantization.py
def float16_activations_var_getter(getter, *args, **kwargs): """A custom getter function for float32 parameters and float16 activations. This function ensures the following: 1. All variables requested with type fp16 are stored as type fp32. 2. All variables requested with type fp32 are returned as type fp1...
def float16_activations_var_getter(getter, *args, **kwargs): """A custom getter function for float32 parameters and float16 activations. This function ensures the following: 1. All variables requested with type fp16 are stored as type fp32. 2. All variables requested with type fp32 are returned as type fp1...
[ "A", "custom", "getter", "function", "for", "float32", "parameters", "and", "float16", "activations", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L51-L86
[ "def", "float16_activations_var_getter", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "requested_dtype", "=", "kwargs", "[", "\"dtype\"", "]", "if", "requested_dtype", "==", "tf", ".", "float16", ":", "kwargs", "[", "\"dtype\"", "]", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
simulated_quantize
Simulate quantization to num_bits bits, with externally-stored scale. num_bits is the number of bits used to store each value. noise is a float32 Tensor containing values in [0, 1). Each value in noise should take different values across different steps, approximating a uniform distribution over [0, 1). In t...
tensor2tensor/utils/quantization.py
def simulated_quantize(x, num_bits, noise): """Simulate quantization to num_bits bits, with externally-stored scale. num_bits is the number of bits used to store each value. noise is a float32 Tensor containing values in [0, 1). Each value in noise should take different values across different steps, approxi...
def simulated_quantize(x, num_bits, noise): """Simulate quantization to num_bits bits, with externally-stored scale. num_bits is the number of bits used to store each value. noise is a float32 Tensor containing values in [0, 1). Each value in noise should take different values across different steps, approxi...
[ "Simulate", "quantization", "to", "num_bits", "bits", "with", "externally", "-", "stored", "scale", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L89-L134
[ "def", "simulated_quantize", "(", "x", ",", "num_bits", ",", "noise", ")", ":", "shape", "=", "x", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "if", "not", "(", "len", "(", "shape", ")", ">=", "2", "and", "shape", "[", "-", "1", "]", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
noise_from_step_num
Quantization noise equal to (phi * (step_num + 1)) mod 1.0. Not using random_uniform here due to a problem on TPU in that random seeds are not respected, which may cause the parameters on different replicas to go out-of-sync. Returns: a float32 scalar
tensor2tensor/utils/quantization.py
def noise_from_step_num(): """Quantization noise equal to (phi * (step_num + 1)) mod 1.0. Not using random_uniform here due to a problem on TPU in that random seeds are not respected, which may cause the parameters on different replicas to go out-of-sync. Returns: a float32 scalar """ step = tf.to_i...
def noise_from_step_num(): """Quantization noise equal to (phi * (step_num + 1)) mod 1.0. Not using random_uniform here due to a problem on TPU in that random seeds are not respected, which may cause the parameters on different replicas to go out-of-sync. Returns: a float32 scalar """ step = tf.to_i...
[ "Quantization", "noise", "equal", "to", "(", "phi", "*", "(", "step_num", "+", "1", "))", "mod", "1", ".", "0", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L137-L157
[ "def", "noise_from_step_num", "(", ")", ":", "step", "=", "tf", ".", "to_int32", "(", "tf", ".", "train", ".", "get_or_create_global_step", "(", ")", ")", "+", "1", "phi", "=", "(", "(", "5", "**", "0.5", ")", "-", "1", ")", "/", "2", "# Naive comp...
272500b6efe353aeb638d2745ed56e519462ca31
train
_randomized_roundoff_to_bfloat16
Round-off x to cand1 or to cand2 in an unbiased way. Cand1 and cand2 are the same shape as x. For every element of x, the corresponding elements of cand1 and cand2 should be the two closest bfloat16 values to x. Order does not matter. cand1 and cand2 must differ from each other. Args: x: A float32 Tens...
tensor2tensor/utils/quantization.py
def _randomized_roundoff_to_bfloat16(x, noise, cand1, cand2): """Round-off x to cand1 or to cand2 in an unbiased way. Cand1 and cand2 are the same shape as x. For every element of x, the corresponding elements of cand1 and cand2 should be the two closest bfloat16 values to x. Order does not matter. cand1 an...
def _randomized_roundoff_to_bfloat16(x, noise, cand1, cand2): """Round-off x to cand1 or to cand2 in an unbiased way. Cand1 and cand2 are the same shape as x. For every element of x, the corresponding elements of cand1 and cand2 should be the two closest bfloat16 values to x. Order does not matter. cand1 an...
[ "Round", "-", "off", "x", "to", "cand1", "or", "to", "cand2", "in", "an", "unbiased", "way", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L160-L183
[ "def", "_randomized_roundoff_to_bfloat16", "(", "x", ",", "noise", ",", "cand1", ",", "cand2", ")", ":", "cand1_f", "=", "tf", ".", "to_float", "(", "cand1", ")", "cand2_f", "=", "tf", ".", "to_float", "(", "cand2", ")", "step_size", "=", "cand2_f", "-",...
272500b6efe353aeb638d2745ed56e519462ca31
train
_to_bfloat16_unbiased
Convert a float32 to a bfloat16 using randomized roundoff. Args: x: A float32 Tensor. noise: a float32 Tensor with values in [0, 1), broadcastable to tf.shape(x) Returns: A float32 Tensor.
tensor2tensor/utils/quantization.py
def _to_bfloat16_unbiased(x, noise): """Convert a float32 to a bfloat16 using randomized roundoff. Args: x: A float32 Tensor. noise: a float32 Tensor with values in [0, 1), broadcastable to tf.shape(x) Returns: A float32 Tensor. """ x_sign = tf.sign(x) # Make sure x is positive. If it is zero,...
def _to_bfloat16_unbiased(x, noise): """Convert a float32 to a bfloat16 using randomized roundoff. Args: x: A float32 Tensor. noise: a float32 Tensor with values in [0, 1), broadcastable to tf.shape(x) Returns: A float32 Tensor. """ x_sign = tf.sign(x) # Make sure x is positive. If it is zero,...
[ "Convert", "a", "float32", "to", "a", "bfloat16", "using", "randomized", "roundoff", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L186-L206
[ "def", "_to_bfloat16_unbiased", "(", "x", ",", "noise", ")", ":", "x_sign", "=", "tf", ".", "sign", "(", "x", ")", "# Make sure x is positive. If it is zero, the two candidates are identical.", "x", "=", "x", "*", "x_sign", "+", "1e-30", "cand1", "=", "tf", "."...
272500b6efe353aeb638d2745ed56e519462ca31
train
ParameterEncoding.custom_getter
A custom getter that uses the encoding for bfloat16 and float32 vars. When a bfloat16 or float32 variable is requsted, an encoded float16 varaible is created, which is then decoded and cast to a bfloat16 activation. Args: activation_dtype: a dtype to which to convert the decoded value. Retu...
tensor2tensor/utils/quantization.py
def custom_getter(self, activation_dtype=tf.bfloat16): """A custom getter that uses the encoding for bfloat16 and float32 vars. When a bfloat16 or float32 variable is requsted, an encoded float16 varaible is created, which is then decoded and cast to a bfloat16 activation. Args: activation_d...
def custom_getter(self, activation_dtype=tf.bfloat16): """A custom getter that uses the encoding for bfloat16 and float32 vars. When a bfloat16 or float32 variable is requsted, an encoded float16 varaible is created, which is then decoded and cast to a bfloat16 activation. Args: activation_d...
[ "A", "custom", "getter", "that", "uses", "the", "encoding", "for", "bfloat16", "and", "float32", "vars", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/quantization.py#L246-L268
[ "def", "custom_getter", "(", "self", ",", "activation_dtype", "=", "tf", ".", "bfloat16", ")", ":", "def", "getter_fn", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "requested_dtype", "=", "kwargs", "[", "\"dtype\"", "]", "if", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
load_videos
Loads videos from files. Args: template: template string for listing the image files. video_length: length of the video. frame_shape: shape of each frame. Returns: dataset: the tf dataset frame by frame. dataset_len: number of the items which is the number of image files. Raises: ValueE...
tensor2tensor/utils/video_metrics.py
def load_videos(template, video_length, frame_shape): """Loads videos from files. Args: template: template string for listing the image files. video_length: length of the video. frame_shape: shape of each frame. Returns: dataset: the tf dataset frame by frame. dataset_len: number of the item...
def load_videos(template, video_length, frame_shape): """Loads videos from files. Args: template: template string for listing the image files. video_length: length of the video. frame_shape: shape of each frame. Returns: dataset: the tf dataset frame by frame. dataset_len: number of the item...
[ "Loads", "videos", "from", "files", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L38-L63
[ "def", "load_videos", "(", "template", ",", "video_length", ",", "frame_shape", ")", ":", "filenames", "=", "tf", ".", "gfile", ".", "Glob", "(", "template", ")", "if", "not", "filenames", ":", "raise", "ValueError", "(", "\"no files found.\"", ")", "filenam...
272500b6efe353aeb638d2745ed56e519462ca31
train
psnr_and_ssim
Compute the PSNR and SSIM. Args: output: 4-D Tensor, shape=(num_frames, height, width, num_channels) target: 4-D Tensor, shape=(num_frames, height, width, num_channels) Returns: psnr: 1-D Tensor, shape=(num_frames,) ssim: 1-D Tensor, shape=(num_frames,)
tensor2tensor/utils/video_metrics.py
def psnr_and_ssim(output, target): """Compute the PSNR and SSIM. Args: output: 4-D Tensor, shape=(num_frames, height, width, num_channels) target: 4-D Tensor, shape=(num_frames, height, width, num_channels) Returns: psnr: 1-D Tensor, shape=(num_frames,) ssim: 1-D Tensor, shape=(num_frames,) """...
def psnr_and_ssim(output, target): """Compute the PSNR and SSIM. Args: output: 4-D Tensor, shape=(num_frames, height, width, num_channels) target: 4-D Tensor, shape=(num_frames, height, width, num_channels) Returns: psnr: 1-D Tensor, shape=(num_frames,) ssim: 1-D Tensor, shape=(num_frames,) """...
[ "Compute", "the", "PSNR", "and", "SSIM", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L93-L107
[ "def", "psnr_and_ssim", "(", "output", ",", "target", ")", ":", "output", "=", "tf", ".", "cast", "(", "output", ",", "dtype", "=", "tf", ".", "int32", ")", "target", "=", "tf", ".", "cast", "(", "target", ",", "dtype", "=", "tf", ".", "int32", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
get_zipped_dataset_from_predictions
Creates dataset from in-memory predictions.
tensor2tensor/utils/video_metrics.py
def get_zipped_dataset_from_predictions(predictions): """Creates dataset from in-memory predictions.""" targets = stack_data_given_key(predictions, "targets") outputs = stack_data_given_key(predictions, "outputs") num_videos, num_steps = targets.shape[:2] # Truncate output time-steps to match target time-ste...
def get_zipped_dataset_from_predictions(predictions): """Creates dataset from in-memory predictions.""" targets = stack_data_given_key(predictions, "targets") outputs = stack_data_given_key(predictions, "outputs") num_videos, num_steps = targets.shape[:2] # Truncate output time-steps to match target time-ste...
[ "Creates", "dataset", "from", "in", "-", "memory", "predictions", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L116-L132
[ "def", "get_zipped_dataset_from_predictions", "(", "predictions", ")", ":", "targets", "=", "stack_data_given_key", "(", "predictions", ",", "\"targets\"", ")", "outputs", "=", "stack_data_given_key", "(", "predictions", ",", "\"outputs\"", ")", "num_videos", ",", "nu...
272500b6efe353aeb638d2745ed56e519462ca31
train
compute_one_decoding_video_metrics
Computes the average of all the metric for one decoding. Args: iterator: dataset iterator. feed_dict: feed dict to initialize iterator. num_videos: number of videos. Returns: all_psnr: 2-D Numpy array, shape=(num_samples, num_frames) all_ssim: 2-D Numpy array, shape=(num_samples, num_frames)
tensor2tensor/utils/video_metrics.py
def compute_one_decoding_video_metrics(iterator, feed_dict, num_videos): """Computes the average of all the metric for one decoding. Args: iterator: dataset iterator. feed_dict: feed dict to initialize iterator. num_videos: number of videos. Returns: all_psnr: 2-D Numpy array, shape=(num_samples...
def compute_one_decoding_video_metrics(iterator, feed_dict, num_videos): """Computes the average of all the metric for one decoding. Args: iterator: dataset iterator. feed_dict: feed dict to initialize iterator. num_videos: number of videos. Returns: all_psnr: 2-D Numpy array, shape=(num_samples...
[ "Computes", "the", "average", "of", "all", "the", "metric", "for", "one", "decoding", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L135-L164
[ "def", "compute_one_decoding_video_metrics", "(", "iterator", ",", "feed_dict", ",", "num_videos", ")", ":", "output", ",", "target", "=", "iterator", ".", "get_next", "(", ")", "metrics", "=", "psnr_and_ssim", "(", "output", ",", "target", ")", "with", "tf", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
reduce_to_best_decode
Extracts the best-decode from the metrics according to reduce_func. Args: metrics: 3-D numpy array, shape=(num_decodes, num_samples, num_frames) reduce_func: callable, np.argmax or np.argmin. Returns: best_metrics: 2-D numpy array, shape=(num_samples, num_frames). best_decode_ind: 1-D numpy array, ...
tensor2tensor/utils/video_metrics.py
def reduce_to_best_decode(metrics, reduce_func): """Extracts the best-decode from the metrics according to reduce_func. Args: metrics: 3-D numpy array, shape=(num_decodes, num_samples, num_frames) reduce_func: callable, np.argmax or np.argmin. Returns: best_metrics: 2-D numpy array, shape=(num_sample...
def reduce_to_best_decode(metrics, reduce_func): """Extracts the best-decode from the metrics according to reduce_func. Args: metrics: 3-D numpy array, shape=(num_decodes, num_samples, num_frames) reduce_func: callable, np.argmax or np.argmin. Returns: best_metrics: 2-D numpy array, shape=(num_sample...
[ "Extracts", "the", "best", "-", "decode", "from", "the", "metrics", "according", "to", "reduce_func", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L167-L185
[ "def", "reduce_to_best_decode", "(", "metrics", ",", "reduce_func", ")", ":", "num_videos", "=", "metrics", ".", "shape", "[", "1", "]", "# Take mean of the metric across the frames to approximate the video", "# closest to the ground truth.", "mean_across_frames", "=", "np", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
compute_all_metrics_statistics
Computes statistics of metrics across multiple decodings. Args: all_results: dict of 3-D numpy arrays. Each array has shape=(num_decodes, num_samples, num_frames). Returns: statistics: dict of 1-D numpy arrays, shape=(num_frames). First the statistic (max/mean/std) is compu...
tensor2tensor/utils/video_metrics.py
def compute_all_metrics_statistics(all_results): """Computes statistics of metrics across multiple decodings. Args: all_results: dict of 3-D numpy arrays. Each array has shape=(num_decodes, num_samples, num_frames). Returns: statistics: dict of 1-D numpy arrays, shape=(num_frames). ...
def compute_all_metrics_statistics(all_results): """Computes statistics of metrics across multiple decodings. Args: all_results: dict of 3-D numpy arrays. Each array has shape=(num_decodes, num_samples, num_frames). Returns: statistics: dict of 1-D numpy arrays, shape=(num_frames). ...
[ "Computes", "statistics", "of", "metrics", "across", "multiple", "decodings", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L188-L220
[ "def", "compute_all_metrics_statistics", "(", "all_results", ")", ":", "statistics", "=", "{", "}", "decode_inds", "=", "{", "}", "all_metrics", "=", "all_results", ".", "keys", "(", ")", "for", "key", "in", "all_metrics", ":", "values", "=", "all_results", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
compute_video_metrics_from_predictions
Computes metrics from predictions. Args: predictions: list of list of dicts. outer length: num_decodes, inner_length: num_samples decode_hparams: Decode hparams. instance of HParams. Returns: statistics: dict of Tensors, key being the metric with each Tensor having the ...
tensor2tensor/utils/video_metrics.py
def compute_video_metrics_from_predictions(predictions, decode_hparams): """Computes metrics from predictions. Args: predictions: list of list of dicts. outer length: num_decodes, inner_length: num_samples decode_hparams: Decode hparams. instance of HParams. Returns: statistics: dict...
def compute_video_metrics_from_predictions(predictions, decode_hparams): """Computes metrics from predictions. Args: predictions: list of list of dicts. outer length: num_decodes, inner_length: num_samples decode_hparams: Decode hparams. instance of HParams. Returns: statistics: dict...
[ "Computes", "metrics", "from", "predictions", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L223-L246
[ "def", "compute_video_metrics_from_predictions", "(", "predictions", ",", "decode_hparams", ")", ":", "all_results", "=", "{", "}", "ssim_all_decodes", ",", "psnr_all_decodes", "=", "[", "]", ",", "[", "]", "for", "single_decode", "in", "predictions", ":", "args",...
272500b6efe353aeb638d2745ed56e519462ca31
train
compute_video_metrics_from_png_files
Computes the average of all the metric for one decoding. This function assumes that all the predicted and target frames have been saved on the disk and sorting them by name will result to consecutive frames saved in order. Args: output_dirs: directory with all the saved frames. problem_name: prefix of...
tensor2tensor/utils/video_metrics.py
def compute_video_metrics_from_png_files( output_dirs, problem_name, video_length, frame_shape): """Computes the average of all the metric for one decoding. This function assumes that all the predicted and target frames have been saved on the disk and sorting them by name will result to consecutive frames ...
def compute_video_metrics_from_png_files( output_dirs, problem_name, video_length, frame_shape): """Computes the average of all the metric for one decoding. This function assumes that all the predicted and target frames have been saved on the disk and sorting them by name will result to consecutive frames ...
[ "Computes", "the", "average", "of", "all", "the", "metric", "for", "one", "decoding", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L249-L279
[ "def", "compute_video_metrics_from_png_files", "(", "output_dirs", ",", "problem_name", ",", "video_length", ",", "frame_shape", ")", ":", "ssim_all_decodes", ",", "psnr_all_decodes", "=", "[", "]", ",", "[", "]", "for", "output_dir", "in", "output_dirs", ":", "ou...
272500b6efe353aeb638d2745ed56e519462ca31
train
compute_and_save_video_metrics
Compute and saves the video metrics.
tensor2tensor/utils/video_metrics.py
def compute_and_save_video_metrics( output_dirs, problem_name, video_length, frame_shape): """Compute and saves the video metrics.""" statistics, all_results = compute_video_metrics_from_png_files( output_dirs, problem_name, video_length, frame_shape) for results, output_dir in zip(all_results, output_d...
def compute_and_save_video_metrics( output_dirs, problem_name, video_length, frame_shape): """Compute and saves the video metrics.""" statistics, all_results = compute_video_metrics_from_png_files( output_dirs, problem_name, video_length, frame_shape) for results, output_dir in zip(all_results, output_d...
[ "Compute", "and", "saves", "the", "video", "metrics", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/video_metrics.py#L282-L294
[ "def", "compute_and_save_video_metrics", "(", "output_dirs", ",", "problem_name", ",", "video_length", ",", "frame_shape", ")", ":", "statistics", ",", "all_results", "=", "compute_video_metrics_from_png_files", "(", "output_dirs", ",", "problem_name", ",", "video_length"...
272500b6efe353aeb638d2745ed56e519462ca31
train
swap_time_and_batch_axes
Swaps time and batch axis (the first two axis).
tensor2tensor/layers/common_video.py
def swap_time_and_batch_axes(inputs): """Swaps time and batch axis (the first two axis).""" transposed_axes = tf.concat([[1, 0], tf.range(2, tf.rank(inputs))], axis=0) return tf.transpose(inputs, transposed_axes)
def swap_time_and_batch_axes(inputs): """Swaps time and batch axis (the first two axis).""" transposed_axes = tf.concat([[1, 0], tf.range(2, tf.rank(inputs))], axis=0) return tf.transpose(inputs, transposed_axes)
[ "Swaps", "time", "and", "batch", "axis", "(", "the", "first", "two", "axis", ")", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L41-L44
[ "def", "swap_time_and_batch_axes", "(", "inputs", ")", ":", "transposed_axes", "=", "tf", ".", "concat", "(", "[", "[", "1", ",", "0", "]", ",", "tf", ".", "range", "(", "2", ",", "tf", ".", "rank", "(", "inputs", ")", ")", "]", ",", "axis", "=",...
272500b6efe353aeb638d2745ed56e519462ca31
train
encode_to_shape
Encode the given tensor to given image shape.
tensor2tensor/layers/common_video.py
def encode_to_shape(inputs, shape, scope): """Encode the given tensor to given image shape.""" with tf.variable_scope(scope, reuse=tf.AUTO_REUSE): w, h = shape[1], shape[2] x = inputs x = tfl.flatten(x) x = tfl.dense(x, w * h, activation=None, name="enc_dense") x = tf.reshape(x, (-1, w, h, 1)) ...
def encode_to_shape(inputs, shape, scope): """Encode the given tensor to given image shape.""" with tf.variable_scope(scope, reuse=tf.AUTO_REUSE): w, h = shape[1], shape[2] x = inputs x = tfl.flatten(x) x = tfl.dense(x, w * h, activation=None, name="enc_dense") x = tf.reshape(x, (-1, w, h, 1)) ...
[ "Encode", "the", "given", "tensor", "to", "given", "image", "shape", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L47-L55
[ "def", "encode_to_shape", "(", "inputs", ",", "shape", ",", "scope", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "w", ",", "h", "=", "shape", "[", "1", "]", ",", "shape", "[", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
decode_to_shape
Encode the given tensor to given image shape.
tensor2tensor/layers/common_video.py
def decode_to_shape(inputs, shape, scope): """Encode the given tensor to given image shape.""" with tf.variable_scope(scope, reuse=tf.AUTO_REUSE): x = inputs x = tfl.flatten(x) x = tfl.dense(x, shape[2], activation=None, name="dec_dense") x = tf.expand_dims(x, axis=1) return x
def decode_to_shape(inputs, shape, scope): """Encode the given tensor to given image shape.""" with tf.variable_scope(scope, reuse=tf.AUTO_REUSE): x = inputs x = tfl.flatten(x) x = tfl.dense(x, shape[2], activation=None, name="dec_dense") x = tf.expand_dims(x, axis=1) return x
[ "Encode", "the", "given", "tensor", "to", "given", "image", "shape", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L58-L65
[ "def", "decode_to_shape", "(", "inputs", ",", "shape", ",", "scope", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "x", "=", "inputs", "x", "=", "tfl", ".", "flatten", "(", "x", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
basic_lstm
Basic LSTM.
tensor2tensor/layers/common_video.py
def basic_lstm(inputs, state, num_units, name=None): """Basic LSTM.""" input_shape = common_layers.shape_list(inputs) # reuse parameters across time-steps. cell = tf.nn.rnn_cell.BasicLSTMCell( num_units, name=name, reuse=tf.AUTO_REUSE) if state is None: state = cell.zero_state(input_shape[0], tf.flo...
def basic_lstm(inputs, state, num_units, name=None): """Basic LSTM.""" input_shape = common_layers.shape_list(inputs) # reuse parameters across time-steps. cell = tf.nn.rnn_cell.BasicLSTMCell( num_units, name=name, reuse=tf.AUTO_REUSE) if state is None: state = cell.zero_state(input_shape[0], tf.flo...
[ "Basic", "LSTM", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L68-L77
[ "def", "basic_lstm", "(", "inputs", ",", "state", ",", "num_units", ",", "name", "=", "None", ")", ":", "input_shape", "=", "common_layers", ".", "shape_list", "(", "inputs", ")", "# reuse parameters across time-steps.", "cell", "=", "tf", ".", "nn", ".", "r...
272500b6efe353aeb638d2745ed56e519462ca31
train
lstm_cell
Full LSTM cell.
tensor2tensor/layers/common_video.py
def lstm_cell(inputs, state, num_units, use_peepholes=False, cell_clip=0.0, initializer=None, num_proj=None, num_unit_shards=None, num_proj_shards=None, reuse=None, name=None): "...
def lstm_cell(inputs, state, num_units, use_peepholes=False, cell_clip=0.0, initializer=None, num_proj=None, num_unit_shards=None, num_proj_shards=None, reuse=None, name=None): "...
[ "Full", "LSTM", "cell", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L80-L106
[ "def", "lstm_cell", "(", "inputs", ",", "state", ",", "num_units", ",", "use_peepholes", "=", "False", ",", "cell_clip", "=", "0.0", ",", "initializer", "=", "None", ",", "num_proj", "=", "None", ",", "num_unit_shards", "=", "None", ",", "num_proj_shards", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
conv_lstm_2d
2D Convolutional LSTM.
tensor2tensor/layers/common_video.py
def conv_lstm_2d(inputs, state, output_channels, kernel_size=5, name=None, spatial_dims=None): """2D Convolutional LSTM.""" input_shape = common_layers.shape_list(inputs) batch_size, input_channels = input_shape[0], input_shape[-1] if spatial_dims is None: input_shape = input_shape[1:] el...
def conv_lstm_2d(inputs, state, output_channels, kernel_size=5, name=None, spatial_dims=None): """2D Convolutional LSTM.""" input_shape = common_layers.shape_list(inputs) batch_size, input_channels = input_shape[0], input_shape[-1] if spatial_dims is None: input_shape = input_shape[1:] el...
[ "2D", "Convolutional", "LSTM", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L109-L125
[ "def", "conv_lstm_2d", "(", "inputs", ",", "state", ",", "output_channels", ",", "kernel_size", "=", "5", ",", "name", "=", "None", ",", "spatial_dims", "=", "None", ")", ":", "input_shape", "=", "common_layers", ".", "shape_list", "(", "inputs", ")", "bat...
272500b6efe353aeb638d2745ed56e519462ca31
train
scheduled_sample_count
Sample batch with specified mix of groundtruth and generated data points. Args: ground_truth_x: tensor of ground-truth data points. generated_x: tensor of generated data points. batch_size: batch size scheduled_sample_var: number of ground-truth examples to include in batch. Returns: New batch ...
tensor2tensor/layers/common_video.py
def scheduled_sample_count(ground_truth_x, generated_x, batch_size, scheduled_sample_var): """Sample batch with specified mix of groundtruth and generated data points. Args: ground_truth_x: tensor of ground-truth data points. ...
def scheduled_sample_count(ground_truth_x, generated_x, batch_size, scheduled_sample_var): """Sample batch with specified mix of groundtruth and generated data points. Args: ground_truth_x: tensor of ground-truth data points. ...
[ "Sample", "batch", "with", "specified", "mix", "of", "groundtruth", "and", "generated", "data", "points", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L128-L156
[ "def", "scheduled_sample_count", "(", "ground_truth_x", ",", "generated_x", ",", "batch_size", ",", "scheduled_sample_var", ")", ":", "num_ground_truth", "=", "scheduled_sample_var", "idx", "=", "tf", ".", "random_shuffle", "(", "tf", ".", "range", "(", "batch_size"...
272500b6efe353aeb638d2745ed56e519462ca31
train
inject_additional_input
Injects the additional input into the layer. Args: layer: layer that the input should be injected to. inputs: inputs to be injected. name: TF scope name. mode: how the infor should be added to the layer: "concat" concats as additional channels. "multiplicative" broadcasts inputs and multi...
tensor2tensor/layers/common_video.py
def inject_additional_input(layer, inputs, name, mode="concat"): """Injects the additional input into the layer. Args: layer: layer that the input should be injected to. inputs: inputs to be injected. name: TF scope name. mode: how the infor should be added to the layer: "concat" concats as a...
def inject_additional_input(layer, inputs, name, mode="concat"): """Injects the additional input into the layer. Args: layer: layer that the input should be injected to. inputs: inputs to be injected. name: TF scope name. mode: how the infor should be added to the layer: "concat" concats as a...
[ "Injects", "the", "additional", "input", "into", "the", "layer", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L159-L199
[ "def", "inject_additional_input", "(", "layer", ",", "inputs", ",", "name", ",", "mode", "=", "\"concat\"", ")", ":", "layer_shape", "=", "common_layers", ".", "shape_list", "(", "layer", ")", "input_shape", "=", "common_layers", ".", "shape_list", "(", "input...
272500b6efe353aeb638d2745ed56e519462ca31
train
scheduled_sample_prob
Probability based scheduled sampling. Args: ground_truth_x: tensor of ground-truth data points. generated_x: tensor of generated data points. batch_size: batch size scheduled_sample_var: probability of choosing from ground_truth. Returns: New batch with randomly selected data points.
tensor2tensor/layers/common_video.py
def scheduled_sample_prob(ground_truth_x, generated_x, batch_size, scheduled_sample_var): """Probability based scheduled sampling. Args: ground_truth_x: tensor of ground-truth data points. generated_x: tensor of generated data po...
def scheduled_sample_prob(ground_truth_x, generated_x, batch_size, scheduled_sample_var): """Probability based scheduled sampling. Args: ground_truth_x: tensor of ground-truth data points. generated_x: tensor of generated data po...
[ "Probability", "based", "scheduled", "sampling", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L202-L219
[ "def", "scheduled_sample_prob", "(", "ground_truth_x", ",", "generated_x", ",", "batch_size", ",", "scheduled_sample_var", ")", ":", "probability_threshold", "=", "scheduled_sample_var", "probability_of_generated", "=", "tf", ".", "random_uniform", "(", "[", "batch_size",...
272500b6efe353aeb638d2745ed56e519462ca31
train
dna_transformation
Apply dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. dna_input: hidden lyaer to be used for computing DNA transformation. dna_kernel_size: dna kernel size. relu_shift: shift for ReLU function. Returns: List of images transformed by the predicted ...
tensor2tensor/layers/common_video.py
def dna_transformation(prev_image, dna_input, dna_kernel_size, relu_shift): """Apply dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. dna_input: hidden lyaer to be used for computing DNA transformation. dna_kernel_size: dna kernel size. relu_shift: shi...
def dna_transformation(prev_image, dna_input, dna_kernel_size, relu_shift): """Apply dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. dna_input: hidden lyaer to be used for computing DNA transformation. dna_kernel_size: dna kernel size. relu_shift: shi...
[ "Apply", "dynamic", "neural", "advection", "to", "previous", "image", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L222-L251
[ "def", "dna_transformation", "(", "prev_image", ",", "dna_input", ",", "dna_kernel_size", ",", "relu_shift", ")", ":", "# Construct translated images.", "prev_image_pad", "=", "tf", ".", "pad", "(", "prev_image", ",", "[", "[", "0", ",", "0", "]", ",", "[", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
cdna_transformation
Apply convolutional dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. cdna_input: hidden lyaer to be used for computing CDNA kernels. num_masks: number of masks and hence the number of CDNA transformations. color_channels: the number of color channels in ...
tensor2tensor/layers/common_video.py
def cdna_transformation(prev_image, cdna_input, num_masks, color_channels, dna_kernel_size, relu_shift): """Apply convolutional dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. cdna_input: hidden lyaer to be used for computing CDNA kern...
def cdna_transformation(prev_image, cdna_input, num_masks, color_channels, dna_kernel_size, relu_shift): """Apply convolutional dynamic neural advection to previous image. Args: prev_image: previous image to be transformed. cdna_input: hidden lyaer to be used for computing CDNA kern...
[ "Apply", "convolutional", "dynamic", "neural", "advection", "to", "previous", "image", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L254-L304
[ "def", "cdna_transformation", "(", "prev_image", ",", "cdna_input", ",", "num_masks", ",", "color_channels", ",", "dna_kernel_size", ",", "relu_shift", ")", ":", "batch_size", "=", "tf", ".", "shape", "(", "cdna_input", ")", "[", "0", "]", "height", "=", "in...
272500b6efe353aeb638d2745ed56e519462ca31
train
vgg_layer
A layer of VGG network with batch norm. Args: inputs: image tensor nout: number of output channels kernel_size: size of the kernel activation: activation function padding: padding of the image is_training: whether it is training mode or not has_batchnorm: whether batchnorm is applied or n...
tensor2tensor/layers/common_video.py
def vgg_layer(inputs, nout, kernel_size=3, activation=tf.nn.leaky_relu, padding="SAME", is_training=True, has_batchnorm=False, scope=None): """A layer of VGG network with batch norm. Args: inputs: image tensor ...
def vgg_layer(inputs, nout, kernel_size=3, activation=tf.nn.leaky_relu, padding="SAME", is_training=True, has_batchnorm=False, scope=None): """A layer of VGG network with batch norm. Args: inputs: image tensor ...
[ "A", "layer", "of", "VGG", "network", "with", "batch", "norm", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L307-L335
[ "def", "vgg_layer", "(", "inputs", ",", "nout", ",", "kernel_size", "=", "3", ",", "activation", "=", "tf", ".", "nn", ".", "leaky_relu", ",", "padding", "=", "\"SAME\"", ",", "is_training", "=", "True", ",", "has_batchnorm", "=", "False", ",", "scope", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
tile_and_concat
Tile latent and concatenate to image across depth. Args: image: 4-D Tensor, (batch_size X height X width X channels) latent: 2-D Tensor, (batch_size X latent_dims) concat_latent: If set to False, the image is returned as is. Returns: concat_latent: 4-D Tensor, (batch_size X height X width X channe...
tensor2tensor/layers/common_video.py
def tile_and_concat(image, latent, concat_latent=True): """Tile latent and concatenate to image across depth. Args: image: 4-D Tensor, (batch_size X height X width X channels) latent: 2-D Tensor, (batch_size X latent_dims) concat_latent: If set to False, the image is returned as is. Returns: con...
def tile_and_concat(image, latent, concat_latent=True): """Tile latent and concatenate to image across depth. Args: image: 4-D Tensor, (batch_size X height X width X channels) latent: 2-D Tensor, (batch_size X latent_dims) concat_latent: If set to False, the image is returned as is. Returns: con...
[ "Tile", "latent", "and", "concatenate", "to", "image", "across", "depth", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L338-L361
[ "def", "tile_and_concat", "(", "image", ",", "latent", ",", "concat_latent", "=", "True", ")", ":", "if", "not", "concat_latent", ":", "return", "image", "image_shape", "=", "common_layers", ".", "shape_list", "(", "image", ")", "latent_shape", "=", "common_la...
272500b6efe353aeb638d2745ed56e519462ca31
train
_encode_gif
Encodes numpy images into gif string. Args: images: A 4-D `uint8` `np.array` (or a list of 3-D images) of shape `[time, height, width, channels]` where `channels` is 1 or 3. fps: frames per second of the animation Returns: The encoded gif string. Raises: IOError: If the ffmpeg command ret...
tensor2tensor/layers/common_video.py
def _encode_gif(images, fps): """Encodes numpy images into gif string. Args: images: A 4-D `uint8` `np.array` (or a list of 3-D images) of shape `[time, height, width, channels]` where `channels` is 1 or 3. fps: frames per second of the animation Returns: The encoded gif string. Raises: ...
def _encode_gif(images, fps): """Encodes numpy images into gif string. Args: images: A 4-D `uint8` `np.array` (or a list of 3-D images) of shape `[time, height, width, channels]` where `channels` is 1 or 3. fps: frames per second of the animation Returns: The encoded gif string. Raises: ...
[ "Encodes", "numpy", "images", "into", "gif", "string", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L364-L380
[ "def", "_encode_gif", "(", "images", ",", "fps", ")", ":", "writer", "=", "WholeVideoWriter", "(", "fps", ")", "writer", ".", "write_multi", "(", "images", ")", "return", "writer", ".", "finish", "(", ")" ]
272500b6efe353aeb638d2745ed56e519462ca31
train
ffmpeg_works
Tries to encode images with ffmpeg to check if it works.
tensor2tensor/layers/common_video.py
def ffmpeg_works(): """Tries to encode images with ffmpeg to check if it works.""" images = np.zeros((2, 32, 32, 3), dtype=np.uint8) try: _encode_gif(images, 2) return True except (IOError, OSError): return False
def ffmpeg_works(): """Tries to encode images with ffmpeg to check if it works.""" images = np.zeros((2, 32, 32, 3), dtype=np.uint8) try: _encode_gif(images, 2) return True except (IOError, OSError): return False
[ "Tries", "to", "encode", "images", "with", "ffmpeg", "to", "check", "if", "it", "works", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L383-L390
[ "def", "ffmpeg_works", "(", ")", ":", "images", "=", "np", ".", "zeros", "(", "(", "2", ",", "32", ",", "32", ",", "3", ")", ",", "dtype", "=", "np", ".", "uint8", ")", "try", ":", "_encode_gif", "(", "images", ",", "2", ")", "return", "True", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
py_gif_summary
Outputs a `Summary` protocol buffer with gif animations. Args: tag: Name of the summary. images: A 5-D `uint8` `np.array` of shape `[batch_size, time, height, width, channels]` where `channels` is 1 or 3. max_outputs: Max number of batch elements to generate gifs for. fps: frames per second of ...
tensor2tensor/layers/common_video.py
def py_gif_summary(tag, images, max_outputs, fps, return_summary_value=False): """Outputs a `Summary` protocol buffer with gif animations. Args: tag: Name of the summary. images: A 5-D `uint8` `np.array` of shape `[batch_size, time, height, width, channels]` where `channels` is 1 or 3. max_output...
def py_gif_summary(tag, images, max_outputs, fps, return_summary_value=False): """Outputs a `Summary` protocol buffer with gif animations. Args: tag: Name of the summary. images: A 5-D `uint8` `np.array` of shape `[batch_size, time, height, width, channels]` where `channels` is 1 or 3. max_output...
[ "Outputs", "a", "Summary", "protocol", "buffer", "with", "gif", "animations", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L393-L455
[ "def", "py_gif_summary", "(", "tag", ",", "images", ",", "max_outputs", ",", "fps", ",", "return_summary_value", "=", "False", ")", ":", "images", "=", "np", ".", "asarray", "(", "images", ")", "if", "images", ".", "dtype", "!=", "np", ".", "uint8", ":...
272500b6efe353aeb638d2745ed56e519462ca31
train
gif_summary
Outputs a `Summary` protocol buffer with gif animations. Args: name: Name of the summary. tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width, channels]` where `channels` is 1 or 3. max_outputs: Max number of batch elements to generate gifs for. fps: frames per second of t...
tensor2tensor/layers/common_video.py
def gif_summary(name, tensor, max_outputs=3, fps=10, collections=None, family=None): """Outputs a `Summary` protocol buffer with gif animations. Args: name: Name of the summary. tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width, channels]` where `channels` is 1...
def gif_summary(name, tensor, max_outputs=3, fps=10, collections=None, family=None): """Outputs a `Summary` protocol buffer with gif animations. Args: name: Name of the summary. tensor: A 5-D `uint8` `Tensor` of shape `[batch_size, time, height, width, channels]` where `channels` is 1...
[ "Outputs", "a", "Summary", "protocol", "buffer", "with", "gif", "animations", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L458-L497
[ "def", "gif_summary", "(", "name", ",", "tensor", ",", "max_outputs", "=", "3", ",", "fps", "=", "10", ",", "collections", "=", "None", ",", "family", "=", "None", ")", ":", "tensor", "=", "tf", ".", "convert_to_tensor", "(", "tensor", ")", "if", "le...
272500b6efe353aeb638d2745ed56e519462ca31
train
conv_latent_tower
Builds convolutional latent tower for stochastic model. At training time this tower generates a latent distribution (mean and std) conditioned on the entire video. This latent variable will be fed to the main tower as an extra variable to be used for future frames prediction. At inference time, the tower is di...
tensor2tensor/layers/common_video.py
def conv_latent_tower(images, time_axis, latent_channels=1, min_logvar=-5, is_training=False, random_latent=False, tiny_mode=False, small_mode=False): """Builds convolutional latent tower for stochastic model. At training time this tower generates a latent distribution (...
def conv_latent_tower(images, time_axis, latent_channels=1, min_logvar=-5, is_training=False, random_latent=False, tiny_mode=False, small_mode=False): """Builds convolutional latent tower for stochastic model. At training time this tower generates a latent distribution (...
[ "Builds", "convolutional", "latent", "tower", "for", "stochastic", "model", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L516-L582
[ "def", "conv_latent_tower", "(", "images", ",", "time_axis", ",", "latent_channels", "=", "1", ",", "min_logvar", "=", "-", "5", ",", "is_training", "=", "False", ",", "random_latent", "=", "False", ",", "tiny_mode", "=", "False", ",", "small_mode", "=", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
beta_schedule
Get KL multiplier (beta) based on the schedule.
tensor2tensor/layers/common_video.py
def beta_schedule(schedule, global_step, final_beta, decay_start, decay_end): """Get KL multiplier (beta) based on the schedule.""" if decay_start > decay_end: raise ValueError("decay_end is smaller than decay_end.") # Since some of the TF schedules do not support incrementing a value, # in all of the sche...
def beta_schedule(schedule, global_step, final_beta, decay_start, decay_end): """Get KL multiplier (beta) based on the schedule.""" if decay_start > decay_end: raise ValueError("decay_end is smaller than decay_end.") # Since some of the TF schedules do not support incrementing a value, # in all of the sche...
[ "Get", "KL", "multiplier", "(", "beta", ")", "based", "on", "the", "schedule", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L585-L618
[ "def", "beta_schedule", "(", "schedule", ",", "global_step", ",", "final_beta", ",", "decay_start", ",", "decay_end", ")", ":", "if", "decay_start", ">", "decay_end", ":", "raise", "ValueError", "(", "\"decay_end is smaller than decay_end.\"", ")", "# Since some of th...
272500b6efe353aeb638d2745ed56e519462ca31
train
extract_random_video_patch
For every video, extract a random consecutive patch of num_frames. Args: videos: 5-D Tensor, (NTHWC) num_frames: Integer, if -1 then the entire video is returned. Returns: video_patch: 5-D Tensor, (NTHWC) with T = num_frames. Raises: ValueError: If num_frames is greater than the number of total f...
tensor2tensor/layers/common_video.py
def extract_random_video_patch(videos, num_frames=-1): """For every video, extract a random consecutive patch of num_frames. Args: videos: 5-D Tensor, (NTHWC) num_frames: Integer, if -1 then the entire video is returned. Returns: video_patch: 5-D Tensor, (NTHWC) with T = num_frames. Raises: Val...
def extract_random_video_patch(videos, num_frames=-1): """For every video, extract a random consecutive patch of num_frames. Args: videos: 5-D Tensor, (NTHWC) num_frames: Integer, if -1 then the entire video is returned. Returns: video_patch: 5-D Tensor, (NTHWC) with T = num_frames. Raises: Val...
[ "For", "every", "video", "extract", "a", "random", "consecutive", "patch", "of", "num_frames", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L621-L658
[ "def", "extract_random_video_patch", "(", "videos", ",", "num_frames", "=", "-", "1", ")", ":", "if", "num_frames", "==", "-", "1", ":", "return", "videos", "batch_size", ",", "num_total_frames", ",", "h", ",", "w", ",", "c", "=", "common_layers", ".", "...
272500b6efe353aeb638d2745ed56e519462ca31
train
VideoWriter.write_multi
Writes multiple video frames.
tensor2tensor/layers/common_video.py
def write_multi(self, frames, encoded_frames=None): """Writes multiple video frames.""" if encoded_frames is None: # Infinite iterator. encoded_frames = iter(lambda: None, 1) for (frame, encoded_frame) in zip(frames, encoded_frames): self.write(frame, encoded_frame)
def write_multi(self, frames, encoded_frames=None): """Writes multiple video frames.""" if encoded_frames is None: # Infinite iterator. encoded_frames = iter(lambda: None, 1) for (frame, encoded_frame) in zip(frames, encoded_frames): self.write(frame, encoded_frame)
[ "Writes", "multiple", "video", "frames", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L668-L674
[ "def", "write_multi", "(", "self", ",", "frames", ",", "encoded_frames", "=", "None", ")", ":", "if", "encoded_frames", "is", "None", ":", "# Infinite iterator.", "encoded_frames", "=", "iter", "(", "lambda", ":", "None", ",", "1", ")", "for", "(", "frame"...
272500b6efe353aeb638d2745ed56e519462ca31
train
WholeVideoWriter.__init_ffmpeg
Initializes ffmpeg to write frames.
tensor2tensor/layers/common_video.py
def __init_ffmpeg(self, image_shape): """Initializes ffmpeg to write frames.""" import itertools # pylint: disable=g-import-not-at-top from subprocess import Popen, PIPE # pylint: disable=g-import-not-at-top,g-multiple-import,g-importing-member ffmpeg = "ffmpeg" height, width, channels = image_sha...
def __init_ffmpeg(self, image_shape): """Initializes ffmpeg to write frames.""" import itertools # pylint: disable=g-import-not-at-top from subprocess import Popen, PIPE # pylint: disable=g-import-not-at-top,g-multiple-import,g-importing-member ffmpeg = "ffmpeg" height, width, channels = image_sha...
[ "Initializes", "ffmpeg", "to", "write", "frames", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L715-L744
[ "def", "__init_ffmpeg", "(", "self", ",", "image_shape", ")", ":", "import", "itertools", "# pylint: disable=g-import-not-at-top", "from", "subprocess", "import", "Popen", ",", "PIPE", "# pylint: disable=g-import-not-at-top,g-multiple-import,g-importing-member", "ffmpeg", "=", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
WholeVideoWriter._start_reader_thread
Starts a thread for reading output from FFMPEG. The thread reads consecutive chunks from the stream and saves them in the given list. Args: stream: output stream of the FFMPEG process. chunks: list to save output chunks to. Returns: Thread
tensor2tensor/layers/common_video.py
def _start_reader_thread(self, stream, chunks): """Starts a thread for reading output from FFMPEG. The thread reads consecutive chunks from the stream and saves them in the given list. Args: stream: output stream of the FFMPEG process. chunks: list to save output chunks to. Returns: ...
def _start_reader_thread(self, stream, chunks): """Starts a thread for reading output from FFMPEG. The thread reads consecutive chunks from the stream and saves them in the given list. Args: stream: output stream of the FFMPEG process. chunks: list to save output chunks to. Returns: ...
[ "Starts", "a", "thread", "for", "reading", "output", "from", "FFMPEG", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L746-L769
[ "def", "_start_reader_thread", "(", "self", ",", "stream", ",", "chunks", ")", ":", "import", "io", "# pylint: disable=g-import-not-at-top", "import", "threading", "# pylint: disable=g-import-not-at-top", "def", "target", "(", ")", ":", "while", "True", ":", "chunk", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
WholeVideoWriter.finish
Finishes transconding and returns the video. Returns: bytes Raises: IOError: in case of transcoding error.
tensor2tensor/layers/common_video.py
def finish(self): """Finishes transconding and returns the video. Returns: bytes Raises: IOError: in case of transcoding error. """ if self.proc is None: return None self.proc.stdin.close() for thread in (self._out_thread, self._err_thread): thread.join() (out, ...
def finish(self): """Finishes transconding and returns the video. Returns: bytes Raises: IOError: in case of transcoding error. """ if self.proc is None: return None self.proc.stdin.close() for thread in (self._out_thread, self._err_thread): thread.join() (out, ...
[ "Finishes", "transconding", "and", "returns", "the", "video", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_video.py#L776-L800
[ "def", "finish", "(", "self", ")", ":", "if", "self", ".", "proc", "is", "None", ":", "return", "None", "self", ".", "proc", ".", "stdin", ".", "close", "(", ")", "for", "thread", "in", "(", "self", ".", "_out_thread", ",", "self", ".", "_err_threa...
272500b6efe353aeb638d2745ed56e519462ca31
train
validate_flags
Validates flags are set to acceptable values.
tensor2tensor/serving/query.py
def validate_flags(): """Validates flags are set to acceptable values.""" if FLAGS.cloud_mlengine_model_name: assert not FLAGS.server assert not FLAGS.servable_name else: assert FLAGS.server assert FLAGS.servable_name
def validate_flags(): """Validates flags are set to acceptable values.""" if FLAGS.cloud_mlengine_model_name: assert not FLAGS.server assert not FLAGS.servable_name else: assert FLAGS.server assert FLAGS.servable_name
[ "Validates", "flags", "are", "set", "to", "acceptable", "values", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/serving/query.py#L53-L60
[ "def", "validate_flags", "(", ")", ":", "if", "FLAGS", ".", "cloud_mlengine_model_name", ":", "assert", "not", "FLAGS", ".", "server", "assert", "not", "FLAGS", ".", "servable_name", "else", ":", "assert", "FLAGS", ".", "server", "assert", "FLAGS", ".", "ser...
272500b6efe353aeb638d2745ed56e519462ca31
train
make_request_fn
Returns a request function.
tensor2tensor/serving/query.py
def make_request_fn(): """Returns a request function.""" if FLAGS.cloud_mlengine_model_name: request_fn = serving_utils.make_cloud_mlengine_request_fn( credentials=GoogleCredentials.get_application_default(), model_name=FLAGS.cloud_mlengine_model_name, version=FLAGS.cloud_mlengine_model_...
def make_request_fn(): """Returns a request function.""" if FLAGS.cloud_mlengine_model_name: request_fn = serving_utils.make_cloud_mlengine_request_fn( credentials=GoogleCredentials.get_application_default(), model_name=FLAGS.cloud_mlengine_model_name, version=FLAGS.cloud_mlengine_model_...
[ "Returns", "a", "request", "function", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/serving/query.py#L63-L76
[ "def", "make_request_fn", "(", ")", ":", "if", "FLAGS", ".", "cloud_mlengine_model_name", ":", "request_fn", "=", "serving_utils", ".", "make_cloud_mlengine_request_fn", "(", "credentials", "=", "GoogleCredentials", ".", "get_application_default", "(", ")", ",", "mode...
272500b6efe353aeb638d2745ed56e519462ca31
train
NextFrameSavpBase.encoder
Convnet that encodes inputs into mean and std of a gaussian. Args: inputs: 5-D Tensor, shape (batch_size, num_frames, width, height, channels) n_layers: Number of layers. Returns: z_mu: Mean of the latent gaussians. z_log_var: log(var) of the latent gaussians. Raises: ValueError...
tensor2tensor/models/video/savp.py
def encoder(self, inputs, n_layers=3): """Convnet that encodes inputs into mean and std of a gaussian. Args: inputs: 5-D Tensor, shape (batch_size, num_frames, width, height, channels) n_layers: Number of layers. Returns: z_mu: Mean of the latent gaussians. z_log_var: log(var) of the l...
def encoder(self, inputs, n_layers=3): """Convnet that encodes inputs into mean and std of a gaussian. Args: inputs: 5-D Tensor, shape (batch_size, num_frames, width, height, channels) n_layers: Number of layers. Returns: z_mu: Mean of the latent gaussians. z_log_var: log(var) of the l...
[ "Convnet", "that", "encodes", "inputs", "into", "mean", "and", "std", "of", "a", "gaussian", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/savp.py#L42-L105
[ "def", "encoder", "(", "self", ",", "inputs", ",", "n_layers", "=", "3", ")", ":", "latent_dims", "=", "self", ".", "hparams", ".", "z_dim", "shape_as_list", "=", "inputs", ".", "shape", ".", "as_list", "(", ")", "if", "len", "(", "shape_as_list", ")",...
272500b6efe353aeb638d2745ed56e519462ca31
train
NextFrameSavpBase.get_fc_dimensions
Get expected fully connected shape after a series of convolutions.
tensor2tensor/models/video/savp.py
def get_fc_dimensions(self, strides, kernel_sizes): """Get expected fully connected shape after a series of convolutions.""" output_height, output_width, _ = self.hparams.problem.frame_shape output_steps = self.hparams.video_num_target_frames output_shape = np.array([output_steps, output_height, output_...
def get_fc_dimensions(self, strides, kernel_sizes): """Get expected fully connected shape after a series of convolutions.""" output_height, output_width, _ = self.hparams.problem.frame_shape output_steps = self.hparams.video_num_target_frames output_shape = np.array([output_steps, output_height, output_...
[ "Get", "expected", "fully", "connected", "shape", "after", "a", "series", "of", "convolutions", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/savp.py#L110-L118
[ "def", "get_fc_dimensions", "(", "self", ",", "strides", ",", "kernel_sizes", ")", ":", "output_height", ",", "output_width", ",", "_", "=", "self", ".", "hparams", ".", "problem", ".", "frame_shape", "output_steps", "=", "self", ".", "hparams", ".", "video_...
272500b6efe353aeb638d2745ed56e519462ca31
train
NextFrameSavpBase.discriminator
3-D SNGAN discriminator. Args: frames: a list of batch-major tensors indexed by time. Returns: logits: 1-D Tensor with shape=batch_size. Positive logits imply that the discriminator thinks that it belongs to the true class.
tensor2tensor/models/video/savp.py
def discriminator(self, frames): """3-D SNGAN discriminator. Args: frames: a list of batch-major tensors indexed by time. Returns: logits: 1-D Tensor with shape=batch_size. Positive logits imply that the discriminator thinks that it belongs to the true class. ""...
def discriminator(self, frames): """3-D SNGAN discriminator. Args: frames: a list of batch-major tensors indexed by time. Returns: logits: 1-D Tensor with shape=batch_size. Positive logits imply that the discriminator thinks that it belongs to the true class. ""...
[ "3", "-", "D", "SNGAN", "discriminator", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/savp.py#L120-L153
[ "def", "discriminator", "(", "self", ",", "frames", ")", ":", "ndf", "=", "self", ".", "hparams", ".", "num_discriminator_filters", "frames", "=", "tf", ".", "stack", "(", "frames", ")", "# Switch from time-major axis to batch-major axis.", "frames", "=", "common_...
272500b6efe353aeb638d2745ed56e519462ca31
train
NextFrameSavpBase.d_step
Performs the discriminator step in computing the GAN loss. Applies stop-gradient to the generated frames while computing the discriminator loss to make sure that the gradients are not back-propagated to the generator. This makes sure that only the discriminator is updated. Args: true_frames: Tru...
tensor2tensor/models/video/savp.py
def d_step(self, true_frames, gen_frames): """Performs the discriminator step in computing the GAN loss. Applies stop-gradient to the generated frames while computing the discriminator loss to make sure that the gradients are not back-propagated to the generator. This makes sure that only the discrimin...
def d_step(self, true_frames, gen_frames): """Performs the discriminator step in computing the GAN loss. Applies stop-gradient to the generated frames while computing the discriminator loss to make sure that the gradients are not back-propagated to the generator. This makes sure that only the discrimin...
[ "Performs", "the", "discriminator", "step", "in", "computing", "the", "GAN", "loss", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/savp.py#L155-L192
[ "def", "d_step", "(", "self", ",", "true_frames", ",", "gen_frames", ")", ":", "hparam_to_disc_loss", "=", "{", "\"least_squares\"", ":", "gan_losses", ".", "least_squares_discriminator_loss", ",", "\"cross_entropy\"", ":", "gan_losses", ".", "modified_discriminator_los...
272500b6efe353aeb638d2745ed56e519462ca31
train
NextFrameSavpBase.g_step
Performs the generator step in computing the GAN loss. Args: gen_frames: Generated frames fake_logits_stop: Logits corresponding to the generated frames as per the discriminator. Assumed to have a stop-gradient term. Returns: gan_g_loss_pos_d: Loss. gan_g_loss_ne...
tensor2tensor/models/video/savp.py
def g_step(self, gen_frames, fake_logits_stop): """Performs the generator step in computing the GAN loss. Args: gen_frames: Generated frames fake_logits_stop: Logits corresponding to the generated frames as per the discriminator. Assumed to have a stop-gradient term. Ret...
def g_step(self, gen_frames, fake_logits_stop): """Performs the generator step in computing the GAN loss. Args: gen_frames: Generated frames fake_logits_stop: Logits corresponding to the generated frames as per the discriminator. Assumed to have a stop-gradient term. Ret...
[ "Performs", "the", "generator", "step", "in", "computing", "the", "GAN", "loss", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/savp.py#L194-L226
[ "def", "g_step", "(", "self", ",", "gen_frames", ",", "fake_logits_stop", ")", ":", "hparam_to_gen_loss", "=", "{", "\"least_squares\"", ":", "gan_losses", ".", "least_squares_generator_loss", ",", "\"cross_entropy\"", ":", "gan_losses", ".", "modified_generator_loss", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
NextFrameSavpBase.get_gan_loss
Get the discriminator + generator loss at every step. This performs an 1:1 update of the discriminator and generator at every step. Args: true_frames: 5-D Tensor of shape (num_steps, batch_size, H, W, C) Assumed to be ground truth. gen_frames: 5-D Tensor of shape (num_steps,...
tensor2tensor/models/video/savp.py
def get_gan_loss(self, true_frames, gen_frames, name): """Get the discriminator + generator loss at every step. This performs an 1:1 update of the discriminator and generator at every step. Args: true_frames: 5-D Tensor of shape (num_steps, batch_size, H, W, C) Assumed to be g...
def get_gan_loss(self, true_frames, gen_frames, name): """Get the discriminator + generator loss at every step. This performs an 1:1 update of the discriminator and generator at every step. Args: true_frames: 5-D Tensor of shape (num_steps, batch_size, H, W, C) Assumed to be g...
[ "Get", "the", "discriminator", "+", "generator", "loss", "at", "every", "step", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/savp.py#L228-L262
[ "def", "get_gan_loss", "(", "self", ",", "true_frames", ",", "gen_frames", ",", "name", ")", ":", "# D - STEP", "with", "tf", ".", "variable_scope", "(", "\"%s_discriminator\"", "%", "name", ",", "reuse", "=", "tf", ".", "AUTO_REUSE", ")", ":", "gan_d_loss",...
272500b6efe353aeb638d2745ed56e519462ca31
train
NextFrameSavpBase.get_extra_loss
Gets extra loss from VAE and GAN.
tensor2tensor/models/video/savp.py
def get_extra_loss(self, latent_means=None, latent_stds=None, true_frames=None, gen_frames=None): """Gets extra loss from VAE and GAN.""" if not self.is_training: return 0.0 vae_loss, d_vae_loss, d_gan_loss = 0.0, 0.0, 0.0 # Use sv2p's KL divergence computation. if self.h...
def get_extra_loss(self, latent_means=None, latent_stds=None, true_frames=None, gen_frames=None): """Gets extra loss from VAE and GAN.""" if not self.is_training: return 0.0 vae_loss, d_vae_loss, d_gan_loss = 0.0, 0.0, 0.0 # Use sv2p's KL divergence computation. if self.h...
[ "Gets", "extra", "loss", "from", "VAE", "and", "GAN", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/savp.py#L264-L296
[ "def", "get_extra_loss", "(", "self", ",", "latent_means", "=", "None", ",", "latent_stds", "=", "None", ",", "true_frames", "=", "None", ",", "gen_frames", "=", "None", ")", ":", "if", "not", "self", ".", "is_training", ":", "return", "0.0", "vae_loss", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
NextFrameSavpBase.pad_conv3d_lrelu
Pad, apply 3-D convolution and leaky relu.
tensor2tensor/models/video/savp.py
def pad_conv3d_lrelu(self, activations, n_filters, kernel_size, strides, scope): """Pad, apply 3-D convolution and leaky relu.""" padding = [[0, 0], [1, 1], [1, 1], [1, 1], [0, 0]] # tf.nn.conv3d accepts a list of 5 values for strides # with first and last value equal to 1 if...
def pad_conv3d_lrelu(self, activations, n_filters, kernel_size, strides, scope): """Pad, apply 3-D convolution and leaky relu.""" padding = [[0, 0], [1, 1], [1, 1], [1, 1], [0, 0]] # tf.nn.conv3d accepts a list of 5 values for strides # with first and last value equal to 1 if...
[ "Pad", "apply", "3", "-", "D", "convolution", "and", "leaky", "relu", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/savp.py#L298-L327
[ "def", "pad_conv3d_lrelu", "(", "self", ",", "activations", ",", "n_filters", ",", "kernel_size", ",", "strides", ",", "scope", ")", ":", "padding", "=", "[", "[", "0", ",", "0", "]", ",", "[", "1", ",", "1", "]", ",", "[", "1", ",", "1", "]", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
weight
Weight-level magnitude pruning.
tensor2tensor/utils/pruning_utils.py
def weight(w, sparsity): """Weight-level magnitude pruning.""" w_shape = common_layers.shape_list(w) k = int(np.prod(w_shape[:-1])) count = tf.to_int32(k * sparsity) mask = common_layers.weight_targeting(w, count) return (1 - mask) * w
def weight(w, sparsity): """Weight-level magnitude pruning.""" w_shape = common_layers.shape_list(w) k = int(np.prod(w_shape[:-1])) count = tf.to_int32(k * sparsity) mask = common_layers.weight_targeting(w, count) return (1 - mask) * w
[ "Weight", "-", "level", "magnitude", "pruning", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/pruning_utils.py#L27-L33
[ "def", "weight", "(", "w", ",", "sparsity", ")", ":", "w_shape", "=", "common_layers", ".", "shape_list", "(", "w", ")", "k", "=", "int", "(", "np", ".", "prod", "(", "w_shape", "[", ":", "-", "1", "]", ")", ")", "count", "=", "tf", ".", "to_in...
272500b6efe353aeb638d2745ed56e519462ca31
train
unit
Unit-level magnitude pruning.
tensor2tensor/utils/pruning_utils.py
def unit(w, sparsity): """Unit-level magnitude pruning.""" w_shape = common_layers.shape_list(w) count = tf.to_int32(w_shape[-1] * sparsity) mask = common_layers.unit_targeting(w, count) return (1 - mask) * w
def unit(w, sparsity): """Unit-level magnitude pruning.""" w_shape = common_layers.shape_list(w) count = tf.to_int32(w_shape[-1] * sparsity) mask = common_layers.unit_targeting(w, count) return (1 - mask) * w
[ "Unit", "-", "level", "magnitude", "pruning", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/pruning_utils.py#L37-L42
[ "def", "unit", "(", "w", ",", "sparsity", ")", ":", "w_shape", "=", "common_layers", ".", "shape_list", "(", "w", ")", "count", "=", "tf", ".", "to_int32", "(", "w_shape", "[", "-", "1", "]", "*", "sparsity", ")", "mask", "=", "common_layers", ".", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
sparsify
Prune the weights of a model and evaluate.
tensor2tensor/utils/pruning_utils.py
def sparsify(sess, eval_model, pruning_strategy, pruning_params): """Prune the weights of a model and evaluate.""" weights = tf.trainable_variables() def should_prune(name): """Whether to prune a weight or not.""" in_whitelist = not pruning_params.white_list or any( e in name for e in pruning_par...
def sparsify(sess, eval_model, pruning_strategy, pruning_params): """Prune the weights of a model and evaluate.""" weights = tf.trainable_variables() def should_prune(name): """Whether to prune a weight or not.""" in_whitelist = not pruning_params.white_list or any( e in name for e in pruning_par...
[ "Prune", "the", "weights", "of", "a", "model", "and", "evaluate", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/pruning_utils.py#L45-L80
[ "def", "sparsify", "(", "sess", ",", "eval_model", ",", "pruning_strategy", ",", "pruning_params", ")", ":", "weights", "=", "tf", ".", "trainable_variables", "(", ")", "def", "should_prune", "(", "name", ")", ":", "\"\"\"Whether to prune a weight or not.\"\"\"", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
DebugFrontendApplication.load_config
Loads the configuration.
tensor2tensor/insights/server.py
def load_config(self): """Loads the configuration.""" config = dict([(key, value) for key, value in iteritems(self.options) if key in self.cfg.settings and value is not None]) for key, value in iteritems(config): self.cfg.set(key.lower(), value)
def load_config(self): """Loads the configuration.""" config = dict([(key, value) for key, value in iteritems(self.options) if key in self.cfg.settings and value is not None]) for key, value in iteritems(config): self.cfg.set(key.lower(), value)
[ "Loads", "the", "configuration", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/insights/server.py#L79-L84
[ "def", "load_config", "(", "self", ")", ":", "config", "=", "dict", "(", "[", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "iteritems", "(", "self", ".", "options", ")", "if", "key", "in", "self", ".", "cfg", ".", "settings", ...
272500b6efe353aeb638d2745ed56e519462ca31
train
ppo_base_v1
Set of hyperparameters.
tensor2tensor/models/research/rl.py
def ppo_base_v1(): """Set of hyperparameters.""" hparams = common_hparams.basic_params1() hparams.learning_rate_schedule = "constant" hparams.learning_rate_constant = 1e-4 hparams.clip_grad_norm = 0.5 hparams.weight_decay = 0 # If set, extends the LR warmup to all epochs except the final one. hparams.ad...
def ppo_base_v1(): """Set of hyperparameters.""" hparams = common_hparams.basic_params1() hparams.learning_rate_schedule = "constant" hparams.learning_rate_constant = 1e-4 hparams.clip_grad_norm = 0.5 hparams.weight_decay = 0 # If set, extends the LR warmup to all epochs except the final one. hparams.ad...
[ "Set", "of", "hyperparameters", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/rl.py#L46-L76
[ "def", "ppo_base_v1", "(", ")", ":", "hparams", "=", "common_hparams", ".", "basic_params1", "(", ")", "hparams", ".", "learning_rate_schedule", "=", "\"constant\"", "hparams", ".", "learning_rate_constant", "=", "1e-4", "hparams", ".", "clip_grad_norm", "=", "0.5...
272500b6efe353aeb638d2745ed56e519462ca31
train
ppo_atari_base
Pong base parameters.
tensor2tensor/models/research/rl.py
def ppo_atari_base(): """Pong base parameters.""" hparams = ppo_discrete_action_base() hparams.learning_rate_constant = 1e-4 hparams.epoch_length = 200 hparams.gae_gamma = 0.985 hparams.gae_lambda = 0.985 hparams.entropy_loss_coef = 0.003 hparams.value_loss_coef = 1 hparams.optimization_epochs = 3 h...
def ppo_atari_base(): """Pong base parameters.""" hparams = ppo_discrete_action_base() hparams.learning_rate_constant = 1e-4 hparams.epoch_length = 200 hparams.gae_gamma = 0.985 hparams.gae_lambda = 0.985 hparams.entropy_loss_coef = 0.003 hparams.value_loss_coef = 1 hparams.optimization_epochs = 3 h...
[ "Pong", "base", "parameters", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/rl.py#L100-L115
[ "def", "ppo_atari_base", "(", ")", ":", "hparams", "=", "ppo_discrete_action_base", "(", ")", "hparams", ".", "learning_rate_constant", "=", "1e-4", "hparams", ".", "epoch_length", "=", "200", "hparams", ".", "gae_gamma", "=", "0.985", "hparams", ".", "gae_lambd...
272500b6efe353aeb638d2745ed56e519462ca31
train
ppo_original_params
Parameters based on the original PPO paper.
tensor2tensor/models/research/rl.py
def ppo_original_params(): """Parameters based on the original PPO paper.""" hparams = ppo_atari_base() hparams.learning_rate_constant = 2.5e-4 hparams.gae_gamma = 0.99 hparams.gae_lambda = 0.95 hparams.clipping_coef = 0.1 hparams.value_loss_coef = 1 hparams.entropy_loss_coef = 0.01 hparams.eval_every...
def ppo_original_params(): """Parameters based on the original PPO paper.""" hparams = ppo_atari_base() hparams.learning_rate_constant = 2.5e-4 hparams.gae_gamma = 0.99 hparams.gae_lambda = 0.95 hparams.clipping_coef = 0.1 hparams.value_loss_coef = 1 hparams.entropy_loss_coef = 0.01 hparams.eval_every...
[ "Parameters", "based", "on", "the", "original", "PPO", "paper", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/rl.py#L119-L134
[ "def", "ppo_original_params", "(", ")", ":", "hparams", "=", "ppo_atari_base", "(", ")", "hparams", ".", "learning_rate_constant", "=", "2.5e-4", "hparams", ".", "gae_gamma", "=", "0.99", "hparams", ".", "gae_lambda", "=", "0.95", "hparams", ".", "clipping_coef"...
272500b6efe353aeb638d2745ed56e519462ca31
train
ppo_original_world_model
Atari parameters with world model as policy.
tensor2tensor/models/research/rl.py
def ppo_original_world_model(): """Atari parameters with world model as policy.""" hparams = ppo_original_params() hparams.policy_network = "next_frame_basic_deterministic" hparams_keys = hparams.values().keys() video_hparams = basic_deterministic_params.next_frame_basic_deterministic() for (name, value) in...
def ppo_original_world_model(): """Atari parameters with world model as policy.""" hparams = ppo_original_params() hparams.policy_network = "next_frame_basic_deterministic" hparams_keys = hparams.values().keys() video_hparams = basic_deterministic_params.next_frame_basic_deterministic() for (name, value) in...
[ "Atari", "parameters", "with", "world", "model", "as", "policy", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/rl.py#L172-L185
[ "def", "ppo_original_world_model", "(", ")", ":", "hparams", "=", "ppo_original_params", "(", ")", "hparams", ".", "policy_network", "=", "\"next_frame_basic_deterministic\"", "hparams_keys", "=", "hparams", ".", "values", "(", ")", ".", "keys", "(", ")", "video_h...
272500b6efe353aeb638d2745ed56e519462ca31
train
ppo_tiny_world_model
Atari parameters with world model as policy.
tensor2tensor/models/research/rl.py
def ppo_tiny_world_model(): """Atari parameters with world model as policy.""" hparams = ppo_original_params() hparams.policy_network = "next_frame_basic_deterministic" hparams_keys = hparams.values().keys() video_hparams = basic_deterministic_params.next_frame_tiny() for (name, value) in six.iteritems(vide...
def ppo_tiny_world_model(): """Atari parameters with world model as policy.""" hparams = ppo_original_params() hparams.policy_network = "next_frame_basic_deterministic" hparams_keys = hparams.values().keys() video_hparams = basic_deterministic_params.next_frame_tiny() for (name, value) in six.iteritems(vide...
[ "Atari", "parameters", "with", "world", "model", "as", "policy", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/rl.py#L189-L201
[ "def", "ppo_tiny_world_model", "(", ")", ":", "hparams", "=", "ppo_original_params", "(", ")", "hparams", ".", "policy_network", "=", "\"next_frame_basic_deterministic\"", "hparams_keys", "=", "hparams", ".", "values", "(", ")", ".", "keys", "(", ")", "video_hpara...
272500b6efe353aeb638d2745ed56e519462ca31
train
ppo_original_world_model_stochastic_discrete
Atari parameters with stochastic discrete world model as policy.
tensor2tensor/models/research/rl.py
def ppo_original_world_model_stochastic_discrete(): """Atari parameters with stochastic discrete world model as policy.""" hparams = ppo_original_params() hparams.policy_network = "next_frame_basic_stochastic_discrete" hparams_keys = hparams.values().keys() video_hparams = basic_stochastic.next_frame_basic_st...
def ppo_original_world_model_stochastic_discrete(): """Atari parameters with stochastic discrete world model as policy.""" hparams = ppo_original_params() hparams.policy_network = "next_frame_basic_stochastic_discrete" hparams_keys = hparams.values().keys() video_hparams = basic_stochastic.next_frame_basic_st...
[ "Atari", "parameters", "with", "stochastic", "discrete", "world", "model", "as", "policy", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/rl.py#L205-L219
[ "def", "ppo_original_world_model_stochastic_discrete", "(", ")", ":", "hparams", "=", "ppo_original_params", "(", ")", "hparams", ".", "policy_network", "=", "\"next_frame_basic_stochastic_discrete\"", "hparams_keys", "=", "hparams", ".", "values", "(", ")", ".", "keys"...
272500b6efe353aeb638d2745ed56e519462ca31
train
make_simulated_env_fn
Returns a function creating a simulated env, in or out of graph. Args: **env_kwargs: kwargs to pass to the simulated env constructor. Returns: Function in_graph -> env.
tensor2tensor/models/research/rl.py
def make_simulated_env_fn(**env_kwargs): """Returns a function creating a simulated env, in or out of graph. Args: **env_kwargs: kwargs to pass to the simulated env constructor. Returns: Function in_graph -> env. """ def env_fn(in_graph): class_ = SimulatedBatchEnv if in_graph else SimulatedBatc...
def make_simulated_env_fn(**env_kwargs): """Returns a function creating a simulated env, in or out of graph. Args: **env_kwargs: kwargs to pass to the simulated env constructor. Returns: Function in_graph -> env. """ def env_fn(in_graph): class_ = SimulatedBatchEnv if in_graph else SimulatedBatc...
[ "Returns", "a", "function", "creating", "a", "simulated", "env", "in", "or", "out", "of", "graph", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/rl.py#L234-L246
[ "def", "make_simulated_env_fn", "(", "*", "*", "env_kwargs", ")", ":", "def", "env_fn", "(", "in_graph", ")", ":", "class_", "=", "SimulatedBatchEnv", "if", "in_graph", "else", "SimulatedBatchGymEnv", "return", "class_", "(", "*", "*", "env_kwargs", ")", "retu...
272500b6efe353aeb638d2745ed56e519462ca31
train
make_simulated_env_kwargs
Extracts simulated env kwargs from real_env and loop hparams.
tensor2tensor/models/research/rl.py
def make_simulated_env_kwargs(real_env, hparams, **extra_kwargs): """Extracts simulated env kwargs from real_env and loop hparams.""" objs_and_attrs = [ (real_env, [ "reward_range", "observation_space", "action_space", "frame_height", "frame_width" ]), (hparams, ["frame_stack_s...
def make_simulated_env_kwargs(real_env, hparams, **extra_kwargs): """Extracts simulated env kwargs from real_env and loop hparams.""" objs_and_attrs = [ (real_env, [ "reward_range", "observation_space", "action_space", "frame_height", "frame_width" ]), (hparams, ["frame_stack_s...
[ "Extracts", "simulated", "env", "kwargs", "from", "real_env", "and", "loop", "hparams", "." ]
tensorflow/tensor2tensor
python
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/rl.py#L250-L270
[ "def", "make_simulated_env_kwargs", "(", "real_env", ",", "hparams", ",", "*", "*", "extra_kwargs", ")", ":", "objs_and_attrs", "=", "[", "(", "real_env", ",", "[", "\"reward_range\"", ",", "\"observation_space\"", ",", "\"action_space\"", ",", "\"frame_height\"", ...
272500b6efe353aeb638d2745ed56e519462ca31