neulab/docprompting-conala huggingface dataset:
tf.keras.utils.get_file     View source on GitHub    Downloads a file from a URL if it not already in the cache.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.get_file  
tf.keras.utils.get_file(
    fname, origin, untar=False, md5_hash=None, file_hash=None,
    cache_subdir='datasets', hash_algorithm='auto',
    extract=False, archive_format='auto', cache_dir=None
)
 By default the file at the url origin is downloaded to the cache_dir ~/.keras, placed in the cache_subdir datasets, and given the filename fname. The final location of a file example.txt would therefore be ~/.keras/datasets/example.txt. Files in tar, tar.gz, tar.bz, and zip formats can also be extracted. Passing a hash will verify the file after download. The command line programs shasum and sha256sum can compute the hash. Example: path_to_downloaded_file = tf.keras.utils.get_file(
    "flower_photos",
    "https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz",
    untar=True)

 


 Arguments
  fname   Name of the file. If an absolute path /path/to/file.txt is specified the file will be saved at that location.  
  origin   Original URL of the file.  
  untar   Deprecated in favor of extract argument. boolean, whether the file should be decompressed  
  md5_hash   Deprecated in favor of file_hash argument. md5 hash of the file for verification  
  file_hash   The expected hash string of the file after download. The sha256 and md5 hash algorithms are both supported.  
  cache_subdir   Subdirectory under the Keras cache dir where the file is saved. If an absolute path /path/to/folder is specified the file will be saved at that location.  
  hash_algorithm   Select the hash algorithm to verify the file. options are 'md5', 'sha256', and 'auto'. The default 'auto' detects the hash algorithm in use.  
  extract   True tries extracting the file as an Archive, like tar or zip.  
  archive_format   Archive format to try for extracting the file. Options are 'auto', 'tar', 'zip', and None. 'tar' includes tar, tar.gz, and tar.bz files. The default 'auto' corresponds to ['tar', 'zip']. None or an empty list will return no matches found.  
  cache_dir   Location to store cached files, when None it defaults to the default directory ~/.keras/.   
 


 Returns   Path to the downloaded file
tf.keras.utils.get_registered_name Returns the name registered to an object within the Keras framework.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.get_registered_name  
tf.keras.utils.get_registered_name(
    obj
)
 This function is part of the Keras serialization and deserialization framework. It maps objects to the string names associated with those objects for serialization/deserialization.
 


 Args
  obj   The object to look up.   
 


 Returns   The name associated with the object, or the default Python name if the object is not registered.
tf.keras.utils.get_registered_object Returns the class associated with name if it is registered with Keras.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.get_registered_object  
tf.keras.utils.get_registered_object(
    name, custom_objects=None, module_objects=None
)
 This function is part of the Keras serialization and deserialization framework. It maps strings to the objects associated with them for serialization/deserialization. Example: def from_config(cls, config, custom_objects=None):
  if 'my_custom_object_name' in config:
    config['hidden_cls'] = tf.keras.utils.get_registered_object(
        config['my_custom_object_name'], custom_objects=custom_objects)

 


 Args
  name   The name to look up.  
  custom_objects   A dictionary of custom objects to look the name up in. Generally, custom_objects is provided by the user.  
  module_objects   A dictionary of custom objects to look the name up in. Generally, module_objects is provided by midlevel library implementers.   
 


 Returns   An instantiable class associated with 'name', or None if no such class exists.
tf.keras.utils.get_source_inputs     View source on GitHub    Returns the list of input tensors necessary to compute tensor.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.get_source_inputs  
tf.keras.utils.get_source_inputs(
    tensor, layer=None, node_index=None
)
 Output will always be a list of tensors (potentially with 1 element).
 


 Arguments
  tensor   The tensor to start from.  
  layer   Origin layer of the tensor. Will be determined via tensor._keras_history if not provided.  
  node_index   Origin node index of the tensor.   
 


 Returns   List of input tensors.
