def __init__(self, name):
"""Performs the initialisation necessary for all AbstractModule instances.
Every subclass of AbstractModule must begin their constructor with a call to
this constructor, i.e. `super(MySubModule, self).__init__(name=name)`.
Avoid instantiating sub-modules in __init__ where possible, as they will not
be defined under the module's scope. Instead, instantiate sub-modules in
`build`.
Args:
name: Name of this module. Used to construct the Templated build function.
Raises:
ValueError: If name is not specified.
"""
if not isinstance(name, string_types):
raise ValueError("Name must be a string.")
self._is_connected = False
self._template = tf.make_template(name, self._build,
create_scope_now_=True)
# Update __call__ and the object docstrings to enable better introspection
self.__doc__ = self._build.__doc__
self.__call__.__func__.__doc__ = self._build.__doc__
评论列表
文章目录