Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

python - Multiple Inputs for neural network in tensorflow?

Im trying to implement a reinforcement learning algorithm with tensorflow to train an agent.

I want my neural network to have 2 different inputs, the first one an image stack of 4 images with the shape (4,160,120,1) and then just a one dimensional array with 10 entries.

I tried to do it like i did with just one input and defined my call function of my neural network with two inputs and ran my program. When the function train_on_batch was executed it resulted in an error and i received following message, in which states2 is my second input:

ValueError: Models passed to train_on_batch can only have training and the first argument in call as positional arguments, found: ['state2']

So how can I use two inputs for my neural network and still be able to use train_on_batch?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You would need to either concatenate the inputs into a single npy array, or use a list of arrays, as stated in the documentation when running the tf.keras.Model.train_on_batch() function.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...