tf.keras.utils.model_to_dot     View source on GitHub    Convert a Keras model to dot format.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.model_to_dot  
tf.keras.utils.model_to_dot(
    model, show_shapes=False, show_dtype=False, show_layer_names=True,
    rankdir='TB', expand_nested=False, dpi=96, subgraph=False
)

 


 Arguments
  model   A Keras model instance.  
  show_shapes   whether to display shape information.  
  show_dtype   whether to display layer dtypes.  
  show_layer_names   whether to display layer names.  
  rankdir   rankdir argument passed to PyDot, a string specifying the format of the plot: 'TB' creates a vertical plot; 'LR' creates a horizontal plot.  
  expand_nested   whether to expand nested models into clusters.  
  dpi   Dots per inch.  
  subgraph   whether to return a pydot.Cluster instance.   
 


 Returns   A pydot.Dot instance representing the Keras model or a pydot.Cluster instance representing nested model if subgraph=True.  

 


 Raises
  ImportError   if graphviz or pydot are not available.
tf.keras.utils.normalize     View source on GitHub    Normalizes a Numpy array.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.normalize  
tf.keras.utils.normalize(
    x, axis=-1, order=2
)

 


 Arguments
  x   Numpy array to normalize.  
  axis   axis along which to normalize.  
  order   Normalization order (e.g. order=2 for L2 norm).   
 


 Returns   A normalized copy of the array.
tf.keras.utils.OrderedEnqueuer     View source on GitHub    Builds a Enqueuer from a Sequence. Inherits From: SequenceEnqueuer  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.OrderedEnqueuer  
tf.keras.utils.OrderedEnqueuer(
    sequence, use_multiprocessing=False, shuffle=False
)
 Used in fit_generator, evaluate_generator, predict_generator.
 


 Arguments
  sequence   A tf.keras.utils.data_utils.Sequence object.  
  use_multiprocessing   use multiprocessing if True, otherwise threading  
  shuffle   whether to shuffle the data at the beginning of each epoch    Methods get View source 
get()
 Creates a generator to extract data from the queue. Skip the data if it is None.
 


 Yields   The next element in the queue, i.e. a tuple (inputs, targets) or (inputs, targets, sample_weights).  
 is_running View source 
is_running()
 start View source 
start(
    workers=1, max_queue_size=10
)
 Starts the handler's workers.
 


 Arguments
  workers   Number of workers.  
  max_queue_size   queue size (when full, workers could block on put())    stop View source 
stop(
    timeout=None
)
 Stops running threads and wait for them to exit, if necessary. Should be called by the same thread which called start().
 


 Arguments
  timeout   maximum time to wait on thread.join()
tf.keras.utils.pack_x_y_sample_weight Packs user-provided data into a tuple. 
tf.keras.utils.pack_x_y_sample_weight(
    x, y=None, sample_weight=None
)
 This is a convenience utility for packing data into the tuple formats that Model.fit uses. Standalone usage: 
x = tf.ones((10, 1))
data = tf.keras.utils.pack_x_y_sample_weight(x)
isinstance(data, tf.Tensor)
True
y = tf.ones((10, 1))
data = tf.keras.utils.pack_x_y_sample_weight(x, y)
isinstance(data, tuple)
True
x, y = data

 


 Arguments
  x   Features to pass to Model.  
  y   Ground-truth targets to pass to Model.  
  sample_weight   Sample weight for each element.   
 


 Returns   Tuple in the format used in Model.fit.
tf.keras.utils.plot_model     View source on GitHub    Converts a Keras model to dot format and save to a file.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.plot_model  
tf.keras.utils.plot_model(
    model, to_file='model.png', show_shapes=False, show_dtype=False,
    show_layer_names=True, rankdir='TB', expand_nested=False, dpi=96
)
 Example: input = tf.keras.Input(shape=(100,), dtype='int32', name='input')
x = tf.keras.layers.Embedding(
    output_dim=512, input_dim=10000, input_length=100)(input)
