Python Forum
How to prepare a NumPy array which include float type array elements
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to prepare a NumPy array which include float type array elements
#1
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  np.where on 3Darray => result remains a 3D array paul18fr 1 3,836 Sep-10-2025, 04:19 AM
Last Post: Pedroski55
  ndim array Sowmya 2 1,855 Apr-03-2024, 04:19 AM
Last Post: Sowmya
  [Numpy] How to store different data type in one numpy array? water 7 4,095 Mar-26-2024, 02:18 PM
Last Post: snippsat
  [Numpy] Load date/time from .txt to 'datetime64' type. water 4 4,869 Mar-01-2024, 11:16 PM
Last Post: Gribouillis
  LDA Model prepare() method failure in Python noerkes 0 1,899 Feb-22-2024, 01:42 PM
Last Post: noerkes
  boolean array: looking for all rows where all is True paul18fr 4 3,400 Jan-04-2023, 09:58 PM
Last Post: paul18fr
  reshaping 2D numpy array paul18fr 3 2,879 Jan-03-2023, 06:45 PM
Last Post: paul18fr
  Turn list of arrays into an array of lists Cola_Reb 6 3,835 Jul-20-2022, 06:55 PM
Last Post: Cola_Reb
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 5,433 Jul-19-2022, 06:31 AM
Last Post: paul18fr
Question how to write a function that accepts a 1D array as a parameter in Python SuperNinja3I3 1 2,880 Jul-02-2022, 01:55 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020