Module

class dragon.vm.tensorflow.Module(name=None)[source]

The base class of neural network modules.

Inherit this class to design a new module:

class MyModule(tf.Module):
    def __init__(name=None):
        super(MyModule, self).__init__(name)

__init__

Module.__init__(name=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Properties

name

Module.name

Return the module name.

Returns:
str – The module name.

name_scope

Module.name_scope

Returns a dragon.name_scope instance for this class.

Returns:
ContextManger – The context manager to apply the name scope.

submodules

Module.submodules

Return all the submodules into a sequence.

Returns:
Sequence[dragon.vm.tensorflow.Module] – The submodules.

trainable_variables

Module.trainable_variables

Return all the trainable variables into a sequence.

Returns:
Sequence[dragon.vm.tensorflow.Variable] – The trainable variables.

variables

Module.variables

Return all the variables into a sequence.

Returns:
Sequence[dragon.vm.tensorflow.Variable] – The variables.

Methods

flatten

Module.flatten(
  recursive=True,
  predicate=None,
  attribute_traversal_key=None,
  with_path=False
)[source]

Flatten this module to select attributes.

Parameters:
  • recursive (bool, optional, default=True) – True to traverse the submodules recursively.
  • predicate (callable, optional) – The callable to select attribute.
  • attribute_traversal_key (callable, optional) – The custom key function to be used in sorted(...).
  • with_path (bool, optional, default=True) – True to return (paths, element) otherwise element.
Returns:

Iterator – The iterator of attributes.