Hello
I have file of sequence of letters ( 8 different letter) at each line. the maximum sequence length is 700.
I would like to create one hot vector for each one . to create one vector
I defined this method
import numpy as np
def one_hot_encode(seq):
dict = {}
mapping = {“B”:0,“L”:1 ,“E”:2, “G”: 3,“H”:4,“I”:5,“S”:6,“T”:7}
print(mapping)
seq2 = [mapping[i] for i in seq]
return np.eye(20)[seq2]
with open(“train_target.txt”) as f, open(‘out_train_target.txt’, ‘w’) as out:
for line in f:
s= line
a = one_hot_encode(line)
print(a)
It give me an error
seq2 = [mapping[i] for i in seq]
KeyError: ‘\n’
Anyone know what that error means