def _check_same_graph(self):
"""Checks that the module is not being connect to multiple Graphs.
An instance of a Sonnet module 'owns' the variables it contains, and permits
seamless variable sharing. As such, connecting a single module instance to
multiple Graphs is not possible - this function will raise an error should
that occur.
Raises:
DifferentGraphError: if the module is connected to a different Graph than
it was previously used in.
"""
current_graph = tf.get_default_graph()
if self._graph is None:
self._graph = current_graph
self._set_module_info()
elif self._graph != current_graph:
raise DifferentGraphError("Cannot connect module to multiple Graphs.")
评论列表
文章目录