question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hello,i meet a error when i run python train.py --dataset Synapse --vit_name R50-ViT-B_16 Error is as follows:

Traceback (most recent call last):
  File "train.py", line 91, in <module>
    net.load_from(weights=np.load(config_vit.pretrained_path))
  File "D:\Python\papers\TransUNet\networks\vit_seg_modeling.py", line 429, in load_from
    unit.load_from(weights, n_block=uname)
  File "D:\Python\papers\TransUNet\networks\vit_seg_modeling.py", line 192, in load_from
    query_weight = np2th(weights[pjoin(ROOT, ATTENTION_Q, "kernel")]).view(self.hidden_size, self.hidden_size).t()
  File "C:\ProgramData\Anaconda3\envs\transnet\lib\site-packages\numpy\lib\npyio.py", line 260, in __getitem__
    raise KeyError("%s is not a file in the archive" % key)
KeyError: 'Transformer/encoderblock_0\\MultiHeadDotProductAttention_1/query\\kernel is not a file in the archive'

env is corrent.and i use win10 and download R50+ViT-B_16.npz model in the right place.can you help me ?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
liyiersancommented, Aug 4, 2021

It seems that you are not successfully access the key in the pretrained weight. Could you please just replace line 192 of vit_seg_modeling.py: query_weight = np2th(weights[pjoin(ROOT, ATTENTION_Q, “kernel”)]).view(self.hidden_size, self.hidden_size).t() with query_weight = np2th(weights[“Transformer/encoderblock_0/MultiHeadDotProductAttention_1/query/kernel”]).view(self.hidden_size, self.hidden_size).t()

If do so and there is no bug in line 192, I guess it is the problem that running on windows.

Let me know if I was wrong. Thanks.

@775397252 @YUUUCC @cwpl I found a better way to solve this. That is :

  1. Create a new file path_util.py in directory networks.

    from os.path import join
    from os.path import normpath
    import platform
    
    def pjoin(path, *paths):
        p = join(path, *paths)
        if platform.system() == "Windows":
            return normpath(p).replace('\\','/')
        else:
            return p
    
  2. Import pjoin in file vit_seg_modeling_resnet_skip.py and vit_seg_modeling.py

from .path_util import pjoin
  1. And this may due to ‘\’ is not recognized by numpy when using np.load to load a npz file.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Train error vs Test error — scikit-learn 1.2.0 documentation
Train error vs Test error¶. Illustration of how the performance of an estimator on unseen data (test data) is not the same as...
Read more >
Training & Test Error: Validating Models in Machine Learning
Training Error : We get the by calculating the classification error of a model on the same data the model was trained on...
Read more >
3. Training error vs Test error - YouTube
3. Training error vs Test error. 8.9K views 2 years ago Machine Learning. Model assessment and model selection.
Read more >
What is a training and test error? - Quora
Training error is the error that you get when you run the trained model back on the training data. Remember that this data...
Read more >
Training Error | Data Mining - Datacadamia
Training error is the prediction error we get applying the model to the same data from which we trained. Training error is much...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found