neulab/docprompting-conala huggingface dataset:
tf.init_scope     View source on GitHub    A context manager that lifts ops out of control-flow scopes and function-building graphs.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.init_scope  
@tf_contextlib.contextmanager
tf.init_scope()
 There is often a need to lift variable initialization ops out of control-flow scopes, function-building graphs, and gradient tapes. Entering an init_scope is a mechanism for satisfying these desiderata. In particular, entering an init_scope has three effects: (1) All control dependencies are cleared the moment the scope is entered; this is equivalent to entering the context manager returned from control_dependencies(None), which has the side-effect of exiting control-flow scopes like tf.cond and tf.while_loop. (2) All operations that are created while the scope is active are lifted into the lowest context on the context_stack that is not building a graph function. Here, a context is defined as either a graph or an eager context. Every context switch, i.e., every installation of a graph as the default graph and every switch into eager mode, is logged in a thread-local stack called context_switches; the log entry for a context switch is popped from the stack when the context is exited. Entering an init_scope is equivalent to crawling up context_switches, finding the first context that is not building a graph function, and entering it. A caveat is that if graph mode is enabled but the default graph stack is empty, then entering an init_scope will simply install a fresh graph as the default one. (3) The gradient tape is paused while the scope is active. When eager execution is enabled, code inside an init_scope block runs with eager execution enabled even when tracing a tf.function. For example: tf.compat.v1.enable_eager_execution()

@tf.function
def func():
  # A function constructs TensorFlow graphs,
  # it does not execute eagerly.
  assert not tf.executing_eagerly()
  with tf.init_scope():
    # Initialization runs with eager execution enabled
    assert tf.executing_eagerly()

 


 Raises
  RuntimeError   if graph state is incompatible with this initialization.
tf.inside_function Indicates whether the caller code is executing inside a tf.function. 
tf.inside_function()

 


 Returns   Boolean, True if the caller code is executing inside a tf.function rather than eagerly.  
 Example: 
tf.inside_function()
False
@tf.function
def f():
  print(tf.inside_function())
