0

Here is my code:

        bsp = Input(shape = (1,3,))
        V1 = Dense(2,activation = 'softmax')(bsp)

        # b = Dense(5, activation = "relu")(B)
        # inputs = [B]
        # merges = [b]
        S_input = Input(shape = (15,4))
        S = Reshape((15,4,1))(S_input)
        #inputs.append(S)

        x2 = inception(S)

        # merge and add
        V2 = Dense(2, activation = 'softmax')(x2)
        V = add([V1,V2])
        model = Model(inputs = [bsp,S_input], outputs = V)

        model.predict([observation[0],observation[1]])

Basically it's a model with 2 inputs and 1 output. In the final computation, the 2 inputs were added together and passed into the final model. However, it has error as :

Traceback (most recent call last):
  File "C:/Users/User/Desktop/Learning Materials/programming/python_code/RL/LabFiles_RL/stock_market_reinforcement_learning/market_pg.py", line 157, in <module>
    pg.train(verbose = 1)
  File "C:/Users/User/Desktop/Learning Materials/programming/python_code/RL/LabFiles_RL/stock_market_reinforcement_learning/market_pg.py", line 66, in train
    aprob = model.predict([observation[0],observation[1]])[0]
  File "C:\Users\User\Anaconda3\lib\site-packages\keras\engine\training.py", line 1172, in predict
    steps=steps)
  File "C:\Users\User\Anaconda3\lib\site-packages\keras\engine\training_arrays.py", line 297, in predict_loop
    batch_outs = f(ins_batch)
  File "C:\Users\User\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2661, in __call__
    return self._call(inputs)
  File "C:\Users\User\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2614, in _call
    dtype=tensor.dtype.base_dtype.name))
  File "C:\Users\User\Anaconda3\lib\site-packages\numpy\core\numeric.py", line 492, in asarray
    return array(a, dtype, copy=False, order=order)
ValueError: setting an array element with a sequence.

As mentioned in the other similar questions, I have ensured that the two inputs are of same dimension, in my case, which are shape of (1,1,3) and (1,15,4).

How can I fix the problem ?

exteral
  • 991
  • 2
  • 12
  • 33

1 Answers1

0

I would look into the datatypes of the arrays and set them to float during construction. This is a numpy error, discussed here:

ValueError: setting an array element with a sequence

papayiannis
  • 114
  • 5