neulab/docprompting-conala huggingface dataset:
tf.keras.datasets.reuters.load_data     View source on GitHub    Loads the Reuters newswire classification dataset.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.datasets.reuters.load_data  
tf.keras.datasets.reuters.load_data(
    path='reuters.npz', num_words=None, skip_top=0, maxlen=None,
    test_split=0.2, seed=113, start_char=1, oov_char=2, index_from=3, **kwargs
)
 This is a dataset of 11,228 newswires from Reuters, labeled over 46 topics. This was originally generated by parsing and preprocessing the classic Reuters-21578 dataset, but the preprocessing code is no longer packaged with Keras. See this github discussion for more info. Each newswire is encoded as a list of word indexes (integers). For convenience, words are indexed by overall frequency in the dataset, so that for instance the integer "3" encodes the 3rd most frequent word in the data. This allows for quick filtering operations such as: "only consider the top 10,000 most common words, but eliminate the top 20 most common words". As a convention, "0" does not stand for a specific word, but instead is used to encode any unknown word.
 


 Arguments
  path   where to cache the data (relative to ~/.keras/dataset).  
  num_words   integer or None. Words are ranked by how often they occur (in the training set) and only the num_words most frequent words are kept. Any less frequent word will appear as oov_char value in the sequence data. If None, all words are kept. Defaults to None, so all words are kept.  
  skip_top   skip the top N most frequently occurring words (which may not be informative). These words will appear as oov_char value in the dataset. Defaults to 0, so no words are skipped.  
  maxlen   int or None. Maximum sequence length. Any longer sequence will be truncated. Defaults to None, which means no truncation.  
  test_split   Float between 0 and 1. Fraction of the dataset to be used as test data. Defaults to 0.2, meaning 20% of the dataset is used as test data.  
  seed   int. Seed for reproducible data shuffling.  
  start_char   int. The start of a sequence will be marked with this character. Defaults to 1 because 0 is usually the padding character.  
  oov_char   int. The out-of-vocabulary character. Words that were cut out because of the num_words or skip_top limits will be replaced with this character.  
  index_from   int. Index actual words with this index and higher.  
  **kwargs   Used for backwards compatibility.   
 


 Returns   Tuple of Numpy arrays: (x_train, y_train), (x_test, y_test). x_train, x_test: lists of sequences, which are lists of indexes (integers). If the num_words argument was specific, the maximum possible index value is num_words - 1. If the maxlen argument was specified, the largest possible sequence length is maxlen. y_train, y_test: lists of integer labels (1 or 0). 
 
 
Note: The 'out of vocabulary' character is only used for words that were present in the training set but are not included because they're not making the num_words cut here. Words that were not seen in the training set but are in the test set have simply been skipped.
Module: tf.keras.estimator Keras estimator API. Functions model_to_estimator(...): Constructs an Estimator instance from given keras model.
Module: tf.keras.experimental Public API for tf.keras.experimental namespace. Classes class CosineDecay: A LearningRateSchedule that uses a cosine decay schedule. class CosineDecayRestarts: A LearningRateSchedule that uses a cosine decay schedule with restarts. class LinearCosineDecay: A LearningRateSchedule that uses a linear cosine decay schedule. class LinearModel: Linear Model for regression and classification problems. class NoisyLinearCosineDecay: A LearningRateSchedule that uses a noisy linear cosine decay schedule. class PeepholeLSTMCell: Equivalent to LSTMCell class but adds peephole connections. class SequenceFeatures: A layer for sequence input. class WideDeepModel: Wide & Deep Model for regression and classification problems.
tf.keras.experimental.CosineDecay     View source on GitHub    A LearningRateSchedule that uses a cosine decay schedule. Inherits From: LearningRateSchedule  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.experimental.CosineDecay  
tf.keras.experimental.CosineDecay(
    initial_learning_rate, decay_steps, alpha=0.0, name=None
)
 See [Loshchilov & Hutter, ICLR2016], SGDR: Stochastic Gradient Descent with Warm Restarts. https://arxiv.org/abs/1608.03983 When training a model, it is often recommended to lower the learning rate as the training progresses. This schedule applies a cosine decay function to an optimizer step, given a provided initial learning rate. It requires a step value to compute the decayed learning rate. You can just pass a TensorFlow variable that you increment at each training step. The schedule a 1-arg callable that produces a decayed learning rate when passed the current optimizer step. This can be useful for changing the learning rate value across different invocations of optimizer functions. It is computed as: def decayed_learning_rate(step):
  step = min(step, decay_steps)
  cosine_decay = 0.5 * (1 + cos(pi * step / decay_steps))
  decayed = (1 - alpha) * cosine_decay + alpha
  return initial_learning_rate * decayed
 Example usage: decay_steps = 1000
