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
  ndim array Sowmya 2 220 Apr-03-2024, 04:19 AM
Last Post: Sowmya
  [Numpy] How to store different data type in one numpy array? water 7 540 Mar-26-2024, 02:18 PM
Last Post: snippsat
  [Numpy] Load date/time from .txt to 'datetime64' type. water 4 560 Mar-01-2024, 11:16 PM
Last Post: Gribouillis
  LDA Model prepare() method failure in Python noerkes 0 308 Feb-22-2024, 01:42 PM
Last Post: noerkes
  boolean array: looking for all rows where all is True paul18fr 4 1,206 Jan-04-2023, 09:58 PM
Last Post: paul18fr
  reshaping 2D numpy array paul18fr 3 1,008 Jan-03-2023, 06:45 PM
Last Post: paul18fr
  Turn list of arrays into an array of lists Cola_Reb 6 1,707 Jul-20-2022, 06:55 PM
Last Post: Cola_Reb
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,602 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 1,596 Jul-02-2022, 01:55 PM
Last Post: Larz60+
  replace sets of values in an array without using loops paul18fr 7 1,712 Jun-20-2022, 08:15 PM
Last Post: paul18fr

Forum Jump:

User Panel Messages

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