base.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:sonnet 作者: deepmind 项目源码 文件源码
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.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号