neulab/docprompting-conala huggingface dataset:
tf.estimator.experimental.stop_if_no_increase_hook     View source on GitHub    Creates hook to stop if metric does not increase within given max steps.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.experimental.stop_if_no_increase_hook  
tf.estimator.experimental.stop_if_no_increase_hook(
    estimator, metric_name, max_steps_without_increase, eval_dir=None, min_steps=0,
    run_every_secs=60, run_every_steps=None
)
 Usage example: estimator = ...
# Hook to stop training if accuracy does not increase in over 100000 steps.
hook = early_stopping.stop_if_no_increase_hook(estimator, "accuracy", 100000)
train_spec = tf.estimator.TrainSpec(..., hooks=[hook])
tf.estimator.train_and_evaluate(estimator, train_spec, ...)
 Caveat: Current implementation supports early-stopping both training and evaluation in local mode. In distributed mode, training can be stopped but evaluation (where it's a separate job) will indefinitely wait for new model checkpoints to evaluate, so you will need other means to detect and stop it. Early-stopping evaluation in distributed mode requires changes in train_and_evaluate API and will be addressed in a future revision.
 


 Args
  estimator   A tf.estimator.Estimator instance.  
  metric_name   str, metric to track. "loss", "accuracy", etc.  
  max_steps_without_increase   int, maximum number of training steps with no increase in the given metric.  
  eval_dir   If set, directory containing summary files with eval metrics. By default, estimator.eval_dir() will be used.  
  min_steps   int, stop is never requested if global step is less than this value. Defaults to 0.  
  run_every_secs   If specified, calls should_stop_fn at an interval of run_every_secs seconds. Defaults to 60 seconds. Either this or run_every_steps must be set.  
  run_every_steps   If specified, calls should_stop_fn every run_every_steps steps. Either this or run_every_secs must be set.   
 


 Returns   An early-stopping hook of type SessionRunHook that periodically checks if the given metric shows no increase over given maximum number of training steps, and initiates early stopping if true.
Module: tf.estimator.export All public utility methods for exporting Estimator to SavedModel. This file includes functions and constants from core (model_utils) and export.py Classes class ClassificationOutput: Represents the output of a classification head. class ExportOutput: Represents an output of a model that can be served. class PredictOutput: Represents the output of a generic prediction head. class RegressionOutput: Represents the output of a regression head. class ServingInputReceiver: A return type for a serving_input_receiver_fn. class TensorServingInputReceiver: A return type for a serving_input_receiver_fn. Functions build_parsing_serving_input_receiver_fn(...): Build a serving_input_receiver_fn expecting fed tf.Examples. build_raw_serving_input_receiver_fn(...): Build a serving_input_receiver_fn expecting feature Tensors.
tf.estimator.export.build_parsing_serving_input_receiver_fn     View source on GitHub    Build a serving_input_receiver_fn expecting fed tf.Examples.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.export.build_parsing_serving_input_receiver_fn  
tf.estimator.export.build_parsing_serving_input_receiver_fn(
    feature_spec, default_batch_size=None
)
 Creates a serving_input_receiver_fn that expects a serialized tf.Example fed into a string placeholder. The function parses the tf.Example according to the provided feature_spec, and returns all parsed Tensors as features.
 


 Args
  feature_spec   a dict of string to VarLenFeature/FixedLenFeature.  
  default_batch_size   the number of query examples expected per batch. Leave unset for variable batch size (recommended).   
 


 Returns   A serving_input_receiver_fn suitable for use in serving.
tf.estimator.export.build_raw_serving_input_receiver_fn     View source on GitHub    Build a serving_input_receiver_fn expecting feature Tensors.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.export.build_raw_serving_input_receiver_fn  
tf.estimator.export.build_raw_serving_input_receiver_fn(
    features, default_batch_size=None
)
 Creates an serving_input_receiver_fn that expects all features to be fed directly.
 


 Args
  features   a dict of string to Tensor.  
  default_batch_size   the number of query examples expected per batch. Leave unset for variable batch size (recommended).   
 


 Returns   A serving_input_receiver_fn.
tf.estimator.export.ClassificationOutput     View source on GitHub    Represents the output of a classification head. Inherits From: ExportOutput  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.export.ClassificationOutput  
tf.estimator.export.ClassificationOutput(
    scores=None, classes=None
)
 Either classes or scores or both must be set. The classes Tensor must provide string labels, not integer class IDs. If only classes is set, it is interpreted as providing top-k results in descending order. If only scores is set, it is interpreted as providing a score for every class in order of class ID. If both classes and scores are set, they are interpreted as zipped, so each score corresponds to the class at the same index. Clients should not depend on the order of the entries.
 


 Args
  scores   A float Tensor giving scores (sometimes but not always interpretable as probabilities) for each class. May be None, but only if classes is set. Interpretation varies-- see class doc.  
  classes   A string Tensor giving predicted class labels. May be None, but only if scores is set. Interpretation varies-- see class doc.   
 


 Raises
  ValueError   if neither classes nor scores is set, or one of them is not a Tensor with the correct dtype.   
 


 Attributes
  classes  
 
  scores  
   Methods as_signature_def View source 
as_signature_def(
    receiver_tensors
)
 Generate a SignatureDef proto for inclusion in a MetaGraphDef. The SignatureDef will specify outputs as described in this ExportOutput, and will use the provided receiver_tensors as inputs.
 


 Args
  receiver_tensors   a Tensor, or a dict of string to Tensor, specifying input nodes that will be fed.
tf.estimator.export.ExportOutput     View source on GitHub    Represents an output of a model that can be served.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.export.ExportOutput  These typically correspond to model heads. Methods as_signature_def View source 
@abc.abstractmethod
as_signature_def(
    receiver_tensors
)
 Generate a SignatureDef proto for inclusion in a MetaGraphDef. The SignatureDef will specify outputs as described in this ExportOutput, and will use the provided receiver_tensors as inputs.
 


 Args
  receiver_tensors   a Tensor, or a dict of string to Tensor, specifying input nodes that will be fed.
tf.estimator.export.PredictOutput     View source on GitHub    Represents the output of a generic prediction head. Inherits From: ExportOutput  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.export.PredictOutput  
tf.estimator.export.PredictOutput(
    outputs
)
 A generic prediction need not be either a classification or a regression. Named outputs must be provided as a dict from string to Tensor,
 


 Args
  outputs   A Tensor or a dict of string to Tensor representing the predictions.   
 


 Raises
  ValueError   if the outputs is not dict, or any of its keys are not strings, or any of its values are not Tensors.   
 


 Attributes
  outputs  
   Methods as_signature_def View source 
as_signature_def(
    receiver_tensors
)
 Generate a SignatureDef proto for inclusion in a MetaGraphDef. The SignatureDef will specify outputs as described in this ExportOutput, and will use the provided receiver_tensors as inputs.
 


 Args
  receiver_tensors   a Tensor, or a dict of string to Tensor, specifying input nodes that will be fed.
tf.estimator.export.RegressionOutput     View source on GitHub    Represents the output of a regression head. Inherits From: ExportOutput  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.export.RegressionOutput  
tf.estimator.export.RegressionOutput(
    value
)

 


 Args
  value   a float Tensor giving the predicted values. Required.   
 


 Raises
  ValueError   if the value is not a Tensor with dtype tf.float32.   
 


 Attributes
  value  
   Methods as_signature_def View source 
as_signature_def(
    receiver_tensors
)
 Generate a SignatureDef proto for inclusion in a MetaGraphDef. The SignatureDef will specify outputs as described in this ExportOutput, and will use the provided receiver_tensors as inputs.
 


 Args
  receiver_tensors   a Tensor, or a dict of string to Tensor, specifying input nodes that will be fed.
tf.estimator.export.ServingInputReceiver     View source on GitHub    A return type for a serving_input_receiver_fn.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.export.ServingInputReceiver  
tf.estimator.export.ServingInputReceiver(
    features, receiver_tensors, receiver_tensors_alternatives=None
)

 


 Attributes
  features   A Tensor, SparseTensor, or dict of string or int to Tensor or SparseTensor, specifying the features to be passed to the model. Note: if features passed is not a dict, it will be wrapped in a dict with a single entry, using 'feature' as the key. Consequently, the model must accept a feature dict of the form {'feature': tensor}. You may use TensorServingInputReceiver if you want the tensor to be passed as is.  
  receiver_tensors   A Tensor, SparseTensor, or dict of string to Tensor or SparseTensor, specifying input nodes where this receiver expects to be fed by default. Typically, this is a single placeholder expecting serialized tf.Example protos.  
  receiver_tensors_alternatives   a dict of string to additional groups of receiver tensors, each of which may be a Tensor, SparseTensor, or dict of string to Tensor orSparseTensor. These named receiver tensor alternatives generate additional serving signatures, which may be used to feed inputs at different points within the input receiver subgraph. A typical usage is to allow feeding raw feature Tensors downstream of the tf.parse_example() op. Defaults to None.
tf.estimator.export.TensorServingInputReceiver     View source on GitHub    A return type for a serving_input_receiver_fn.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.export.TensorServingInputReceiver  
tf.estimator.export.TensorServingInputReceiver(
    features, receiver_tensors, receiver_tensors_alternatives=None
)
 This is for use with models that expect a single Tensor or SparseTensor as an input feature, as opposed to a dict of features. The normal ServingInputReceiver always returns a feature dict, even if it contains only one entry, and so can be used only with models that accept such a dict. For models that accept only a single raw feature, the serving_input_receiver_fn provided to Estimator.export_saved_model() should return this TensorServingInputReceiver instead. See: https://github.com/tensorflow/tensorflow/issues/11674 Note that the receiver_tensors and receiver_tensor_alternatives arguments will be automatically converted to the dict representation in either case, because the SavedModel format requires each input Tensor to have a name (provided by the dict key).
 


 Attributes
  features   A single Tensor or SparseTensor, representing the feature to be passed to the model.  
  receiver_tensors   A Tensor, SparseTensor, or dict of string to Tensor or SparseTensor, specifying input nodes where this receiver expects to be fed by default. Typically, this is a single placeholder expecting serialized tf.Example protos.  
  receiver_tensors_alternatives   a dict of string to additional groups of receiver tensors, each of which may be a Tensor, SparseTensor, or dict of string to Tensor orSparseTensor. These named receiver tensor alternatives generate additional serving signatures, which may be used to feed inputs at different points within the input receiver subgraph. A typical usage is to allow feeding raw feature Tensors downstream of the tf.parse_example() op. Defaults to None.
tf.estimator.Exporter     View source on GitHub    A class representing a type of model export.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.Exporter 
 


 Attributes
  name   Directory name. A directory name under the export base directory where exports of this type are written. Should not be None nor empty. 
   Methods export View source 
@abc.abstractmethod
export(
    estimator, export_path, checkpoint_path, eval_result, is_the_final_export
)
 Exports the given Estimator to a specific format.
 


 Args
  estimator   the Estimator to export.  
  export_path   A string containing a directory where to write the export.  
  checkpoint_path   The checkpoint path to export.  
  eval_result   The output of Estimator.evaluate on this checkpoint.  
  is_the_final_export   This boolean is True when this is an export in the end of training. It is False for the intermediate exports during the training. When passing Exporter to tf.estimator.train_and_evaluate is_the_final_export is always False if TrainSpec.max_steps is None.   
 


 Returns   The string path to the exported directory or None if export is skipped.
tf.estimator.FeedFnHook Runs feed_fn and sets the feed_dict accordingly. Inherits From: SessionRunHook  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.FeedFnHook, tf.compat.v1.train.FeedFnHook  
tf.estimator.FeedFnHook(
    feed_fn
)

 


 Args
  feed_fn   function that takes no arguments and returns dict of Tensor to feed.    Methods after_create_session View source 
after_create_session(
    session, coord
)
 Called when new TensorFlow session is created. This is called to signal the hooks that a new session has been created. This has two essential differences with the situation in which begin is called:  When this is called, the graph is finalized and ops can no longer be added to the graph. This method will also be called as a result of recovering a wrapped session, not only at the beginning of the overall session. 
 


 Args
  session   A TensorFlow Session that has been created.  
  coord   A Coordinator object which keeps track of all threads.    after_run View source 
after_run(
    run_context, run_values
)
 Called after each call to run(). The run_values argument contains results of requested ops/tensors by before_run(). The run_context argument is the same one send to before_run call. run_context.request_stop() can be called to stop the iteration. If session.run() raises any exceptions then after_run() is not called.
 


 Args
  run_context   A SessionRunContext object.  
  run_values   A SessionRunValues object.    before_run View source 
before_run(
    run_context
)
 Called before each call to run(). You can return from this call a SessionRunArgs object indicating ops or tensors to add to the upcoming run() call. These ops/tensors will be run together with the ops/tensors originally passed to the original run() call. The run args you return can also contain feeds to be added to the run() call. The run_context argument is a SessionRunContext that provides information about the upcoming run() call: the originally requested op/tensors, the TensorFlow Session. At this point graph is finalized and you can not add ops.
 


 Args
  run_context   A SessionRunContext object.   
 


 Returns   None or a SessionRunArgs object.  
 begin View source 
begin()
 Called once before using the session. When called, the default graph is the one that will be launched in the session. The hook can modify the graph by adding new operations to it. After the begin() call the graph will be finalized and the other callbacks can not modify the graph anymore. Second call of begin() on the same graph, should not change the graph. end View source 
end(
    session
)
 Called at the end of session. The session argument can be used in case the hook wants to run final ops, such as saving a last checkpoint. If session.run() raises exception other than OutOfRangeError or StopIteration then end() is not called. Note the difference between end() and after_run() behavior when session.run() raises OutOfRangeError or StopIteration. In that case end() is called but after_run() is not called.
 


 Args
  session   A TensorFlow Session that will be soon closed.
tf.estimator.FinalExporter     View source on GitHub    This class exports the serving graph and checkpoints at the end. Inherits From: Exporter  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.FinalExporter  
tf.estimator.FinalExporter(
    name, serving_input_receiver_fn, assets_extra=None, as_text=False
)
 This class performs a single export at the end of training.
 


 Args
  name   unique name of this Exporter that is going to be used in the export path.  
  serving_input_receiver_fn   a function that takes no arguments and returns a ServingInputReceiver.  
  assets_extra   An optional dict specifying how to populate the assets.extra directory within the exported SavedModel. Each key should give the destination path (including the filename) relative to the assets.extra directory. The corresponding value gives the full path of the source file to be copied. For example, the simple case of copying a single file without renaming it is specified as {'my_asset_file.txt': '/path/to/my_asset_file.txt'}.  
  as_text   whether to write the SavedModel proto in text format. Defaults to False.   
 


 Raises
  ValueError   if any arguments is invalid.   
 


 Attributes
  name   Directory name. A directory name under the export base directory where exports of this type are written. Should not be None nor empty. 
   Methods export View source 
export(
    estimator, export_path, checkpoint_path, eval_result, is_the_final_export
)
 Exports the given Estimator to a specific format.
 


 Args
  estimator   the Estimator to export.  
  export_path   A string containing a directory where to write the export.  
  checkpoint_path   The checkpoint path to export.  
  eval_result   The output of Estimator.evaluate on this checkpoint.  
  is_the_final_export   This boolean is True when this is an export in the end of training. It is False for the intermediate exports during the training. When passing Exporter to tf.estimator.train_and_evaluate is_the_final_export is always False if TrainSpec.max_steps is None.   
 


 Returns   The string path to the exported directory or None if export is skipped.
tf.estimator.LatestExporter     View source on GitHub    This class regularly exports the serving graph and checkpoints. Inherits From: Exporter  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.LatestExporter  
tf.estimator.LatestExporter(
    name, serving_input_receiver_fn, assets_extra=None, as_text=False,
    exports_to_keep=5
)
 In addition to exporting, this class also garbage collects stale exports.
 


 Args
  name   unique name of this Exporter that is going to be used in the export path.  
  serving_input_receiver_fn   a function that takes no arguments and returns a ServingInputReceiver.  
  assets_extra   An optional dict specifying how to populate the assets.extra directory within the exported SavedModel. Each key should give the destination path (including the filename) relative to the assets.extra directory. The corresponding value gives the full path of the source file to be copied. For example, the simple case of copying a single file without renaming it is specified as {'my_asset_file.txt': '/path/to/my_asset_file.txt'}.  
  as_text   whether to write the SavedModel proto in text format. Defaults to False.  
  exports_to_keep   Number of exports to keep. Older exports will be garbage-collected. Defaults to 5. Set to None to disable garbage collection.   
 


 Raises
  ValueError   if any arguments is invalid.   
 


 Attributes
  name   Directory name. A directory name under the export base directory where exports of this type are written. Should not be None nor empty. 
   Methods export View source 
export(
    estimator, export_path, checkpoint_path, eval_result, is_the_final_export
)
 Exports the given Estimator to a specific format.
 


 Args
  estimator   the Estimator to export.  
  export_path   A string containing a directory where to write the export.  
  checkpoint_path   The checkpoint path to export.  
  eval_result   The output of Estimator.evaluate on this checkpoint.  
  is_the_final_export   This boolean is True when this is an export in the end of training. It is False for the intermediate exports during the training. When passing Exporter to tf.estimator.train_and_evaluate is_the_final_export is always False if TrainSpec.max_steps is None.   
 


 Returns   The string path to the exported directory or None if export is skipped.
tf.estimator.ModeKeys     View source on GitHub    Standard names for Estimator model modes.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.ModeKeys  The following standard keys are defined:  
TRAIN: training/fitting mode. 
EVAL: testing/evaluation mode. 
PREDICT: predication/inference mode. 
 


 Class Variables
  EVAL   'eval'  
  PREDICT   'infer'  
  TRAIN   'train'
tf.estimator.NanLossDuringTrainingError Unspecified run-time error.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.NanLossDuringTrainingError, tf.compat.v1.train.NanLossDuringTrainingError  
tf.estimator.NanLossDuringTrainingError(
    *args, **kwargs
)
tf.estimator.SecondOrStepTimer Timer that triggers at most once every N seconds or once every N steps.  View aliases  Compat aliases for migration 
See Migration guide for more details. tf.compat.v1.estimator.SecondOrStepTimer, tf.compat.v1.train.SecondOrStepTimer  
tf.estimator.SecondOrStepTimer(
    every_secs=None, every_steps=None
)
 This symbol is also exported to v2 in tf.estimator namespace. See https://github.com/tensorflow/estimator/blob/master/tensorflow_estimator/python/estimator/hooks/basic_session_run_hooks.py Methods last_triggered_step View source 
last_triggered_step()
 Returns the last triggered time step or None if never triggered. reset View source 
reset()
 Resets the timer. should_trigger_for_step View source 
should_trigger_for_step(
    step
)
 Return true if the timer should trigger for the specified step.
 


 Args
  step   Training step to trigger on.   
 


 Returns   True if the difference between the current time and the time of the last trigger exceeds every_secs, or if the difference between the current step and the last triggered step exceeds every_steps. False otherwise.  
 update_last_triggered_step View source 
update_last_triggered_step(
    step
)
 Update the last triggered time and step number.
 


 Args
  step   The current step.   
 


 Returns   A pair (elapsed_time, elapsed_steps), where elapsed_time is the number of seconds between the current trigger and the last one (a float), and elapsed_steps is the number of steps between the current trigger and the last one. Both values will be set to None on the first trigger.