facebookresearch / SentEval

A python tool for evaluating the quality of sentence embeddings.
Other
2.09k stars 309 forks source link

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (750,) + inhomogeneous part. #94

Open guankaisi opened 1 year ago

guankaisi commented 1 year ago

sent1 = np.array([s.split() for s in sent1])[not_empty_idx] In this line, the element of [s.split() for s in sent1] is not the same len. It will report this error. Has anyone met the same one? I change the code to `sent1_lengths = [len(s.split()) for s in sent1] sent2_lengths = [len(s.split()) for s in sent2] max_length = max(max(sent1_lengths), max(sent2_lengths))

sent1 = np.array([s.split() + [''] (max_length - len(s.split())) for s in sent1])[not_empty_idx] sent2 = np.array([s.split() + [''] (max_length - len(s.split())) for s in sent2])[not_empty_idx] ` and then the code go right.

taofendenanhai commented 1 year ago

it works