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_histogram(tensor[, summary_name, …]) Add the histogram of tensor to the default summary collector, and to collections.
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.
add_summary(summary[, collections]) Add the summary to the default summary collector, and to collections.
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 tfsnippet.settings.enable_assertions == True, open a context that will run assert_ops.
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.
default_summary_collector() Get the SummaryCollector object at the top of context stack.
deprecated_arg(old_arg[, new_arg, version])
ensure_variables_initialized([variables, name]) Ensure variables are initialized.
generate_random_seed() Generate a new random seed from the default NumPy random state.
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_dimension_size(tensor, axis[, name]) Get the size of tensor of specified axis.
get_dimensions_size(tensor[, axes, name]) Get the size of tensor of specified axes.
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_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_add_histogram(tensor[, summary_name, …]) If tfsnippet.settings.auto_histogram == True, add the histogram of tensor via tfsnippet.add_histogram().
maybe_check_numerics(tensor, message[, name]) If tfsnippet.settings.check_numerics == True, check the numerics of tensor.
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.
print_as_table(title, key_values[, hr]) Print a key-value sequence as a table.
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.
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_cache_root(cache_root) Set the root cache directory.
set_random_seed(seed) Generate random seeds for NumPy, TensorFlow and TFSnippet.
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.
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.
BaseRegistry([ignore_case]) A base class for implement a type or object registry.
BoolConfigValidator Config value validator for boolean values.
CacheDir(name[, cache_root]) Class to manipulate a cache directory.
ClassRegistry([ignore_case]) A subclass of BaseRegistry, dedicated for classes.
Config Base class for defining config values.
ConfigField(type[, default, description, …]) A config field.
ConfigValidator Base config value validator.
ConsoleTable(col_count[, col_space, …]) A class to help format a console table.
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).
EventSource([allowed_event_keys]) An object that may trigger events.
Extractor(archive_file) The base class for all archive extractors.
FloatConfigValidator Config value validator for float values.
GraphKeys Defines TensorFlow graph collection keys for TFSnippet.
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.
SummaryCollector([collections, …]) Collecting summaries and histograms added by tfsnippet.add_summary() and tfsnippet.add_histogram().
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.
TensorSpec([shape, dtype]) Base class to describe and validate the specification of a tensor.
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.registry.BaseRegistry, tfsnippet.utils.config_utils.BoolConfigValidator, tfsnippet.utils.caching.CacheDir, tfsnippet.utils.registry.ClassRegistry, tfsnippet.utils.config_utils.Config, tfsnippet.utils.config_utils.ConfigField, tfsnippet.utils.config_utils.ConfigValidator, tfsnippet.utils.console_table.ConsoleTable, tfsnippet.utils.misc.ContextStack, tfsnippet.utils.concepts.Disposable, tfsnippet.utils.concepts.DisposableContext, tfsnippet.utils.misc.ETA, tfsnippet.utils.events.EventSource, tfsnippet.utils.archive_file.Extractor, tfsnippet.utils.config_utils.FloatConfigValidator, tfsnippet.utils.graph_keys.GraphKeys, 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.summary_collector.SummaryCollector, tfsnippet.utils.settings_.TFSnippetConfig, tfsnippet.utils.archive_file.TarExtractor, tfsnippet.utils.type_utils.TensorArgValidator, tfsnippet.utils.tensor_spec.TensorSpec, tfsnippet.utils.tensor_wrapper.TensorWrapper, tfsnippet.utils.reuse.VarScopeObject, tfsnippet.utils.random.VarScopeRandomState, tfsnippet.utils.archive_file.ZipExtractor, tfsnippet.utils.deprecation.deprecated