x = tf.keras.layers.LSTM(32)(x)
x = tf.keras.layers.Dense(64, activation='relu')(x)
x = tf.keras.layers.Dense(64, activation='relu')(x)
x = tf.keras.layers.Dense(64, activation='relu')(x)
output = tf.keras.layers.Dense(1, activation='sigmoid', name='output')(x)
model = tf.keras.Model(inputs=[input], outputs=[output])
dot_img_file = '/tmp/model_1.png'
tf.keras.utils.plot_model(model, to_file=dot_img_file, show_shapes=True)

 


 Arguments
  model   A Keras model instance  
  to_file   File name of the plot image.  
  show_shapes   whether to display shape information.  
  show_dtype   whether to display layer dtypes.  
  show_layer_names   whether to display layer names.  
  rankdir   rankdir argument passed to PyDot, a string specifying the format of the plot: 'TB' creates a vertical plot; 'LR' creates a horizontal plot.  
  expand_nested   Whether to expand nested models into clusters.  
  dpi   Dots per inch.   
 


 Returns   A Jupyter notebook Image object if Jupyter is installed. This enables in-line display of the model plots in notebooks.
tf.keras.utils.Progbar     View source on GitHub    Displays a progress bar.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.Progbar  
tf.keras.utils.Progbar(
    target, width=30, verbose=1, interval=0.05, stateful_metrics=None,
    unit_name='step'
)

 


 Arguments
  target   Total number of steps expected, None if unknown.  
  width   Progress bar width on screen.  
  verbose   Verbosity mode, 0 (silent), 1 (verbose), 2 (semi-verbose)  
  stateful_metrics   Iterable of string names of metrics that should not be averaged over time. Metrics in this list will be displayed as-is. All others will be averaged by the progbar before display.  
  interval   Minimum visual progress update interval (in seconds).  
  unit_name   Display name for step counts (usually "step" or "sample").    Methods add View source 
add(
    n, values=None
)
 update View source 
update(
    current, values=None, finalize=None
)
 Updates the progress bar.
 


 Arguments
  current   Index of current step.  
  values   List of tuples: (name, value_for_last_step). If name is in stateful_metrics, value_for_last_step will be displayed as-is. Else, an average of the metric over time will be displayed.  
  finalize   Whether this is the last update for the progress bar. If None, defaults to current >= self.target.
tf.keras.utils.register_keras_serializable Registers an object with the Keras serialization framework.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.register_keras_serializable  
tf.keras.utils.register_keras_serializable(
    package='Custom', name=None
)
 This decorator injects the decorated class or function into the Keras custom object dictionary, so that it can be serialized and deserialized without needing an entry in the user-provided custom object dict. It also injects a function that Keras will call to get the object's serializable string key. Note that to be serialized and deserialized, classes must implement the get_config() method. Functions do not have this requirement. The object will be registered under the key 'package>name' where name, defaults to the object name if not passed.
 


 Arguments
  package   The package that this class belongs to.  
  name   The name to serialize this class under in this package. If None, the class' name will be used.   
 


 Returns   A decorator that registers the decorated class with the passed names.
tf.keras.utils.Sequence     View source on GitHub    Base object for fitting to a sequence of data, such as a dataset.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.Sequence  Every Sequence must implement the __getitem__ and the __len__ methods. If you want to modify your dataset between epochs you may implement on_epoch_end. The method __getitem__ should return a complete batch. Notes: Sequence are a safer way to do multiprocessing. This structure guarantees that the network will only train once on each sample per epoch which is not the case with generators. Examples: from skimage.io import imread
from skimage.transform import resize
import numpy as np
import math

# Here, `x_set` is list of path to the images
# and `y_set` are the associated classes.

class CIFAR10Sequence(Sequence):

    def __init__(self, x_set, y_set, batch_size):
        self.x, self.y = x_set, y_set
        self.batch_size = batch_size

    def __len__(self):
        return math.ceil(len(self.x) / self.batch_size)

    def __getitem__(self, idx):
        batch_x = self.x[idx * self.batch_size:(idx + 1) *
        self.batch_size]
        batch_y = self.y[idx * self.batch_size:(idx + 1) *
        self.batch_size]

        return np.array([
            resize(imread(file_name), (200, 200))
               for file_name in batch_x]), np.array(batch_y)
 Methods on_epoch_end View source 
on_epoch_end()
 Method called at the end of every epoch. __getitem__ View source 
__getitem__(
    index
)
 Gets batch at position index.
 


 Arguments
  index   position of the batch in the Sequence.   
 


 Returns   A batch  
 __iter__ View source 
__iter__()
 Create a generator that iterate over the Sequence. __len__ View source 
__len__()
 Number of batch in the Sequence.
 


 Returns   The number of batches in the Sequence.
