neulab/docprompting-conala huggingface dataset:
tf.keras.layers.Cropping3D     View source on GitHub    Cropping layer for 3D data (e.g. spatial or spatio-temporal). Inherits From: Layer, Module  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.layers.Cropping3D  
tf.keras.layers.Cropping3D(
    cropping=((1, 1), (1, 1), (1, 1)), data_format=None, **kwargs
)
 Examples: 
input_shape = (2, 28, 28, 10, 3)
x = np.arange(np.prod(input_shape)).reshape(input_shape)
y = tf.keras.layers.Cropping3D(cropping=(2, 4, 2))(x)
print(y.shape)
(2, 24, 20, 6, 3)

 


 Arguments
  cropping   Int, or tuple of 3 ints, or tuple of 3 tuples of 2 ints.  If int: the same symmetric cropping is applied to depth, height, and width. If tuple of 3 ints: interpreted as two different symmetric cropping values for depth, height, and width: (symmetric_dim1_crop, symmetric_dim2_crop, symmetric_dim3_crop). If tuple of 3 tuples of 2 ints: interpreted as ((left_dim1_crop, right_dim1_crop), (left_dim2_crop, right_dim2_crop), (left_dim3_crop, right_dim3_crop)) 

 
  data_format   A string, one of channels_last (default) or channels_first. The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch_size, spatial_dim1, spatial_dim2, spatial_dim3, channels) while channels_first corresponds to inputs with shape (batch_size, channels, spatial_dim1, spatial_dim2, spatial_dim3). It defaults to the image_data_format value found in your Keras config file at ~/.keras/keras.json. If you never set it, then it will be "channels_last".    Input shape: 5D tensor with shape:  If data_format is "channels_last": (batch_size, first_axis_to_crop, second_axis_to_crop, third_axis_to_crop, depth)
 If data_format is "channels_first": (batch_size, depth, first_axis_to_crop, second_axis_to_crop, third_axis_to_crop)
  Output shape: 5D tensor with shape:  If data_format is "channels_last": (batch_size, first_cropped_axis, second_cropped_axis, third_cropped_axis, depth)
 If data_format is "channels_first": (batch_size, depth, first_cropped_axis, second_cropped_axis, third_cropped_axis)
tf.keras.layers.Dense     View source on GitHub    Just your regular densely-connected NN layer. Inherits From: Layer, Module  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.layers.Dense  
tf.keras.layers.Dense(
    units, activation=None, use_bias=True,
    kernel_initializer='glorot_uniform',
    bias_initializer='zeros', kernel_regularizer=None,
    bias_regularizer=None, activity_regularizer=None, kernel_constraint=None,
    bias_constraint=None, **kwargs
)
 Dense implements the operation: output = activation(dot(input, kernel) + bias) where activation is the element-wise activation function passed as the activation argument, kernel is a weights matrix created by the layer, and bias is a bias vector created by the layer (only applicable if use_bias is True). 
Note: If the input to the layer has a rank greater than 2, then Dense computes the dot product between the inputs and the kernel along the last axis of the inputs and axis 1 of the kernel (using tf.tensordot). For example, if input has dimensions (batch_size, d0, d1), then we create a kernel with shape (d1, units), and the kernel operates along axis 2 of the input, on every sub-tensor of shape (1, 1, d1) (there are batch_size * d0 such sub-tensors). The output in this case will have shape (batch_size, d0, units).
 Besides, layer attributes cannot be modified after the layer has been called once (except the trainable attribute). Example: 
# Create a `Sequential` model and add a Dense layer as the first layer.
model = tf.keras.models.Sequential()
model.add(tf.keras.Input(shape=(16,)))
model.add(tf.keras.layers.Dense(32, activation='relu'))
# Now the model will take as input arrays of shape (None, 16)
# and output arrays of shape (None, 32).
# Note that after the first layer, you don't need to specify
# the size of the input anymore:
model.add(tf.keras.layers.Dense(32))
model.output_shape
(None, 32)

 


 Arguments
  units   Positive integer, dimensionality of the output space.  
  activation   Activation function to use. If you don't specify anything, no activation is applied (ie. "linear" activation: a(x) = x).  
  use_bias   Boolean, whether the layer uses a bias vector.  
  kernel_initializer   Initializer for the kernel weights matrix.  
  bias_initializer   Initializer for the bias vector.  
  kernel_regularizer   Regularizer function applied to the kernel weights matrix.  
  bias_regularizer   Regularizer function applied to the bias vector.  
  activity_regularizer   Regularizer function applied to the output of the layer (its "activation").  
  kernel_constraint   Constraint function applied to the kernel weights matrix.  
  bias_constraint   Constraint function applied to the bias vector.    Input shape: N-D tensor with shape: (batch_size, ..., input_dim). The most common situation would be a 2D input with shape (batch_size, input_dim). Output shape: N-D tensor with shape: (batch_size, ..., units). For instance, for a 2D input with shape (batch_size, input_dim), the output would have shape (batch_size, units).