f()
True
Module: tf.io Public API for tf.io namespace. Modules gfile module: Public API for tf.io.gfile namespace. Classes class FixedLenFeature: Configuration for parsing a fixed-length input feature. class FixedLenSequenceFeature: Configuration for parsing a variable-length input feature into a Tensor. class RaggedFeature: Configuration for passing a RaggedTensor input feature. class SparseFeature: Configuration for parsing a sparse input feature from an Example. class TFRecordOptions: Options used for manipulating TFRecord files. class TFRecordWriter: A class to write records to a TFRecords file. class VarLenFeature: Configuration for parsing a variable-length input feature. Functions decode_and_crop_jpeg(...): Decode and Crop a JPEG-encoded image to a uint8 tensor. decode_base64(...): Decode web-safe base64-encoded strings. decode_bmp(...): Decode the first frame of a BMP-encoded image to a uint8 tensor. decode_compressed(...): Decompress strings. decode_csv(...): Convert CSV records to tensors. Each column maps to one tensor. decode_gif(...): Decode the frame(s) of a GIF-encoded image to a uint8 tensor. decode_image(...): Function for decode_bmp, decode_gif, decode_jpeg, and decode_png. decode_jpeg(...): Decode a JPEG-encoded image to a uint8 tensor. decode_json_example(...): Convert JSON-encoded Example records to binary protocol buffer strings. decode_png(...): Decode a PNG-encoded image to a uint8 or uint16 tensor. decode_proto(...): The op extracts fields from a serialized protocol buffers message into tensors. decode_raw(...): Convert raw byte strings into tensors. deserialize_many_sparse(...): Deserialize and concatenate SparseTensors from a serialized minibatch. encode_base64(...): Encode strings into web-safe base64 format. encode_jpeg(...): JPEG-encode an image. encode_png(...): PNG-encode an image. encode_proto(...): The op serializes protobuf messages provided in the input tensors. extract_jpeg_shape(...): Extract the shape information of a JPEG-encoded image. is_jpeg(...): Convenience function to check if the 'contents' encodes a JPEG image. match_filenames_once(...): Save the list of files matching pattern, so it is only computed once. matching_files(...): Returns the set of files matching one or more glob patterns. parse_example(...): Parses Example protos into a dict of tensors. parse_sequence_example(...): Parses a batch of SequenceExample protos. parse_single_example(...): Parses a single Example proto. parse_single_sequence_example(...): Parses a single SequenceExample proto. parse_tensor(...): Transforms a serialized tensorflow.TensorProto proto into a Tensor. read_file(...): Reads and outputs the entire contents of the input filename. serialize_many_sparse(...): Serialize N-minibatch SparseTensor into an [N, 3] Tensor. serialize_sparse(...): Serialize a SparseTensor into a 3-vector (1-D Tensor) object. serialize_tensor(...): Transforms a Tensor into a serialized TensorProto proto. write_file(...): Writes contents to the file at input filename. Creates file and recursively write_graph(...): Writes a graph proto to a file.
tf.io.decode_and_crop_jpeg Decode and Crop a JPEG-encoded image to a uint8 tensor.  View aliases  Main aliases 
tf.image.decode_and_crop_jpeg Compat aliases for migration See Migration guide for more details. tf.compat.v1.image.decode_and_crop_jpeg, tf.compat.v1.io.decode_and_crop_jpeg  
tf.io.decode_and_crop_jpeg(
    contents, crop_window, channels=0, ratio=1, fancy_upscaling=True,
    try_recover_truncated=False, acceptable_fraction=1, dct_method='',
    name=None
)
 The attr channels indicates the desired number of color channels for the decoded image. Accepted values are:  0: Use the number of channels in the JPEG-encoded image. 1: output a grayscale image. 3: output an RGB image.  If needed, the JPEG-encoded image is transformed to match the requested number of color channels. The attr ratio allows downscaling the image by an integer factor during decoding. Allowed values are: 1, 2, 4, and 8. This is much faster than downscaling the image later. It is equivalent to a combination of decode and crop, but much faster by only decoding partial jpeg image.
 


 Args
  contents   A Tensor of type string. 0-D. The JPEG-encoded image.  
  crop_window   A Tensor of type int32. 1-D. The crop window: [crop_y, crop_x, crop_height, crop_width].  
  channels   An optional int. Defaults to 0. Number of color channels for the decoded image.  
  ratio   An optional int. Defaults to 1. Downscaling ratio.  
  fancy_upscaling   An optional bool. Defaults to True. If true use a slower but nicer upscaling of the chroma planes (yuv420/422 only).  
  try_recover_truncated   An optional bool. Defaults to False. If true try to recover an image from truncated input.  
  acceptable_fraction   An optional float. Defaults to 1. The minimum required fraction of lines before a truncated input is accepted.  
  dct_method   An optional string. Defaults to "". string specifying a hint about the algorithm used for decompression. Defaults to "" which maps to a system-specific default. Currently valid values are ["INTEGER_FAST", "INTEGER_ACCURATE"]. The hint may be ignored (e.g., the internal jpeg library changes to a version that does not have that specific option.)  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type uint8.
tf.io.decode_base64 Decode web-safe base64-encoded strings.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.decode_base64, tf.compat.v1.io.decode_base64  
tf.io.decode_base64(
    input, name=None
)
 Input may or may not have padding at the end. See EncodeBase64 for padding. Web-safe means that input must use - and _ instead of + and /.
 


 Args
  input   A Tensor of type string. Base64 strings to decode.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type string.
tf.io.decode_bmp Decode the first frame of a BMP-encoded image to a uint8 tensor.  View aliases  Main aliases 
tf.image.decode_bmp Compat aliases for migration See Migration guide for more details. tf.compat.v1.image.decode_bmp, tf.compat.v1.io.decode_bmp  
tf.io.decode_bmp(
    contents, channels=0, name=None
)
 The attr channels indicates the desired number of color channels for the decoded image. Accepted values are:  0: Use the number of channels in the BMP-encoded image. 3: output an RGB image. 4: output an RGBA image. 
 


 Args
  contents   A Tensor of type string. 0-D. The BMP-encoded image.  
  channels   An optional int. Defaults to 0.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type uint8.
