-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The output problem of sharing weights. #28
Comments
@taehoonlee Do you have any idea? Is it a bug? |
@LynnHo, Sorry for the late reply. This is because the two models have the same prefix for the output tensors. Currently, the following is one of the workarounds: import tensorflow as tf
import tensornets as nets
from functools import partial
x_1 = tf.placeholder(tf.float32, [None, 224, 224, 3], name='x1')
x_2 = tf.placeholder(tf.float32, [None, 224, 224, 3], name='x2')
resnet = partial(nets.ResNet50, scope='resnet50', reuse=tf.AUTO_REUSE)
model1 = resnet(x_1)
with tf.name_scope('xx'):
model2 = resnet(x_2)
assert len(model1.get_outputs()) == 161
assert len(model2.get_outputs()) == 161
assert len(model1.get_weights()) == 320
assert len(model2.get_weights()) == 320 If I find the elegant methods or make weight sharing more seamless, I'll let you know. Thank you for the reports! |
The recent updates address the issue you reported. Currently, I recommend the following pattern: with tf.name_scope('clone0'):
model1 = nets.ResNet50(x1, reuse=tf.AUTO_REUSE)
with tf.name_scope('clone1'):
model2 = nets.ResNet50(x2, reuse=tf.AUTO_REUSE) These are the materials you might be interested in:
If you want to use the latest version, you can try |
@taehoonlee Thanks for your effort! Tensornets really helps in my works! |
I use the code like below,
outputs_2
appends the outputs ofx_2
tooutputs_1
.The text was updated successfully, but these errors were encountered: