0

I have list with different element size. Here is the attachment for the reference:

enter image description here

As can be seen in the image, first list element size is1095, second 16, third 66, and so on. This List should now be converted to a NumPy array. As far as I know, all of the List's elements should be the same size for conversion. However, I've seen some stack overflow posts stack overflow posts where individuals converted a list of different element sizes to a NumPy array with Null or 0 values to to the elements in order to do the size uniform.

However, I do not want to change my data via adding any 0 or Null values. Because I need to input it into the deep model as is. Is there a method to convert a list of elements (different component sizes) to a NumPy array without changing the data?

3
  • What kind of array does your model require? What you want does not matter. Commented Mar 4, 2022 at 5:19
  • I did not ask what you are using. Commented Mar 4, 2022 at 5:29
  • my model required numpy array Commented Mar 4, 2022 at 5:32

1 Answer 1

-1

If you want to use the list as the input for your deep learning model, you can use the mask and padding. You can find it here https://www.tensorflow.org/guide/keras/masking_and_padding Check that it does not change your data to int. You need to use pad_sequences(x, dtype='float32') (or 'float64') or something like this.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks. Somehow its working. But it converting data to int. Which ignore all the float information. How can you handle that?
You need to use pad_sequences(x, dtype='float32') (or 'float64', as you see fit) or something.
I went through your given link, there masking is done column wise. Here in my case it is in row wise. So the question is, would tensorflow keras also ignore these values?
Hi, my input layer is input_layer = tf.keras.Input(shape=input_shape, name="time_series_activity") con_l1 = tf.keras.layers.Conv2D(64, (5, 1), activation="relu")(input_layer) . How to add mask_zero=True here. As in the official documentation, its through layers.Embedding?
Does this concept is just for RNN models, not for others like CNN or hybrid model like CNN, LSTM, Attention etc?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.