我想知道是否有人可以告诉我如何用Tensorflow中的(已经)保存的小模型替换大型模型的一部分。确切地说,我想要的是,在下面,将y(g)部分地设为f(x)。 y = g(x)是已经训练过的,保存过的模型,我想训练f(x)而不用链接g(x)。
with tf.variable_scope("foo"):
z1 = f(x1)
with tf.variable_scope("bar", reuse=True):
z2 = f(x2)
我将声明f(x)两次像
<Switch>
<Redirect exact from='/' to='/dashboard' />
<Route exact path='/dashboard' component={Dashboard} />
</Switch>
任何评论都表示赞赏。
答案 0 :(得分:0)
执行y = tf.stop_gradient(g(x))
之类的操作,并通过创建自己的保护程序并将g的变量列表传递给检查点来加载g的权重。