Skip to content
This repository has been archived by the owner on Oct 19, 2019. It is now read-only.

is there anyone have successfully load the pretrained model in code? #43

Open
Yiman-GO opened this issue Feb 1, 2018 · 7 comments
Open

Comments

@Yiman-GO
Copy link

Yiman-GO commented Feb 1, 2018

is there anyone have successfully load the pretrained model in code?
I have no idea about it.
I have tried :
saver1 = tf.train.import_meta_graph(pretrained_meta)
saver1.restore(sess, pretrained_ckpt)
but it tells me that "At least two variables have the same name"
if you have loaded successfully, please tell me your method. I will appreciate it.

@GabrielXia
Copy link

Hi @Yiman-GO, I tried something just like you did

with tf.Session() as sess:
    saver = tf.train.import_meta_graph('ResNet-L152.meta')
    saver.restore(sess, "ResNet-L152.ckpt")

And it worked fine, hope it helps !

@Yiman-GO
Copy link
Author

Yiman-GO commented Feb 4, 2018

@GabrielXia I tried but it doesn't work. Can I have a look at your code? I am confused where to add the code.
Also, have you had an implementation on your own data successfully? I abandoned the pretrained model but! it doesn't work. it said that loss is nan. I have no idea about it.
Thank you very much.

@cardwing
Copy link

cardwing commented Mar 25, 2018

The following code works for me where I load the weight of 2D ResNet-50 model into 3D ResNet-50 model:
with tf.Session() as sess:
# build 3D ResNet-50
saver = tf.train.import_meta_graph('/DATA/houyn/pre-trained-models/models/ResNet-L50.meta')
saver.restore(sess, '/DATA/houyn/pre-trained-models/models/ResNet-L50.ckpt')
var_list = saver._var_list
value=[]
for i in range(265):
tmp = sess.run(var_list[i], feed_dict={})
if tmp.shape[0] < 10:
tmp = [tmp / 1.0 / tmp.shape[0] for _ in range(tmp.shape[0])]
tmp = np.stack(tmp, axis=0)
value.append(tmp)
You can use PyCharm to view the variable values and its names in the debug mode.

@SongleChen2015
Copy link

SongleChen2015 commented Dec 27, 2018

@cardwing can you tell me where i can download 3D ResNet-50 model, thanks.

@cardwing
Copy link

@SongleChen2015, the following URL stores the model of 3d resnet-50, please check.
https://drive.google.com/open?id=1WkNtPNqf7-O1-RvXj4auWTH6OYqA2QKG

@SongleChen2015
Copy link

@cardwing I have downloaded the 3d resnet-50 model, thanks. Can you show me an example about how to define a 3d renset-50 network by using tensorflow ? Thanks again.

@berylyellow
Copy link

Hi @Yiman-GO, I tried something just like you did

with tf.Session() as sess:
    saver = tf.train.import_meta_graph('ResNet-L152.meta')
    saver.restore(sess, "ResNet-L152.ckpt")

And it worked fine, hope it helps !

When I do this, get:
ValueError: At least two variables have the same name: fc/biases
How to solve it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants