with tf.variable_scope(
"try"):
w2 = tf.get_variable(
"w1",shape=[
2,
3,
4], dtype=tf.float32)
w3 = tf.get_variable(
"w2", shape=[
2,
3,
4], dtype=tf.float32)
tf.get_variable_scope().reuse_variables()
w4 = tf.get_variable(
"w1", shape=[
2,
3,
4], dtype=tf.float32)
w5 = tf.get_variable(
"w2", shape=[
2,
3,
4], dtype=tf.float32)
tf.get_variable_scope().reuse_variables()
w6 = tf.get_variable(
"w1", shape=[
2,
3,
4], dtype=tf.float32)
w7 = tf.get_variable(
"w2", shape=[
2,
3,
4], dtype=tf.float32)
这样就可以实现变量共享了
转载请注明原文地址: https://ju.6miu.com/read-700330.html