tf.io.decode_compressed Decompress strings.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.decode_compressed, tf.compat.v1.io.decode_compressed  
tf.io.decode_compressed(
    bytes, compression_type='', name=None
)
 This op decompresses each element of the bytes input Tensor, which is assumed to be compressed using the given compression_type. The output is a string Tensor of the same shape as bytes, each element containing the decompressed data from the corresponding element in bytes.
 


 Args
  bytes   A Tensor of type string. A Tensor of string which is compressed.  
  compression_type   An optional string. Defaults to "". A scalar containing either (i) the empty string (no compression), (ii) "ZLIB", or (iii) "GZIP".  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type string.
tf.io.decode_csv     View source on GitHub    Convert CSV records to tensors. Each column maps to one tensor. 
tf.io.decode_csv(
    records, record_defaults, field_delim=',', use_quote_delim=True,
    na_value='', select_cols=None, name=None
)
 RFC 4180 format is expected for the CSV records. (https://tools.ietf.org/html/rfc4180) Note that we allow leading and trailing spaces with int or float field.
 


 Args
  records   A Tensor of type string. Each string is a record/row in the csv and all records should have the same format.  
  record_defaults   A list of Tensor objects with specific types. Acceptable types are float32, float64, int32, int64, string. One tensor per column of the input record, with either a scalar default value for that column or an empty vector if the column is required.  
  field_delim   An optional string. Defaults to ",". char delimiter to separate fields in a record.  
  use_quote_delim   An optional bool. Defaults to True. If false, treats double quotation marks as regular characters inside of the string fields (ignoring RFC 4180, Section 2, Bullet 5).  
  na_value   Additional string to recognize as NA/NaN.  
  select_cols   Optional sorted list of column indices to select. If specified, only this subset of columns will be parsed and returned.  
  name   A name for the operation (optional).   
 


 Returns   A list of Tensor objects. Has the same type as record_defaults. Each tensor will have the same shape as records.  

 


 Raises
  ValueError   If any of the arguments is malformed.
tf.io.decode_gif   Decode the frame(s) of a GIF-encoded image to a uint8 tensor.  View aliases  Main aliases 
tf.image.decode_gif Compat aliases for migration See Migration guide for more details. tf.compat.v1.image.decode_gif, tf.compat.v1.io.decode_gif  
tf.io.decode_gif(
    contents, name=None
)
 GIF images with frame or transparency compression are not supported. On Linux and MacOS systems, convert animated GIFs from compressed to uncompressed by running: convert $src.gif -coalesce $dst.gif
 This op also supports decoding JPEGs and PNGs, though it is cleaner to use tf.io.decode_image.
 


 Args
  contents   A Tensor of type string. 0-D. The GIF-encoded image.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type uint8.
tf.io.decode_image     View source on GitHub    Function for decode_bmp, decode_gif, decode_jpeg, and decode_png.  View aliases  Main aliases 
tf.image.decode_image Compat aliases for migration See Migration guide for more details. tf.compat.v1.image.decode_image, tf.compat.v1.io.decode_image  
tf.io.decode_image(
    contents, channels=None, dtype=tf.dtypes.uint8, name=None,
    expand_animations=True
)
 Detects whether an image is a BMP, GIF, JPEG, or PNG, and performs the appropriate operation to convert the input bytes string into a Tensor of type dtype. 
Note: decode_gif returns a 4-D array [num_frames, height, width, 3], as opposed to decode_bmp, decode_jpeg and decode_png, which return 3-D arrays [height, width, num_channels]. Make sure to take this into account when constructing your graph if you are intermixing GIF files with BMP, JPEG, and/or PNG files. Alternately, set the expand_animations argument of this function to False, in which case the op will return 3-dimensional tensors and will truncate animated GIF files to the first frame.


Note: If the first frame of an animated GIF does not occupy the entire canvas (maximum frame width x maximum frame height), then it fills the unoccupied areas (in the first frame) with zeros (black). For frames after the first frame that does not occupy the entire canvas, it uses the previous frame to fill the unoccupied areas.

 


 Args
  contents   0-D string. The encoded image bytes.  
  channels   An optional int. Defaults to 0. Number of color channels for the decoded image.  
  dtype   The desired DType of the returned Tensor.  
  name   A name for the operation (optional)  
  expand_animations   Controls the shape of the returned op's output. If True, the returned op will produce a 3-D tensor for PNG, JPEG, and BMP files; and a 4-D tensor for all GIFs, whether animated or not. If, False, the returned op will produce a 3-D tensor for all file types and will truncate animated GIFs to the first frame.   
 


 Returns   Tensor with type dtype and a 3- or 4-dimensional shape, depending on the file type and the value of the expand_animations parameter.  

 


 Raises
  ValueError   On incorrect number of channels.
tf.io.decode_jpeg Decode a JPEG-encoded image to a uint8 tensor.  View aliases  Main aliases 
tf.image.decode_jpeg Compat aliases for migration See Migration guide for more details. tf.compat.v1.image.decode_jpeg, tf.compat.v1.io.decode_jpeg  
tf.io.decode_jpeg(
    contents, channels=0, ratio=1, fancy_upscaling=True,
    try_recover_truncated=False, acceptable_fraction=1, dct_method='',
    name=None
)
 The attr channels indicates the desired number of color channels for the decoded image. Accepted values are:  0: Use the number of channels in the JPEG-encoded image. 1: output a grayscale image. 3: output an RGB image.  If needed, the JPEG-encoded image is transformed to match the requested number of color channels. The attr ratio allows downscaling the image by an integer factor during decoding. Allowed values are: 1, 2, 4, and 8. This is much faster than downscaling the image later. This op also supports decoding PNGs and non-animated GIFs since the interface is the same, though it is cleaner to use tf.io.decode_image.
 


 Args
  contents   A Tensor of type string. 0-D. The JPEG-encoded image.  
  channels   An optional int. Defaults to 0. Number of color channels for the decoded image.  
  ratio   An optional int. Defaults to 1. Downscaling ratio.  
  fancy_upscaling   An optional bool. Defaults to True. If true use a slower but nicer upscaling of the chroma planes (yuv420/422 only).  
  try_recover_truncated   An optional bool. Defaults to False. If true try to recover an image from truncated input.  
  acceptable_fraction   An optional float. Defaults to 1. The minimum required fraction of lines before a truncated input is accepted.  
  dct_method   An optional string. Defaults to "". string specifying a hint about the algorithm used for decompression. Defaults to "" which maps to a system-specific default. Currently valid values are ["INTEGER_FAST", "INTEGER_ACCURATE"]. The hint may be ignored (e.g., the internal jpeg library changes to a version that does not have that specific option.)  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type uint8.
tf.io.decode_json_example Convert JSON-encoded Example records to binary protocol buffer strings.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.decode_json_example, tf.compat.v1.io.decode_json_example  
tf.io.decode_json_example(
    json_examples, name=None
)
 This op translates a tensor containing Example records, encoded using the standard JSON mapping, into a tensor containing the same records encoded as binary protocol buffers. The resulting tensor can then be fed to any of the other Example-parsing ops.
 


 Args
  json_examples   A Tensor of type string. Each string is a JSON object serialized according to the JSON mapping of the Example proto.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type string.
tf.io.decode_png Decode a PNG-encoded image to a uint8 or uint16 tensor.  View aliases  Main aliases 
tf.image.decode_png Compat aliases for migration See Migration guide for more details. tf.compat.v1.image.decode_png, tf.compat.v1.io.decode_png  
tf.io.decode_png(
    contents, channels=0, dtype=tf.dtypes.uint8, name=None
)
 The attr channels indicates the desired number of color channels for the decoded image. Accepted values are:  0: Use the number of channels in the PNG-encoded image. 1: output a grayscale image. 3: output an RGB image. 4: output an RGBA image.  If needed, the PNG-encoded image is transformed to match the requested number of color channels. This op also supports decoding JPEGs and non-animated GIFs since the interface is the same, though it is cleaner to use tf.io.decode_image.
 


 Args
  contents   A Tensor of type string. 0-D. The PNG-encoded image.  
  channels   An optional int. Defaults to 0. Number of color channels for the decoded image.  
  dtype   An optional tf.DType from: tf.uint8, tf.uint16. Defaults to tf.uint8.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type dtype.
tf.io.decode_raw Convert raw byte strings into tensors. 
tf.io.decode_raw(
    input_bytes, out_type, little_endian=True, fixed_length=None, name=None
)

 


 Args
  input_bytes   Each element of the input Tensor is converted to an array of bytes.  
  out_type   DType of the output. Acceptable types are half, float, double, int32, uint16, uint8, int16, int8, int64.  
  little_endian   Whether the input_bytes data is in little-endian format. Data will be converted into host byte order if necessary.  
  fixed_length   If set, the first fixed_length bytes of each element will be converted. Data will be zero-padded or truncated to the specified length. fixed_length must be a multiple of the size of out_type. fixed_length must be specified if the elements of input_bytes are of variable length. 
 
  name   A name for the operation (optional).   
 


 Returns   A Tensor object storing the decoded bytes.
tf.io.deserialize_many_sparse     View source on GitHub    Deserialize and concatenate SparseTensors from a serialized minibatch.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.deserialize_many_sparse, tf.compat.v1.io.deserialize_many_sparse  
tf.io.deserialize_many_sparse(
    serialized_sparse, dtype, rank=None, name=None
)
 The input serialized_sparse must be a string matrix of shape [N x 3] where N is the minibatch size and the rows correspond to packed outputs of serialize_sparse. The ranks of the original SparseTensor objects must all match. When the final SparseTensor is created, it has rank one higher than the ranks of the incoming SparseTensor objects (they have been concatenated along a new row dimension). The output SparseTensor object's shape values for all dimensions but the first are the max across the input SparseTensor objects' shape values for the corresponding dimensions. Its first shape value is N, the minibatch size. The input SparseTensor objects' indices are assumed ordered in standard lexicographic order. If this is not the case, after this step run sparse.reorder to restore index ordering. For example, if the serialized input is a [2, 3] matrix representing two original SparseTensor objects: index = [ 0]
        [10]
        [20]
values = [1, 2, 3]
shape = [50]
 and index = [ 2]
        [10]
values = [4, 5]
shape = [30]
 then the final deserialized SparseTensor will be: index = [0  0]
        [0 10]
        [0 20]
        [1  2]
        [1 10]
values = [1, 2, 3, 4, 5]
shape = [2 50]

 


 Args
  serialized_sparse   2-D Tensor of type string of shape [N, 3]. The serialized and packed SparseTensor objects.  
  dtype   The dtype of the serialized SparseTensor objects.  
  rank   (optional) Python int, the rank of the SparseTensor objects.  
  name   A name prefix for the returned tensors (optional)   
 


 Returns   A SparseTensor representing the deserialized SparseTensors, concatenated along the SparseTensors' first dimension. All of the serialized SparseTensors must have had the same rank and type.
tf.io.encode_base64 Encode strings into web-safe base64 format.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.encode_base64, tf.compat.v1.io.encode_base64  
tf.io.encode_base64(
    input, pad=False, name=None
)
 Refer to the following article for more information on base64 format: en.wikipedia.org/wiki/Base64. Base64 strings may have padding with '=' at the end so that the encoded has length multiple of 4. See Padding section of the link above. Web-safe means that the encoder uses - and _ instead of + and /.
 


 Args
  input   A Tensor of type string. Strings to be encoded.  
  pad   An optional bool. Defaults to False. Bool whether padding is applied at the ends.  
  name   A name for the operation (optional).   
 


 Returns   A Tensor of type string.