Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@guankaisi
Copy link

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
Copy link

it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants