'Python: Unable to convert list of arrays to tensor
I have a list of arrays containing embeddings:
train_x_l = []
for i in range(0, len(train_embeddings)):
train_x_l.append(max_pooling(train_embeddings[i], 100))
val_x_l = []
for i in range(0, len(val_embeddings)):
val_x_l.append(max_pooling(val_embeddings[i], 100))
test_x_l = []
for i in range(0, len(test_embeddings)):
test_x_l.append(max_pooling(test_embeddings[i], 100))
I know that they need to be converted into tensor before it can be passed to model.fit. However, when I try to convert them the program just ran infinitely. List size is not that large. train_x_l is of length 9600 while val_x_l and test_x_l are only 1200 in size. Following are the command that are running forever:
train_x = np.asarray(train_x_l).astype(np.int_)
val_x = np.asarray(val_x_l).astype(np.int_)
test_x = np.asarray(test_x_l).astype(np.int_)
I only get a warning and no error message, so its difficult for me to troubleshoot it. Can someone help me in fixing this problem?
/var/folders/vz/gpzxhx9x3nzbg0fm1w7bt_7m0000gn/T/ipykernel_1214/1704967012.py:1: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
train_x = np.asarray(train_x_l).astype(np.int_)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|