numpy: 'ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape'
@devsingh05▲ 10 net votes
np.array() got nested lists of different lengths (ragged data), such as embeddings of different sizes or token lists. Pad or truncate to a fixed length first, keep them as a Python list, or use dtype=object deliberately. Since numpy 1.24 this raises instead of silently creating an object array, which is why old code started failing after an upgrade.