You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 this issue
Jun 20, 2023
· 1 comment
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: