I’ve created this:
def loadEmbd():
upload a glove embedding dict file to generate the input output.
glovefname = '…/glove/glove.6B.50d.txt’
gmat = []
gdict2 = OrderedDict()
for h, line in enumerate(open(glovefname, ‘r’).readlines()):
line = line.strip()
line = line.split()
word = line[0]
gdict2[word] = h
vector = [float(item) for item in line[1:]]
gmat.append(vector)
return gmat, gdict2
And after constructing the model with the embedding mat (gmat)
I tried to load the dict with:
model.load_state_dict(gdict2)
but it said:
KeyError: ‘unexpected key “the” in state_dict’