Python Forum

Full Version: How to prepare a NumPy array which include float type array elements
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For a Graph based machine learning task, I need to input a Numpy array in the following format.
array([array([[1., 0., 0., 0., 0.],
[0., 1., 0., 0., 0.],
[0., 0., 0., 0., 1.]], dtype=float32),
array([[1., 0., 0., 0., 0.],
[1., 0., 0., 0., 0.],
[0., 0., 0., 0., 1.]], dtype=float32)], dtype=object)

However, currently I'm having the input as below.
array([[[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.]],

[[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.]]], dtype=float32)

This has the shape (2, 3, 5), but I need to have an input with shape (2,). When I analyze the smaple input I understood that its an array of arrays. But I'm sturggling to convert my input into that format. Can anyone please help on this matter?