mt.tf.utils
Useful subroutines dealing with GPU devices.
Functions
gpus_in_tf_format()
: Converts a gpu list or a gpu count into a list of GPUs in TF format.as_floatx()
: Ensures that a tensor is of dtype floatx.sigmoid()
: Stable sigmoid, taken from tfp.asigmoid()
: Inverse of sigmoid, taken from tfp.
- mt.tf.utils.gpus_in_tf_format(gpus)
Converts a gpu list or a gpu count into a list of GPUs in TF format.
- mt.tf.utils.as_floatx(x)
Ensures that a tensor is of dtype floatx.
- mt.tf.utils.sigmoid(x)
Stable sigmoid, taken from tfp.
- mt.tf.utils.asigmoid(y)
Inverse of sigmoid, taken from tfp.
Classes
NameScope
: An iterator that generates name scope prefixes, mostly for Keras layers.
- class mt.tf.utils.NameScope(name: str, parent_scope=None)
An iterator that generates name scope prefixes, mostly for Keras layers.
- Parameters:
name (str) – the name of the scope
parent_scope (NameScope, optional) – the parent name scope
- __call__()
Gets the full name of a base name, with prefix generated from the name scope.
Examples
>>> from mt import tf >>> name_scope = tf.NameScope("myblock") >>> name_scope("a") 'myblock_0/a' >>> name_scope("b") 'myblock_0/b' >>> next(name_scope) >>> name_scope("c") 'myblock_1/c' >>> child_scope = tf.NameScope("childblock", parent_scope=name_scope) >>> child_scope("d") 'myblock_1/childblock_0/d'
Inheritance
digraph inheritanced6f0c93074 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "NameScope" [URL="#mt.tf.utils.NameScope",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="An iterator that generates name scope prefixes, mostly for Keras layers."]; }- prefix(full: bool = False)
Returns the current prefix, with or without any parent prefix.