美文网首页
在TensorFlow中实现共享变量

在TensorFlow中实现共享变量

作者: nonoka | 来源:发表于2019-01-23 14:16 被阅读0次

        最近要用TensorFlow实现Siamese Network,需要实现两个分支网络之间的权重共享。TensorFlow的name_scope和variable_scope快把我绕晕了,蓝瘦。查了好多资料,发现共享变量最简单的方法如下:

with tf.variable_scope("Siamese") as scope:
    self.left_output = self.model(self.left)
    scope.reuse_variables()
    self.right_output = self.model(self.right)

相关文章

网友评论

      本文标题:在TensorFlow中实现共享变量

      本文链接:https://www.haomeiwen.com/subject/efijjqtx.html