0

I am trying to implement a multi-agent decentralized execution algorithm in Keras. Each agent is supposed to observe only a part of the observation vector. To this end, I am using concatenate to pick up certain elements from the vector and combine them as an input vector to a certain agent. Here x2 is the global observation vector

for i in range(nagents):

    x2 = concatenate(inputs = [x2[:,i*5:(i*5+5)],x2[:,i+50:i+51],x2[:,60:61]])
    vars()['inp_p%d'%i]=x2
    vars()['x_p%d'%i]= Dense(20, activation='relu')(vars()['inp_p%d'%i])
    vars()['x_p%d'%i]= Dense(20, activation='relu')(vars()['x_p%d'%i])
    vars()['out_p%d'%i] = Dense(2,activation = 'softmax')(vars()['x_p%d'%i])
out = list(np.zeros(ncomp))
for i in range(ncomp):
    out[i] = vars()['out_p%d'%i]

However, I get the following error:

--> 234         vars()['x_p%d'%i]= Dense(20, activation='relu')(vars()['inp_p%d'%i])
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

It works when we use the whole x2 vector as an input.

Adriaan
  • 17,741
  • 7
  • 42
  • 75
  • Welcome to Stack Overflow! Please remember that Stack Overflow is not your favourite Python forum, but rather a question and answer site for all programming related questions. Thus, always include the tag of the language you are programming in, that way other users familiar with that language can more easily find your question. Take the [tour] and read up on [ask] to get more information on how this site works, then [edit] the question with the relevant tags. – Adriaan May 30 '23 at 12:33

0 Answers0