lr_decayed_fn = tf.keras.experimental.CosineDecay(
    initial_learning_rate, decay_steps)
 You can pass this schedule directly into a tf.keras.optimizers.Optimizer as the learning rate. The learning rate schedule is also serializable and deserializable using tf.keras.optimizers.schedules.serialize and tf.keras.optimizers.schedules.deserialize.
 


 Returns   A 1-arg callable learning rate schedule that takes the current optimizer step and outputs the decayed learning rate, a scalar Tensor of the same type as initial_learning_rate.  

 


 Args
  initial_learning_rate   A scalar float32 or float64 Tensor or a Python number. The initial learning rate.  
  decay_steps   A scalar int32 or int64 Tensor or a Python number. Number of steps to decay over.  
  alpha   A scalar float32 or float64 Tensor or a Python number. Minimum learning rate value as a fraction of initial_learning_rate.  
  name   String. Optional name of the operation. Defaults to 'CosineDecay'.    Methods from_config View source 
@classmethod
from_config(
    config
)
 Instantiates a LearningRateSchedule from its config.
 


 Args
  config   Output of get_config().   
 


 Returns   A LearningRateSchedule instance.  
 get_config View source 
get_config()
 __call__ View source 
__call__(
    step
)
 Call self as a function.
tf.keras.experimental.CosineDecayRestarts     View source on GitHub    A LearningRateSchedule that uses a cosine decay schedule with restarts. Inherits From: LearningRateSchedule  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.experimental.CosineDecayRestarts  
tf.keras.experimental.CosineDecayRestarts(
    initial_learning_rate, first_decay_steps, t_mul=2.0, m_mul=1.0, alpha=0.0,
    name=None
)
 See [Loshchilov & Hutter, ICLR2016], SGDR: Stochastic Gradient Descent with Warm Restarts. https://arxiv.org/abs/1608.03983 When training a model, it is often recommended to lower the learning rate as the training progresses. This schedule applies a cosine decay function with restarts to an optimizer step, given a provided initial learning rate. It requires a step value to compute the decayed learning rate. You can just pass a TensorFlow variable that you increment at each training step. The schedule a 1-arg callable that produces a decayed learning rate when passed the current optimizer step. This can be useful for changing the learning rate value across different invocations of optimizer functions. The learning rate multiplier first decays from 1 to alpha for first_decay_steps steps. Then, a warm restart is performed. Each new warm restart runs for t_mul times more steps and with m_mul times smaller initial learning rate. Example usage: first_decay_steps = 1000
lr_decayed_fn = (
  tf.keras.experimental.CosineDecayRestarts(
      initial_learning_rate,
      first_decay_steps))
 You can pass this schedule directly into a tf.keras.optimizers.Optimizer as the learning rate. The learning rate schedule is also serializable and deserializable using tf.keras.optimizers.schedules.serialize and tf.keras.optimizers.schedules.deserialize.
 


 Returns   A 1-arg callable learning rate schedule that takes the current optimizer step and outputs the decayed learning rate, a scalar Tensor of the same type as initial_learning_rate.  

 


 Args
  initial_learning_rate   A scalar float32 or float64 Tensor or a Python number. The initial learning rate.  
  first_decay_steps   A scalar int32 or int64 Tensor or a Python number. Number of steps to decay over.  
  t_mul   A scalar float32 or float64 Tensor or a Python number. Used to derive the number of iterations in the i-th period  
  m_mul   A scalar float32 or float64 Tensor or a Python number. Used to derive the initial learning rate of the i-th period:  
  alpha   A scalar float32 or float64 Tensor or a Python number. Minimum learning rate value as a fraction of the initial_learning_rate.  
  name   String. Optional name of the operation. Defaults to 'SGDRDecay'.    Methods from_config View source 
@classmethod
from_config(
    config
)
 Instantiates a LearningRateSchedule from its config.
 


 Args
  config   Output of get_config().   
 


 Returns   A LearningRateSchedule instance.  
 get_config View source 
get_config()
 __call__ View source 
__call__(
    step
)
 Call self as a function.