tf.keras.utils.SequenceEnqueuer     View source on GitHub    Base class to enqueue inputs.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.SequenceEnqueuer  
tf.keras.utils.SequenceEnqueuer(
    sequence, use_multiprocessing=False
)
 The task of an Enqueuer is to use parallelism to speed up preprocessing. This is done with processes or threads. Example: enqueuer = SequenceEnqueuer(...)
enqueuer.start()
datas = enqueuer.get()
for data in datas:
    # Use the inputs; training, evaluating, predicting.
    # ... stop sometime.
enqueuer.stop()
 The enqueuer.get() should be an infinite stream of datas. Methods get View source 
get()
 Creates a generator to extract data from the queue. Skip the data if it is None. Returns: Generator yielding tuples (inputs, targets) or (inputs, targets, sample_weights). is_running View source 
is_running()
 start View source 
start(
    workers=1, max_queue_size=10
)
 Starts the handler's workers.
 


 Arguments
  workers   Number of workers.  
  max_queue_size   queue size (when full, workers could block on put())    stop View source 
stop(
    timeout=None
)
 Stops running threads and wait for them to exit, if necessary. Should be called by the same thread which called start().
 


 Arguments
  timeout   maximum time to wait on thread.join()
tf.keras.utils.serialize_keras_object     View source on GitHub    Serialize a Keras object into a JSON-compatible representation.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.serialize_keras_object  
tf.keras.utils.serialize_keras_object(
    instance
)
tf.keras.utils.to_categorical     View source on GitHub    Converts a class vector (integers) to binary class matrix.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.utils.to_categorical  
tf.keras.utils.to_categorical(
    y, num_classes=None, dtype='float32'
)
 E.g. for use with categorical_crossentropy.
 


 Arguments
  y   class vector to be converted into a matrix (integers from 0 to num_classes).  
  num_classes   total number of classes. If None, this would be inferred as the (largest number in y) + 1.  
  dtype   The data type expected by the input. Default: 'float32'.   
 


 Returns   A binary matrix representation of the input. The classes axis is placed last.  
 Example: 
a = tf.keras.utils.to_categorical([0, 1, 2, 3], num_classes=4)
a = tf.constant(a, shape=[4, 4])
print(a)
tf.Tensor(
  [[1. 0. 0. 0.]
   [0. 1. 0. 0.]
   [0. 0. 1. 0.]
   [0. 0. 0. 1.]], shape=(4, 4), dtype=float32)
 
b = tf.constant([.9, .04, .03, .03,
                 .3, .45, .15, .13,
                 .04, .01, .94, .05,
                 .12, .21, .5, .17],
                shape=[4, 4])
loss = tf.keras.backend.categorical_crossentropy(a, b)
print(np.around(loss, 5))
[0.10536 0.82807 0.1011  1.77196]
 
loss = tf.keras.backend.categorical_crossentropy(a, a)
print(np.around(loss, 5))
[0. 0. 0. 0.]

 


 Raises   Value Error: If input contains string value
tf.keras.utils.unpack_x_y_sample_weight Unpacks user-provided data tuple. 
tf.keras.utils.unpack_x_y_sample_weight(
    data
)
 This is a convenience utility to be used when overriding Model.train_step, Model.test_step, or Model.predict_step. This utility makes it easy to support data of the form (x,), (x, y), or (x, y, sample_weight). Standalone usage: 
features_batch = tf.ones((10, 5))
labels_batch = tf.zeros((10, 5))
data = (features_batch, labels_batch)
# `y` and `sample_weight` will default to `None` if not provided.
x, y, sample_weight = tf.keras.utils.unpack_x_y_sample_weight(data)
sample_weight is None
True
 Example in overridden Model.train_step: class MyModel(tf.keras.Model):

  def train_step(self, data):
    # If `sample_weight` is not provided, all samples will be weighted
    # equally.
    x, y, sample_weight = tf.keras.utils.unpack_x_y_sample_weight(data)

    with tf.GradientTape() as tape:
      y_pred = self(x, training=True)
      loss = self.compiled_loss(
        y, y_pred, sample_weight, regularization_losses=self.losses)
      trainable_variables = self.trainable_variables
      gradients = tape.gradient(loss, trainable_variables)
      self.optimizer.apply_gradients(zip(gradients, trainable_variables))

    self.compiled_metrics.update_state(y, y_pred, sample_weight)
    return {m.name: m.result() for m in self.metrics}

 


 Arguments
  data   A tuple of the form (x,), (x, y), or (x, y, sample_weight).   
 


 Returns   The unpacked tuple, with Nones for y and sample_weight if they are not provided.
Module: tf.keras.wrappers Public API for tf.keras.wrappers namespace. Modules scikit_learn module: Wrapper for using the Scikit-Learn API with Keras models.
Module: tf.keras.wrappers.scikit_learn Wrapper for using the Scikit-Learn API with Keras models. Classes class KerasClassifier: Implementation of the scikit-learn classifier API for Keras. class KerasRegressor: Implementation of the scikit-learn regressor API for Keras.
tf.keras.wrappers.scikit_learn.KerasRegressor     View source on GitHub    Implementation of the scikit-learn regressor API for Keras.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.wrappers.scikit_learn.KerasRegressor  
tf.keras.wrappers.scikit_learn.KerasRegressor(
    build_fn=None, **sk_params
)
 Methods check_params View source 
check_params(
    params
)
 Checks for user typos in params.
 


 Arguments
  params   dictionary; the parameters to be checked   
 


 Raises
  ValueError   if any member of params is not a valid argument.    filter_sk_params View source 
filter_sk_params(
    fn, override=None
)
 Filters sk_params and returns those in fn's arguments.
 


 Arguments
  fn   arbitrary function  
  override   dictionary, values to override sk_params   
 


 Returns
  res   dictionary containing variables in both sk_params and fn's arguments.    fit View source 
fit(
    x, y, **kwargs
)
 Constructs a new model with build_fn & fit the model to (x, y).
 


 Arguments
  x   array-like, shape (n_samples, n_features) Training samples where n_samples is the number of samples and n_features is the number of features.  
  y   array-like, shape (n_samples,) or (n_samples, n_outputs) True labels for x.  
  **kwargs   dictionary arguments Legal arguments are the arguments of Sequential.fit   
 


 Returns
  history   object details about the training history at each epoch.    get_params View source 
get_params(
    **params
)
 Gets parameters for this estimator.
 


 Arguments
  **params   ignored (exists for API compatibility).   
 


 Returns   Dictionary of parameter names mapped to their values.  
 predict View source 
predict(
    x, **kwargs
)
 Returns predictions for the given test data.
 


 Arguments
  x   array-like, shape (n_samples, n_features) Test samples where n_samples is the number of samples and n_features is the number of features.  
  **kwargs   dictionary arguments Legal arguments are the arguments of Sequential.predict.   
 


 Returns
  preds   array-like, shape (n_samples,) Predictions.    score View source 
score(
    x, y, **kwargs
)
 Returns the mean loss on the given test data and labels.
 


 Arguments
  x   array-like, shape (n_samples, n_features) Test samples where n_samples is the number of samples and n_features is the number of features.  
  y   array-like, shape (n_samples,) True labels for x.  
  **kwargs   dictionary arguments Legal arguments are the arguments of Sequential.evaluate.   
 


 Returns
  score   float Mean accuracy of predictions on x wrt. y.    set_params View source 
set_params(
    **params
)
 Sets the parameters of this estimator.
 


 Arguments
  **params   Dictionary of parameter names mapped to their values.   
 


 Returns   self
tf.linalg.adjoint     View source on GitHub    Transposes the last two dimensions of and conjugates tensor matrix.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.linalg.adjoint  
tf.linalg.adjoint(
    matrix, name=None
)
 For example: x = tf.constant([[1 + 1j, 2 + 2j, 3 + 3j],
                 [4 + 4j, 5 + 5j, 6 + 6j]])
tf.linalg.adjoint(x)  # [[1 - 1j, 4 - 4j],
                      #  [2 - 2j, 5 - 5j],
                      #  [3 - 3j, 6 - 6j]]

 


 Args
  matrix   A Tensor. Must be float16, float32, float64, complex64, or complex128 with shape [..., M, M].  
  name   A name to give this Op (optional).   
 


 Returns   The adjoint (a.k.a. Hermitian transpose a.k.a. conjugate transpose) of matrix.