Skip to content

How to load pretrained weights?  #2

@magenta2n

Description

@magenta2n

I wanted to load the pretrained weights but on specifying --pretrained_dir as the absolute path of the weights file: soyloc.bin, I get the following error:

WARNING - main - Process rank: -1, device: cuda, n_gpu: 1, distributed training: False, 16-bits training: False
Traceback (most recent call last):
File "/FFVT-main/train.py", line 416, in
main()
File "/home/code/classifiers/FFVT-main/train.py", line 409, in main
args, model = setup(args)
File "/FFVT-main/train.py", line 93, in setup
model.load_from(np.load(args.pretrained_dir, allow_pickle=True))
File "/FFVT-main/models/modeling.py", line 379, in load_from
self.transformer.embeddings.patch_embeddings.weight.copy_(np2th(weights["embedding/kernel"], conv=True))
TypeError: 'int' object is not subscriptable

And when I try to load weights I generated(--pretrained_dir= my_ckpt.bin) after training with a custom dataset I get:

Traceback (most recent call last):
File "/FFVT-main/train.py", line 416, in
main()
File "/FFVT-main/train.py", line 409, in main
args, model = setup(args)
File "/FFVT-main/train.py", line 93, in setup
model.load_from(np.load(args.pretrained_dir, allow_pickle=True))
File "/FFVT-main/models/modeling.py", line 379, in load_from
self.transformer.embeddings.patch_embeddings.weight.copy_(np2th(weights["embedding/kernel"], conv=True))
File "/PyEnvs/base/lib/python3.8/site-packages/numpy/lib/npyio.py", line 260, in getitem
raise KeyError("%s is not a file in the archive" % key)
KeyError: 'embedding/kernel is not a file in the archive'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions