Keras and Error: Setting an array element with a sequence

后端 未结 3 2099
逝去的感伤
逝去的感伤 2021-01-21 11:49

I have a problem with the input of multiple data sources in my neural network. My dataframe is:

                           0  1  2                   3   4  
0            


        
相关标签:
3条回答
  • 2021-01-21 12:12

    First of all, convert the input array into numpy array and convert the categorical boolean inputs into numbers. Then, give input dimension = 8 instead of 4.

    0 讨论(0)
  • 2021-01-21 12:13

    The list inside the numpy array needs to be flattened before insertion.

    array is [[False, False, True], 4, -10, [False, True, False], 1] in the OP implementation,

    and should be flattened to [False, False, True, 4, -10, False, True, False, 1].

    Here is a working jupyter notebook demonstrating this.

    0 讨论(0)
  • 2021-01-21 12:22

    You are trying to input 2 different types of data to the neuron of a neural network. Neural networks isn't a magical box to throw random information into it and expect it to give a reasonable output.

    NN's take only numbers as input. When you flatten your data

    [False, False, True, 4, -10, False, True, False, 1] to this format, what you are effectively doing is converting it into this [0,0,1,4,-10,0,1,0,1].

    I am not really sure what you want from this data but, if you want only 5 features, you can take the majority outcome for those with binary values.

    arr = [[False, False, True], 4, -10, [False, True, False], 1]
    

    can be converted to

    arr = [False,4,-10,False,1]
    

    which effectively means your input is

    arr=[0,4,-10,0,1]
    

    But, before you do this, be sure what you're trying to do makes sense. You need to be able to answer questions like "what does each value represent?", "do i need to normalize the data?", "Would True/False in this dataset make sense?".

    0 讨论(0)
提交回复
热议问题