Skip to content
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

Error on loading pre-trained model #54

Closed
robi56 opened this issue Jan 13, 2020 · 1 comment
Closed

Error on loading pre-trained model #54

robi56 opened this issue Jan 13, 2020 · 1 comment

Comments

@robi56
Copy link

robi56 commented Jan 13, 2020

I am trying to work on transfer learning using Mobilenet Pretrained model

model = nets.MobileNet35v2(inputs, is_training=True, classes=2)
with tf.Session() as sess:
nets.pretrained(model)

But this gives the following error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-ba2d4690d272> in <module>
      8 
      9 with tf.Session() as sess:
---> 10     nets.pretrained(model)
     11 
     12     for i in range(0,len(epochs)):

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/tensornets/pretrained.py in assign(scopes)
     56         model_name = parse_scopes(scope)[0]
     57         try:
---> 58             __load_dict__[model_name](scope)
     59         except KeyError:
     60             try:

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/tensornets/pretrained.py in load_mobilenet35v2(scopes, return_fn)
    550         file_hash='cf758f7f8024d39365e553ec924bb395')
    551     values = parse_weights(weights_path)
--> 552     return return_fn(scopes, values)
    553 
    554 

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/tensornets/pretrained.py in _assign(scopes, values)
    108 
    109     for scope in scopes:
--> 110         sess.run(pretrained_initializer(scope, values))
    111 
    112 

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/tensornets/utils.py in pretrained_initializer(scope, values)
    324                       'Never mind if you are trying to load stem layers only.')
    325 
--> 326     if scope.dtype == tf.float16:
    327         ops = [weights[0].assign(np.asarray(values[0], dtype=np.float16))]
    328         for (w, v) in zip(weights[1:-2], values[1:-2]):

AttributeError: 'str' object has no attribute 'dtype'
@taehoonlee
Copy link
Owner

@robi56, The nets.pretrained() will be depreciated. Please use sess.run(model.pretrained()) instead.

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

No branches or pull requests

2 participants