tfsnippet.utils

tfsnippet.utils Package

Functions

DocInherit(kclass) Class decorator to enable kclass and all its sub-classes to automatically inherit docstrings from base classes.
add_name_and_scope_arg_doc(method) Add name and scope argument to the doc of method.
add_name_arg_doc(method) Add name argument to the doc of method.
append_arg_to_doc(doc, arg_doc) Add the doc for name and scope argument to the doc string.
append_to_doc(doc, content) Append content to the doc string.
assert_deps(*args, **kwds) If is_assertion_enabled() == True, open a context that will run assert_ops on exit.
broadcast_to_shape(x, shape[, name]) Broadcast x to match shape.
broadcast_to_shape_strict(x, shape[, name]) Broadcast x to match shape.
camel_to_underscore(name) Convert a camel-case name to underscore.
concat_shapes(shapes[, name]) Concat shapes from shapes.
create_session([lock_memory, …]) A convenient method to create a TensorFlow session.
deprecated_arg(old_arg[, new_arg, version])
ensure_variables_initialized([variables, name]) Ensure variables are initialized.
flatten_to_ndims(x, ndims[, name]) Flatten the front dimensions of x, such that the resulting tensor will have at most ndims dimensions.
get_batch_size(tensor[, axis, name]) Infer the mini-batch size according to tensor.
get_cache_root() Get the cache root directory.
get_config_defaults(config) Get the default config values of config.
get_config_validator(type) Get an instance of ConfigValidator for specified type.
get_default_scope_name(name[, cls_or_instance]) Generate a valid default scope name.
get_default_session_or_error() Get the default session.
get_dimensions_size(tensor[, axis, name]) Get the size of tensor of specified axis.
get_model_variables([scope]) Get all model variables (i.e., variables in MODEL_VARIABLES collection).
get_rank(tensor[, name]) Get the rank of the tensor.
get_reuse_stack_top() Get the top of the reuse scope stack.
get_static_shape(tensor) Get the the static shape of specified tensor as a tuple.
get_uninitialized_variables([variables, name]) Get uninitialized variables as a list.
get_variable_ddi(name, initial_value[, …]) Wraps tf.get_variable() to support data-dependent initialization.
get_variables_as_dict([scope, collection]) Get TensorFlow variables as dict.
global_reuse([method_or_scope, _sentinel, scope]) Decorate a function to reuse a variable scope automatically.
humanize_duration(seconds[, short_units]) Format specified time duration as human readable text.
instance_reuse([method_or_scope, _sentinel, …]) Decorate an instance method to reuse a variable scope automatically.
is_assertion_enabled(*args, **kwargs) Whether or not to enable assertions?
is_float(x) Test whether or not x is a Python or NumPy float.
is_integer(x) Test whether or not x is a Python or NumPy integer.
is_shape_equal(x, y[, name]) Check whether the shape of x equals to y.
is_tensor_object(x) Test whether or not x is a tensor object.
is_tensorflow_version_higher_or_equal(version) Check whether the version of TensorFlow is higher than or equal to version.
iter_files(root_dir[, sep]) Iterate through all files in root_dir, returning the relative paths of each file.
makedirs(name[, mode, exist_ok])
maybe_check_numerics(tensor, message[, name]) Check the numerics of tensor, if should_check_numerics().
maybe_close(*args, **kwds) Enter a context, and if obj has .close() method, close it when exiting the context.
minibatch_slices_iterator(length, batch_size) Iterate through all the mini-batch slices.
model_variable(name[, shape, dtype, …]) Get or create a model variable.
register_config_arguments(config, parser[, …]) Register config to the specified argument parser.
register_config_validator(type, validator_class) Register a config value validator.
register_tensor_wrapper_class(cls) Register a sub-class of TensorWrapper into TensorFlow type system.
reopen_variable_scope(*args, **kwds) Reopen the specified var_scope and its original name scope.
reshape_tail(input, ndims, shape[, name]) Reshape the tail (last) ndims into specified shape.
resolve_negative_axis(ndims, axis) Resolve all negative axis indices according to ndims into positive.
root_variable_scope(*args, **kwds) Open the root variable scope and its name scope.
scoped_set_config(*args, **kwds) Set config values within a context scope.
set_assertion_enabled(*args, **kwargs) Set whether or not to enable assertions?
set_cache_root(cache_root) Set the root cache directory.
set_check_numerics(*args, **kwargs) Set whether or not to check numerics?
set_random_seed(seed) Generate random seeds for NumPy, TensorFlow and TFSnippet.
should_check_numerics(*args, **kwargs) Whether or not to check numerics?
split_numpy_array(array[, portion, size, …]) Split numpy array into two halves, by portion or by size.
split_numpy_arrays(arrays[, portion, size, …]) Split numpy arrays into two halves, by portion or by size.
transpose_conv2d_axis(input, …[, name]) Ensure the channels axis of input tensor to be placed at the desired axis.
transpose_conv2d_channels_last_to_x(input, …) Ensure the channels axis (known to be the last axis) of input tensor to be placed at the desired axis.
transpose_conv2d_channels_x_to_last(input, …) Ensure the channels axis of input tensor to be placed at the last axis.
unflatten_from_ndims(x, static_front_shape, …) The inverse transformation of flatten().
validate_enum_arg(arg_name, arg_value, choices) Validate the value of a enumeration argument.
validate_group_ndims_arg(group_ndims[, name]) Validate the specified value for group_ndims argument.
validate_int_tuple_arg(arg_name, arg_value) Validate an integer or a tuple of integers, as a tuple of integers.
validate_n_samples_arg(value, name) Validate the n_samples argument.
validate_positive_int_arg(arg_name, arg_value) Validate a positive integer argument.

Classes

AutoInitAndCloseable Classes with init() to initialize its internal states, and also close() to destroy these states.
BoolConfigValidator Config value validator for boolean values.
CacheDir(name[, cache_root]) Class to manipulate a cache directory.
Config() Base class for defining config values.
ConfigField(type[, default, description, …]) A config field.
ConfigValidator Base config value validator.
ContextStack([initial_factory]) A thread-local context stack for general purpose.
Disposable Classes which can only be used once.
DisposableContext Base class for contexts which can only be entered once.
ETA([take_initial_snapshot]) Class to help compute the Estimated Time Ahead (ETA).
Extractor(archive_file) The base class for all archive extractors.
FloatConfigValidator Config value validator for float values.
InputSpec([shape, dtype]) Class to describe the specification for an input tensor.
IntConfigValidator Config value validator for integer values.
InvertibleMatrix(size[, strict, dtype, …]) A matrix initialized to be an invertible, orthogonal matrix.
NoReentrantContext Base class for contexts which are not reentrant (i.e., if there is a context opened by __enter__, and it has not called __exit__, the __enter__ cannot be called again).
ParamSpec(*args, **kwargs) Class to describe the specification for a parameter.
PermutationMatrix(data) A non-trainable permutation matrix.
RarExtractor(fpath) Extractor for “.rar” files.
StatisticsCollector([shape]) Computing \(\mathrm{E}[X]\) and \(\operatorname{Var}[X]\) online.
StrConfigValidator Config value validator for string values.
TFSnippetConfig() Global configurations of TFSnippet.
TarExtractor(fpath) Extractor for “.tar”, “.tar.gz”, “.tgz”, “.tar.bz2”, “.tbz”, “.tbz2”, “.tb2”, “.tar.xz”, “.txz” files.
TemporaryDirectory([suffix, prefix, dir]) Create and return a temporary directory.
TensorArgValidator(name) Class to validate argument values of tensors.
TensorWrapper Tensor-like object that wraps a tf.Tensor instance.
VarScopeObject([name, scope]) Base class for objects that own a variable scope.
VarScopeRandomState(variable_scope) A sub-class of np.random.RandomState, which uses a variable-scope dependent seed.
ZipExtractor(fpath) Extractor for “.zip” files.
deprecated([message, version]) Decorate a class, a method or a function to be deprecated.

Class Inheritance Diagram

Inheritance diagram of tfsnippet.utils.concepts.AutoInitAndCloseable, tfsnippet.utils.config_utils.BoolConfigValidator, tfsnippet.utils.caching.CacheDir, tfsnippet.utils.config_utils.Config, tfsnippet.utils.config_utils.ConfigField, tfsnippet.utils.config_utils.ConfigValidator, tfsnippet.utils.misc.ContextStack, tfsnippet.utils.concepts.Disposable, tfsnippet.utils.concepts.DisposableContext, tfsnippet.utils.misc.ETA, tfsnippet.utils.archive_file.Extractor, tfsnippet.utils.config_utils.FloatConfigValidator, tfsnippet.utils.tensor_spec.InputSpec, tfsnippet.utils.config_utils.IntConfigValidator, tfsnippet.utils.invertible_matrix.InvertibleMatrix, tfsnippet.utils.concepts.NoReentrantContext, tfsnippet.utils.tensor_spec.ParamSpec, tfsnippet.utils.invertible_matrix.PermutationMatrix, tfsnippet.utils.archive_file.RarExtractor, tfsnippet.utils.statistics.StatisticsCollector, tfsnippet.utils.config_utils.StrConfigValidator, tfsnippet.utils.config_.TFSnippetConfig, tfsnippet.utils.archive_file.TarExtractor, tfsnippet.utils.type_utils.TensorArgValidator, tfsnippet.utils.tensor_wrapper.TensorWrapper, tfsnippet.utils.reuse.VarScopeObject, tfsnippet.utils.random.VarScopeRandomState, tfsnippet.utils.archive_file.ZipExtractor, tfsnippet.utils.deprecation.deprecated