问题
Given an array of the form
array([list([21603, 125, 737, 579, 2065, 10399, 1175, 0, 0, 0]),
...
list([1896, 3917, 498, 296, 1452, 523, 754, 450, 3795, 341])],
dtype=object)
How do you prepare it to be consumed by a Keras model in TensorFlow 2.0 RC0? In its current form it throws the error
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type list).
and I can't seem to get it in the form I'm familiar with,
array([[21603, 125, 737, 579, 2065, 10399, 1175, 0, 0, 0],
...
[1896, 3917, 498, 296, 1452, 523, 754, 450, 3795, 341]])
回答1:
If you find yourself in this situation, you can correct your array(s) with the following:
new_array = np.array(list(x for x in old_array))
来源:https://stackoverflow.com/questions/57760510/converting-array-of-lists-to-keras-input