tf.keras.layers.DenseFeatures     View source on GitHub    A layer that produces a dense Tensor based on given feature_columns. Inherits From: DenseFeatures, Layer, Module 
tf.keras.layers.DenseFeatures(
    feature_columns, trainable=True, name=None, **kwargs
)
 Generally a single example in training data is described with FeatureColumns. At the first layer of the model, this column oriented data should be converted to a single Tensor. This layer can be called multiple times with different features. This is the V2 version of this layer that uses name_scopes to create variables instead of variable_scopes. But this approach currently lacks support for partitioned variables. In that case, use the V1 version instead. Example: price = tf.feature_column.numeric_column('price')
keywords_embedded = tf.feature_column.embedding_column(
    tf.feature_column.categorical_column_with_hash_bucket("keywords", 10K),
    dimensions=16)
columns = [price, keywords_embedded, ...]
feature_layer = tf.keras.layers.DenseFeatures(columns)

features = tf.io.parse_example(
    ..., features=tf.feature_column.make_parse_example_spec(columns))
dense_tensor = feature_layer(features)
for units in [128, 64, 32]:
  dense_tensor = tf.keras.layers.Dense(units, activation='relu')(dense_tensor)
prediction = tf.keras.layers.Dense(1)(dense_tensor)

 


 Args
  feature_columns   An iterable containing the FeatureColumns to use as inputs to your model. All items should be instances of classes derived from DenseColumn such as numeric_column, embedding_column, bucketized_column, indicator_column. If you have categorical features, you can wrap them with an embedding_column or indicator_column.  
  trainable   Boolean, whether the layer's variables will be updated via gradient descent during training.  
  name   Name to give to the DenseFeatures.  
  **kwargs   Keyword arguments to construct a layer.   
 


 Raises
  ValueError   if an item in feature_columns is not a DenseColumn.
tf.keras.layers.deserialize     View source on GitHub    Instantiates a layer from a config dictionary.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.layers.deserialize  
tf.keras.layers.deserialize(
    config, custom_objects=None
)

 


 Arguments
  config   dict of the form {'class_name': str, 'config': dict}  
  custom_objects   dict mapping class names (or function names) of custom (non-Keras) objects to class/functions   
 


 Returns   Layer instance (may be Model, Sequential, Network, Layer...)
tf.keras.layers.Dot     View source on GitHub    Layer that computes a dot product between samples in two tensors. Inherits From: Layer, Module  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.layers.Dot  
tf.keras.layers.Dot(
    axes, normalize=False, **kwargs
)
 E.g. if applied to a list of two tensors a and b of shape (batch_size, n), the output will be a tensor of shape (batch_size, 1) where each entry i will be the dot product between a[i] and b[i]. 
x = np.arange(10).reshape(1, 5, 2)
print(x)
[[[0 1]
  [2 3]
  [4 5]
  [6 7]
  [8 9]]]
y = np.arange(10, 20).reshape(1, 2, 5)
print(y)
[[[10 11 12 13 14]
  [15 16 17 18 19]]]
tf.keras.layers.Dot(axes=(1, 2))([x, y])
<tf.Tensor: shape=(1, 2, 2), dtype=int64, numpy=
array([[[260, 360],
        [320, 445]]])>
 
x1 = tf.keras.layers.Dense(8)(np.arange(10).reshape(5, 2))
x2 = tf.keras.layers.Dense(8)(np.arange(10, 20).reshape(5, 2))
dotted = tf.keras.layers.Dot(axes=1)([x1, x2])
dotted.shape
TensorShape([5, 1])

 


 Arguments
  axes   Integer or tuple of integers, axis or axes along which to take the dot product. If a tuple, should be two integers corresponding to the desired axis from the first input and the desired axis from the second input, respectively. Note that the size of the two selected axes must match.  
  normalize   Whether to L2-normalize samples along the dot product axis before taking the dot product. If set to True, then the output of the dot product is the cosine proximity between the two samples.  
  **kwargs   Standard layer keyword arguments.
tf.keras.layers.Dropout     View source on GitHub    Applies Dropout to the input. Inherits From: Layer, Module  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.layers.Dropout  
tf.keras.layers.Dropout(
    rate, noise_shape=None, seed=None, **kwargs
)
 The Dropout layer randomly sets input units to 0 with a frequency of rate at each step during training time, which helps prevent overfitting. Inputs not set to 0 are scaled up by 1/(1 - rate) such that the sum over all inputs is unchanged. Note that the Dropout layer only applies when training is set to True such that no values are dropped during inference. When using model.fit, training will be appropriately set to True automatically, and in other contexts, you can set the kwarg explicitly to True when calling the layer. (This is in contrast to setting trainable=False for a Dropout layer. trainable does not affect the layer's behavior, as Dropout does not have any variables/weights that can be frozen during training.) 
tf.random.set_seed(0)
layer = tf.keras.layers.Dropout(.2, input_shape=(2,))
data = np.arange(10).reshape(5, 2).astype(np.float32)
print(data)
[[0. 1.]
 [2. 3.]
 [4. 5.]
 [6. 7.]
 [8. 9.]]
outputs = layer(data, training=True)
print(outputs)
tf.Tensor(
[[ 0.    1.25]
 [ 2.5   3.75]
 [ 5.    6.25]
 [ 7.5   8.75]
 [10.    0.  ]], shape=(5, 2), dtype=float32)

 


 Arguments
  rate   Float between 0 and 1. Fraction of the input units to drop.  
  noise_shape   1D integer tensor representing the shape of the binary dropout mask that will be multiplied with the input. For instance, if your inputs have shape (batch_size, timesteps, features) and you want the dropout mask to be the same for all timesteps, you can use noise_shape=(batch_size, 1, features).  
  seed   A Python integer to use as random seed.    Call arguments:  
inputs: Input tensor (of any rank). 
training: Python boolean indicating whether the layer should behave in training mode (adding dropout) or in inference mode (doing nothing).
tf.keras.layers.ELU     View source on GitHub    Exponential Linear Unit. Inherits From: Layer, Module  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.layers.ELU  
tf.keras.layers.ELU(
    alpha=1.0, **kwargs
)
 It follows: f(x) =  alpha * (exp(x) - 1.) for x < 0
f(x) = x for x >= 0
 Input shape: Arbitrary. Use the keyword argument input_shape (tuple of integers, does not include the samples axis) when using this layer as the first layer in a model. Output shape: Same shape as the input.
 


 Arguments
  alpha   Scale for the negative factor.
tf.keras.layers.Embedding     View source on GitHub    Turns positive integers (indexes) into dense vectors of fixed size. Inherits From: Layer, Module  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.layers.Embedding  
tf.keras.layers.Embedding(
    input_dim, output_dim, embeddings_initializer='uniform',
    embeddings_regularizer=None, activity_regularizer=None,
    embeddings_constraint=None, mask_zero=False, input_length=None, **kwargs
)
 e.g. [[4], [20]] -> [[0.25, 0.1], [0.6, -0.2]] This layer can only be used as the first layer in a model. Example: 
model = tf.keras.Sequential()
model.add(tf.keras.layers.Embedding(1000, 64, input_length=10))
# The model will take as input an integer matrix of size (batch,
# input_length), and the largest integer (i.e. word index) in the input
# should be no larger than 999 (vocabulary size).
# Now model.output_shape is (None, 10, 64), where `None` is the batch
# dimension.
input_array = np.random.randint(1000, size=(32, 10))
model.compile('rmsprop', 'mse')
output_array = model.predict(input_array)
print(output_array.shape)
(32, 10, 64)

 


 Arguments
  input_dim   Integer. Size of the vocabulary, i.e. maximum integer index + 1.  
  output_dim   Integer. Dimension of the dense embedding.  
  embeddings_initializer   Initializer for the embeddings matrix (see keras.initializers).  
  embeddings_regularizer   Regularizer function applied to the embeddings matrix (see keras.regularizers).  
  embeddings_constraint   Constraint function applied to the embeddings matrix (see keras.constraints).  
  mask_zero   Boolean, whether or not the input value 0 is a special "padding" value that should be masked out. This is useful when using recurrent layers which may take variable length input. If this is True, then all subsequent layers in the model need to support masking or an exception will be raised. If mask_zero is set to True, as a consequence, index 0 cannot be used in the vocabulary (input_dim should equal size of vocabulary + 1).  
  input_length   Length of input sequences, when it is constant. This argument is required if you are going to connect Flatten then Dense layers upstream (without it, the shape of the dense outputs cannot be computed).    Input shape: 2D tensor with shape: (batch_size, input_length). Output shape: 3D tensor with shape: (batch_size, input_length, output_dim).
Module: tf.keras.layers.experimental Public API for tf.keras.layers.experimental namespace. Modules preprocessing module: Public API for tf.keras.layers.experimental.preprocessing namespace. Classes class EinsumDense: A layer that uses tf.einsum as the backing computation. class RandomFourierFeatures: Layer that projects its inputs into a random feature space. class SyncBatchNormalization: Normalize and scale inputs or activations synchronously across replicas.
Module: tf.keras.layers.experimental.preprocessing Public API for tf.keras.layers.experimental.preprocessing namespace. Classes class CategoryCrossing: Category crossing layer. class CategoryEncoding: Category encoding layer. class CenterCrop: Crop the central portion of the images to target height and width. class Discretization: Buckets data into discrete ranges. class Hashing: Implements categorical feature hashing, also known as "hashing trick". class IntegerLookup: Maps integers from a vocabulary to integer indices. class Normalization: Feature-wise normalization of the data. class PreprocessingLayer: Base class for PreprocessingLayers. class RandomContrast: Adjust the contrast of an image or images by a random factor. class RandomCrop: Randomly crop the images to target height and width. class RandomFlip: Randomly flip each image horizontally and vertically. class RandomHeight: Randomly vary the height of a batch of images during training. class RandomRotation: Randomly rotate each image. class RandomTranslation: Randomly translate each image during training. class RandomWidth: Randomly vary the width of a batch of images during training. class RandomZoom: Randomly zoom each image during training. class Rescaling: Multiply inputs by scale and adds offset. class Resizing: Image resizing layer. class StringLookup: Maps strings from a vocabulary to integer indices. class TextVectorization: Text vectorization layer.
tf.keras.layers.experimental.preprocessing.CategoryEncoding Category encoding layer. Inherits From: PreprocessingLayer, Layer, Module 
tf.keras.layers.experimental.preprocessing.CategoryEncoding(
    max_tokens=None, output_mode=BINARY, sparse=False, **kwargs
)
 This layer provides options for condensing data into a categorical encoding. It accepts integer values as inputs and outputs a dense representation (one sample = 1-index tensor of float values representing data about the sample's tokens) of those inputs. Examples: 
layer = tf.keras.layers.experimental.preprocessing.CategoryEncoding(
          max_tokens=4, output_mode="count")
layer([[0, 1], [0, 0], [1, 2], [3, 1]])
<tf.Tensor: shape=(4, 4), dtype=float32, numpy=
  array([[1., 1., 0., 0.],
         [2., 0., 0., 0.],
         [0., 1., 1., 0.],
         [0., 1., 0., 1.]], dtype=float32)>
 Examples with weighted inputs: 
layer = tf.keras.layers.experimental.preprocessing.CategoryEncoding(
          max_tokens=4, output_mode="count")
count_weights = np.array([[.1, .2], [.1, .1], [.2, .3], [.4, .2]])
layer([[0, 1], [0, 0], [1, 2], [3, 1]], count_weights=count_weights)
<tf.Tensor: shape=(4, 4), dtype=float64, numpy=
  array([[0.1, 0.2, 0. , 0. ],
         [0.2, 0. , 0. , 0. ],
         [0. , 0.2, 0.3, 0. ],
         [0. , 0.2, 0. , 0.4]])>
 Call arguments:  
inputs: A 2D tensor (samples, timesteps). 
count_weights: A 2D tensor in the same shape as inputs indicating the weight for each sample value when summing up in count mode. Not used in binary or tfidf mode. 
 


 Attributes
  max_tokens   The maximum size of the vocabulary for this layer. If None, there is no cap on the size of the vocabulary.  
  output_mode   Specification for the output of the layer. Defaults to "binary". Values can be "binary", "count" or "tf-idf", configuring the layer as follows: "binary": Outputs a single int array per batch, of either vocab_size or max_tokens size, containing 1s in all elements where the token mapped to that index exists at least once in the batch item. "count": As "binary", but the int array contains a count of the number of times the token at that index appeared in the batch item. "tf-idf": As "binary", but the TF-IDF algorithm is applied to find the value in each token slot.  
  sparse   Boolean. If true, returns a SparseTensor instead of a dense Tensor. Defaults to False.    Methods adapt View source 
adapt(
    data, reset_state=True
)
 Fits the state of the preprocessing layer to the dataset. Overrides the default adapt method to apply relevant preprocessing to the inputs before passing to the combiner.
 


 Arguments
  data   The data to train on. It can be passed either as a tf.data Dataset, or as a numpy array.  
  reset_state   Optional argument specifying whether to clear the state of the layer at the start of the call to adapt. This must be True for this layer, which does not support repeated calls to adapt.   
 


 Raises
  RuntimeError   if the layer cannot be adapted at this time.    set_num_elements View source 
set_num_elements(
    num_elements
)
 set_tfidf_data View source 
set_tfidf_data(
    tfidf_data
)
tf.keras.layers.experimental.preprocessing.CenterCrop Crop the central portion of the images to target height and width. Inherits From: PreprocessingLayer, Layer, Module  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.layers.experimental.preprocessing.CenterCrop  
tf.keras.layers.experimental.preprocessing.CenterCrop(
    height, width, name=None, **kwargs
)
 Input shape: 4D tensor with shape: (samples, height, width, channels), data_format='channels_last'. Output shape: 4D tensor with shape: (samples, target_height, target_width, channels). If the input height/width is even and the target height/width is odd (or inversely), the input image is left-padded by 1 pixel.
 


 Arguments
  height   Integer, the height of the output shape.  
  width   Integer, the width of the output shape.  
  name   A string, the name of the layer.    Methods adapt View source 
adapt(
    data, reset_state=True
)
 Fits the state of the preprocessing layer to the data being passed.
 


 Arguments
  data   The data to train on. It can be passed either as a tf.data Dataset, or as a numpy array.  
  reset_state   Optional argument specifying whether to clear the state of the layer at the start of the call to adapt, or whether to start from the existing state. This argument may not be relevant to all preprocessing layers: a subclass of PreprocessingLayer may choose to throw if 'reset_state' is set to False.
tf.keras.layers.experimental.preprocessing.Discretization Buckets data into discrete ranges. Inherits From: PreprocessingLayer, Layer, Module  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.keras.layers.experimental.preprocessing.Discretization  
tf.keras.layers.experimental.preprocessing.Discretization(
    bins, **kwargs
)
 This layer will place each element of its input data into one of several contiguous ranges and output an integer index indicating which range each element was placed in. Input shape: Any tf.Tensor or tf.RaggedTensor of dimension 2 or higher. Output shape: Same as input shape. Examples: Bucketize float values based on provided buckets. >>> input = np.array([[-1.5, 1.0, 3.4, .5], [0.0, 3.0, 1.3, 0.0]])
>>> layer = tf.keras.layers.experimental.preprocessing.Discretization(
...          bins=[0., 1., 2.])
>>> layer(input)
<tf.Tensor: shape=(2, 4), dtype=int32, numpy=
array([[0, 1, 3, 1],
       [0, 3, 2, 0]], dtype=int32)>

 


 Attributes
  bins   Optional boundary specification. Bins exclude the left boundary and include the right boundary, so bins=[0., 1., 2.] generates bins (-inf, 0.), [0., 1.), [1., 2.), and [2., +inf).    Methods adapt View source 
adapt(
    data, reset_state=True
)
 Fits the state of the preprocessing layer to the data being passed.
 


 Arguments
  data   The data to train on. It can be passed either as a tf.data Dataset, or as a numpy array.  
  reset_state   Optional argument specifying whether to clear the state of the layer at the start of the call to adapt, or whether to start from the existing state. This argument may not be relevant to all preprocessing layers: a subclass of PreprocessingLayer may choose to throw if 'reset_state' is set to False.