REDN icon indicating copy to clipboard operation
REDN copied to clipboard

RuntimeError: storage has wrong size: expected -4883207186230854459 got 768

Open kemalaraz opened this issue 4 years ago • 2 comments

When I am trying to load trained model with model.load_state_dict(torch.load("ckpt") I am getting this RuntimeError: storage has wrong size: expected -4883207186230854459 got 768 error. When I searched it says it might be related with workers overwriting on to the same file so how can I resolve this?

Thanks

kemalaraz avatar Apr 29 '20 12:04 kemalaraz

Still waiting an answer on that issue can you please help me on that?

from opennre import encoder, model, framework
import json
import os
import torch
import opennre
root_path = '.'
rel2id = json.load(open(os.path.join(root_path, 'benchmark/nyt10/rel2id.json')))

# Define the sentence encoder
sentence_encoder = opennre.encoder.BERTEncoder(
    max_length=128,
    pretrain_path="bert-base-uncased"
)
m = model.SoftmaxNN(sentence_encoder, len(rel2id), rel2id)
m.load_state_dict(torch.load("ckpt/Newmodel_nyt10_sigmoid_withCLS_-2_768_bert.th")['state_dict'])

When I run this script I am getting "RuntimeError: storage has wrong size: expected -4883207186230854459 got 768" error. Thanks

kemalaraz avatar May 04 '20 09:05 kemalaraz

Maybe you open multiple instances of this code but without change the saving directory?

slczgwh avatar Jun 01 '20 00:06 slczgwh