tf.keras.experimental.LinearCosineDecay     View source on GitHub    A LearningRateSchedule that uses a linear cosine decay schedule. Inherits From: LearningRateSchedule  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.experimental.LinearCosineDecay  
tf.keras.experimental.LinearCosineDecay(
    initial_learning_rate, decay_steps, num_periods=0.5, alpha=0.0, beta=0.001,
    name=None
)
 See [Bello et al., ICML2017] Neural Optimizer Search with RL. https://arxiv.org/abs/1709.07417 For the idea of warm starts here controlled by num_periods, see [Loshchilov & Hutter, ICLR2016] SGDR: Stochastic Gradient Descent with Warm Restarts. https://arxiv.org/abs/1608.03983 Note that linear cosine decay is more aggressive than cosine decay and larger initial learning rates can typically be used. When training a model, it is often recommended to lower the learning rate as the training progresses. This schedule applies a linear cosine decay function to an optimizer step, given a provided initial learning rate. It requires a step value to compute the decayed learning rate. You can just pass a TensorFlow variable that you increment at each training step. The schedule a 1-arg callable that produces a decayed learning rate when passed the current optimizer step. This can be useful for changing the learning rate value across different invocations of optimizer functions. It is computed as: def decayed_learning_rate(step):
  step = min(step, decay_steps)
  linear_decay = (decay_steps - step) / decay_steps
  cosine_decay = 0.5 * (
      1 + cos(pi * 2 * num_periods * step / decay_steps))
  decayed = (alpha + linear_decay) * cosine_decay + beta
  return initial_learning_rate * decayed
 Example usage: decay_steps = 1000
lr_decayed_fn = (
  tf.keras.experimental.LinearCosineDecay(
    initial_learning_rate, decay_steps))
 You can pass this schedule directly into a tf.keras.optimizers.Optimizer as the learning rate. The learning rate schedule is also serializable and deserializable using tf.keras.optimizers.schedules.serialize and tf.keras.optimizers.schedules.deserialize.
 


 Returns   A 1-arg callable learning rate schedule that takes the current optimizer step and outputs the decayed learning rate, a scalar Tensor of the same type as initial_learning_rate.  

 


 Args
  initial_learning_rate   A scalar float32 or float64 Tensor or a Python number. The initial learning rate.  
  decay_steps   A scalar int32 or int64 Tensor or a Python number. Number of steps to decay over.  
  num_periods   Number of periods in the cosine part of the decay. See computation above.  
  alpha   See computation above.  
  beta   See computation above.  
  name   String. Optional name of the operation. Defaults to 'LinearCosineDecay'.    Methods from_config View source 
@classmethod
from_config(
    config
)
 Instantiates a LearningRateSchedule from its config.
 


 Args
  config   Output of get_config().   
 


 Returns   A LearningRateSchedule instance.  
 get_config View source 
get_config()
 __call__ View source 
__call__(
    step
)
 Call self as a function.
tf.keras.experimental.SequenceFeatures     View source on GitHub    A layer for sequence input. Inherits From: Layer, Module  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.experimental.SequenceFeatures  
tf.keras.experimental.SequenceFeatures(
    feature_columns, trainable=True, name=None, **kwargs
)
 All feature_columns must be sequence dense columns with the same sequence_length. The output of this method can be fed into sequence networks, such as RNN. The output of this method is a 3D Tensor of shape [batch_size, T, D]. T is the maximum sequence length for this batch, which could differ from batch to batch. If multiple feature_columns are given with Di num_elements each, their outputs are concatenated. So, the final Tensor has shape [batch_size, T, D0 + D1 + ... + Dn]. Example: # Behavior of some cells or feature columns may depend on whether we are in
# training or inference mode, e.g. applying dropout.
training = True
rating = sequence_numeric_column('rating')
watches = sequence_categorical_column_with_identity(
    'watches', num_buckets=1000)
watches_embedding = embedding_column(watches, dimension=10)
columns = [rating, watches_embedding]

sequence_input_layer = SequenceFeatures(columns)
features = tf.io.parse_example(...,
                               features=make_parse_example_spec(columns))
sequence_input, sequence_length = sequence_input_layer(
   features, training=training)
sequence_length_mask = tf.sequence_mask(sequence_length)

rnn_cell = tf.keras.layers.SimpleRNNCell(hidden_size, training=training)
rnn_layer = tf.keras.layers.RNN(rnn_cell, training=training)
outputs, state = rnn_layer(sequence_input, mask=sequence_length_mask)

 


 Args
  feature_columns   An iterable of dense sequence columns. Valid columns are  
embedding_column that wraps a sequence_categorical_column_with_*
 
sequence_numeric_column. 

 
  trainable   Boolean, whether the layer's variables will be updated via gradient descent during training.  
  name   Name to give to the SequenceFeatures.  
  **kwargs   Keyword arguments to construct a layer.   
 


 Raises
  ValueError   If any of the feature_columns is not a SequenceDenseColumn.
Module: tf.keras.initializers Keras initializer serialization / deserialization.  View aliases  Main aliases 
tf.initializers  Classes class Constant: Initializer that generates tensors with constant values. class GlorotNormal: The Glorot normal initializer, also called Xavier normal initializer. class GlorotUniform: The Glorot uniform initializer, also called Xavier uniform initializer. class HeNormal: He normal initializer. class HeUniform: He uniform variance scaling initializer. class Identity: Initializer that generates the identity matrix. class Initializer: Initializer base class: all Keras initializers inherit from this class. class LecunNormal: Lecun normal initializer. class LecunUniform: Lecun uniform initializer. class Ones: Initializer that generates tensors initialized to 1. class Orthogonal: Initializer that generates an orthogonal matrix. class RandomNormal: Initializer that generates tensors with a normal distribution. class RandomUniform: Initializer that generates tensors with a uniform distribution. class TruncatedNormal: Initializer that generates a truncated normal distribution. class VarianceScaling: Initializer capable of adapting its scale to the shape of weights tensors. class Zeros: Initializer that generates tensors initialized to 0. class constant: Initializer that generates tensors with constant values. class glorot_normal: The Glorot normal initializer, also called Xavier normal initializer. class glorot_uniform: The Glorot uniform initializer, also called Xavier uniform initializer. class he_normal: He normal initializer. class he_uniform: He uniform variance scaling initializer. class identity: Initializer that generates the identity matrix. class lecun_normal: Lecun normal initializer. class lecun_uniform: Lecun uniform initializer. class ones: Initializer that generates tensors initialized to 1. class orthogonal: Initializer that generates an orthogonal matrix. class random_normal: Initializer that generates tensors with a normal distribution. class random_uniform: Initializer that generates tensors with a uniform distribution. class truncated_normal: Initializer that generates a truncated normal distribution. class variance_scaling: Initializer capable of adapting its scale to the shape of weights tensors. class zeros: Initializer that generates tensors initialized to 0. Functions deserialize(...): Return an Initializer object from its config. get(...) serialize(...)
tf.keras.initializers.Constant Initializer that generates tensors with constant values. Inherits From: Initializer  View aliases  Main aliases 
tf.initializers.Constant, tf.initializers.constant, tf.keras.initializers.constant  
tf.keras.initializers.Constant(
    value=0
)
 Also available via the shortcut function tf.keras.initializers.constant. Only scalar values are allowed. The constant value provided must be convertible to the dtype requested when calling the initializer. Examples: 
# Standalone usage:
initializer = tf.keras.initializers.Constant(3.)
values = initializer(shape=(2, 2))
 
# Usage in a Keras layer:
initializer = tf.keras.initializers.Constant(3.)
layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

 


 Args
  value   A Python scalar.    Methods from_config View source 
@classmethod
from_config(
    config
)
 Instantiates an initializer from a configuration dictionary. Example: initializer = RandomUniform(-1, 1)
config = initializer.get_config()
initializer = RandomUniform.from_config(config)

 


 Args
  config   A Python dictionary, the output of get_config.   
 


 Returns   A tf.keras.initializers.Initializer instance.  
 get_config View source 
get_config()
 Returns the configuration of the initializer as a JSON-serializable dict.
 


 Returns   A JSON-serializable Python dict.  
 __call__ View source 
__call__(
    shape, dtype=None, **kwargs
)
 Returns a tensor object initialized to self.value.
 


 Args
  shape   Shape of the tensor.  
  dtype   Optional dtype of the tensor. If not specified, tf.keras.backend.floatx() is used, which default to float32 unless you configured it otherwise (via tf.keras.backend.set_floatx(float_dtype)).  
  **kwargs   Additional keyword arguments.
tf.keras.initializers.deserialize     View source on GitHub    Return an Initializer object from its config.  View aliases  Main aliases 
tf.initializers.deserialize Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.initializers.deserialize  
tf.keras.initializers.deserialize(
    config, custom_objects=None
)
tf.keras.initializers.get     View source on GitHub     View aliases  Main aliases 
tf.initializers.get Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.initializers.get  
tf.keras.initializers.get(
    identifier
)
tf.keras.initializers.GlorotNormal The Glorot normal initializer, also called Xavier normal initializer. Inherits From: VarianceScaling, Initializer  View aliases  Main aliases 
tf.initializers.GlorotNormal, tf.initializers.glorot_normal, tf.keras.initializers.glorot_normal  
tf.keras.initializers.GlorotNormal(
    seed=None
)
 Also available via the shortcut function tf.keras.initializers.glorot_normal. Draws samples from a truncated normal distribution centered on 0 with stddev = sqrt(2 / (fan_in + fan_out)) where fan_in is the number of input units in the weight tensor and fan_out is the number of output units in the weight tensor. Examples: 
# Standalone usage:
initializer = tf.keras.initializers.GlorotNormal()
values = initializer(shape=(2, 2))
 
# Usage in a Keras layer:
initializer = tf.keras.initializers.GlorotNormal()
layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

 


 Args
  seed   A Python integer. An initializer created with a given seed will always produce the same random tensor for a given shape and dtype.    References: Glorot et al., 2010 (pdf) Methods from_config View source 
@classmethod
from_config(
    config
)
 Instantiates an initializer from a configuration dictionary. Example: initializer = RandomUniform(-1, 1)
config = initializer.get_config()
initializer = RandomUniform.from_config(config)

 


 Args
  config   A Python dictionary. It will typically be the output of get_config.   
 


 Returns   An Initializer instance.  
 get_config View source 
get_config()
 Returns the configuration of the initializer as a JSON-serializable dict.
 


 Returns   A JSON-serializable Python dict.  
 __call__ View source 
__call__(
    shape, dtype=None, **kwargs
)
 Returns a tensor object initialized as specified by the initializer.
 


 Args
  shape   Shape of the tensor.  
  dtype   Optional dtype of the tensor. Only floating point types are supported. If not specified, tf.keras.backend.floatx() is used, which default to float32 unless you configured it otherwise (via tf.keras.backend.set_floatx(float_dtype))  
  **kwargs   Additional keyword arguments.
tf.keras.initializers.GlorotUniform The Glorot uniform initializer, also called Xavier uniform initializer. Inherits From: VarianceScaling, Initializer  View aliases  Main aliases 
tf.initializers.GlorotUniform, tf.initializers.glorot_uniform, tf.keras.initializers.glorot_uniform  
tf.keras.initializers.GlorotUniform(
    seed=None
)
 Also available via the shortcut function tf.keras.initializers.glorot_uniform. Draws samples from a uniform distribution within [-limit, limit], where limit = sqrt(6 / (fan_in + fan_out)) (fan_in is the number of input units in the weight tensor and fan_out is the number of output units). Examples: 
# Standalone usage:
initializer = tf.keras.initializers.GlorotUniform()
values = initializer(shape=(2, 2))
 
# Usage in a Keras layer:
initializer = tf.keras.initializers.GlorotUniform()
layer = tf.keras.layers.Dense(3, kernel_initializer=initializer)

 


 Args
  seed   A Python integer. An initializer created with a given seed will always produce the same random tensor for a given shape and dtype.    References: Glorot et al., 2010 (pdf) Methods from_config View source 
@classmethod
from_config(
    config
)
 Instantiates an initializer from a configuration dictionary. Example: initializer = RandomUniform(-1, 1)
config = initializer.get_config()
initializer = RandomUniform.from_config(config)

 


 Args
  config   A Python dictionary. It will typically be the output of get_config.   
 


 Returns   An Initializer instance.  
 get_config View source 
get_config()
 Returns the configuration of the initializer as a JSON-serializable dict.
 


 Returns   A JSON-serializable Python dict.  
 __call__ View source 
__call__(
    shape, dtype=None, **kwargs
)
 Returns a tensor object initialized as specified by the initializer.
 


 Args
  shape   Shape of the tensor.  
  dtype   Optional dtype of the tensor. Only floating point types are supported. If not specified, tf.keras.backend.floatx() is used, which default to float32 unless you configured it otherwise (via tf.keras.backend.set_floatx(float_dtype))  
  **kwargs   Additional keyword arguments.