我得到了
Index error: Tuple index out of range while doing one-hot encoding for smile string at line:
if ans.shape[1]<length:
示例:
smiles_string= ['C','C','1','=','(','N','2',')','O','3','4','4']
char_list=['7','.','Br','Pt','[','F','6','S','5','I',']','+','8','#','B','9','Cl','P','-','N']
def onehot_encode(char_list,smiles_string,length):
encode_row = lambda char: map(int,[c == char for c in smiles_string])
print(encode_row)
ans = np.array(map(encode_row,char_list))
if ans.shape[1] < length:
residual = np.zeros((len(char_list),length - ans.shape[1]),dtype=np.int8)
ans = np.concatenate((ans,residual),axis=1)
return ans
我尝试调试,但发现ans数组的形状为(),这不应该发生。
如果任何人都可以提出有关如何映射它并解决错误的想法,将不胜感激。
谢谢。