LostTech.TensorFlow : API Documentation

Type tf.compat

Namespace tensorflow

Public static methods

object as_str_any(Byte[] value)

Converts input to `str` type.

Uses `str(value)`, except for `bytes` typed inputs, which are converted using `as_str`.
Parameters
Byte[] value
A object that can be converted to `str`.
Returns
object
A `str` object.

object as_str_any(Exception value)

Converts input to `str` type.

Uses `str(value)`, except for `bytes` typed inputs, which are converted using `as_str`.
Parameters
Exception value
A object that can be converted to `str`.
Returns
object
A `str` object.

object as_str_any(PythonClassContainer value)

object as_str_any(object value)

Converts input to `str` type.

Uses `str(value)`, except for `bytes` typed inputs, which are converted using `as_str`.
Parameters
object value
A object that can be converted to `str`.
Returns
object
A `str` object.

object as_str_any(string value)

Converts input to `str` type.

Uses `str(value)`, except for `bytes` typed inputs, which are converted using `as_str`.
Parameters
string value
A object that can be converted to `str`.
Returns
object
A `str` object.

object as_str_any_dyn(object value)

Converts input to `str` type.

Uses `str(value)`, except for `bytes` typed inputs, which are converted using `as_str`.
Parameters
object value
A object that can be converted to `str`.
Returns
object
A `str` object.

IContextManager<T> forward_compatibility_horizon(int year, int month, int day)

Context manager for testing forward compatibility of generated graphs.

See [Version compatibility](https://tensorflow.org/guide/version_compat#backward_forward).

To ensure forward compatibility of generated graphs (see `forward_compatible`) with older binaries, new features can be gated with: However, when adding new features, one may want to unittest it before the forward compatibility window expires. This context manager enables such tests.
Parameters
int year
A year (e.g., 2018). Must be an `int`.
int month
A month (1 <= month <= 12) in year. Must be an `int`.
int day
A day (1 <= day <= 31, or 30, or 29, or 28) in month. Must be an `int`.
Show Example
if compat.forward_compatible(year=2018, month=08, date=01):
              generate_graph_with_new_features()
            else:
              generate_graph_so_older_binaries_can_consume_it() 

object forward_compatibility_horizon_dyn(object year, object month, object day)

Context manager for testing forward compatibility of generated graphs.

See [Version compatibility](https://tensorflow.org/guide/version_compat#backward_forward).

To ensure forward compatibility of generated graphs (see `forward_compatible`) with older binaries, new features can be gated with: However, when adding new features, one may want to unittest it before the forward compatibility window expires. This context manager enables such tests.
Parameters
object year
A year (e.g., 2018). Must be an `int`.
object month
A month (1 <= month <= 12) in year. Must be an `int`.
object day
A day (1 <= day <= 31, or 30, or 29, or 28) in month. Must be an `int`.
Show Example
if compat.forward_compatible(year=2018, month=08, date=01):
              generate_graph_with_new_features()
            else:
              generate_graph_so_older_binaries_can_consume_it() 

int forward_compatible(int year, int month, int day)

Return true if the forward compatibility window has expired.

See [Version compatibility](https://tensorflow.org/guide/version_compat#backward_forward).

Forward-compatibility refers to scenarios where the producer of a TensorFlow model (a GraphDef or SavedModel) is compiled against a version of the TensorFlow library newer than what the consumer was compiled against. The "producer" is typically a Python program that constructs and trains a model while the "consumer" is typically another program that loads and serves the model.

TensorFlow has been supporting a 3 week forward-compatibility window for programs compiled from source at HEAD.

For example, consider the case where a new operation `MyNewAwesomeAdd` is created with the intent of replacing the implementation of an existing Python wrapper - tf.add. The Python wrapper implementation should change from something like: to: Where `year`, `month`, and `day` specify the date beyond which binaries that consume a model are expected to have been updated to include the new operations. This date is typically at least 3 weeks beyond the date the code that adds the new operation is committed.
Parameters
int year
A year (e.g., 2018). Must be an `int`.
int month
A month (1 <= month <= 12) in year. Must be an `int`.
int day
A day (1 <= day <= 31, or 30, or 29, or 28) in month. Must be an `int`.
Returns
int
True if the caller can expect that serialized TensorFlow graphs produced can be consumed by programs that are compiled with the TensorFlow library source code after (year, month, day).
Show Example
def add(inputs, name=None):
              return gen_math_ops.add(inputs, name) 

object forward_compatible_dyn(object year, object month, object day)

Return true if the forward compatibility window has expired.

See [Version compatibility](https://tensorflow.org/guide/version_compat#backward_forward).

Forward-compatibility refers to scenarios where the producer of a TensorFlow model (a GraphDef or SavedModel) is compiled against a version of the TensorFlow library newer than what the consumer was compiled against. The "producer" is typically a Python program that constructs and trains a model while the "consumer" is typically another program that loads and serves the model.

TensorFlow has been supporting a 3 week forward-compatibility window for programs compiled from source at HEAD.

For example, consider the case where a new operation `MyNewAwesomeAdd` is created with the intent of replacing the implementation of an existing Python wrapper - tf.add. The Python wrapper implementation should change from something like: to: Where `year`, `month`, and `day` specify the date beyond which binaries that consume a model are expected to have been updated to include the new operations. This date is typically at least 3 weeks beyond the date the code that adds the new operation is committed.
Parameters
object year
A year (e.g., 2018). Must be an `int`.
object month
A month (1 <= month <= 12) in year. Must be an `int`.
object day
A day (1 <= day <= 31, or 30, or 29, or 28) in month. Must be an `int`.
Returns
object
True if the caller can expect that serialized TensorFlow graphs produced can be consumed by programs that are compiled with the TensorFlow library source code after (year, month, day).
Show Example
def add(inputs, name=None):
              return gen_math_ops.add(inputs, name) 

object path_to_str(object path)

Converts input which is a `PathLike` object to `str` type.

Converts from any python constant representation of a `PathLike` object to a string. If the input is not a `PathLike` object, simply returns the input.
Parameters
object path
An object that can be converted to path representation.
Returns
object
A `str` object.

Usage: In case a simplified `str` version of the path is needed from an `os.PathLike` object

Examples: ```python3 >>> tf.compat.path_to_str('C:\XYZ\tensorflow\./.././tensorflow') 'C:\XYZ\tensorflow\./.././tensorflow' # Windows OS >>> tf.compat.path_to_str(Path('C:\XYZ\tensorflow\./.././tensorflow')) 'C:\XYZ\tensorflow\..\tensorflow' # Windows OS >>> tf.compat.path_to_str(Path('./corpus')) 'corpus' # Linux OS >>> tf.compat.path_to_str('./.././Corpus') './.././Corpus' # Linux OS >>> tf.compat.path_to_str(Path('./.././Corpus')) '../Corpus' # Linux OS >>> tf.compat.path_to_str(Path('./..////../')) '../..' # Linux OS

```

Public properties

PythonFunctionContainer as_str_any_fn get;

ValueTuple<Byte[], string> bytes_or_text_types get; set;

ValueTuple<PythonClassContainer, PythonClassContainer> complex_types get; set;

PythonFunctionContainer forward_compatibility_horizon_fn get;

PythonFunctionContainer forward_compatible_fn get;

ValueTuple<PythonClassContainer, PythonClassContainer> integral_types get; set;

PythonFunctionContainer path_to_str_fn get;

ValueTuple<PythonClassContainer, PythonClassContainer, PythonClassContainer> real_types get; set;