I've read most of the posts on here regarding this subject, however most of them deal with gameboards where there are two different categories of single pieces on a board without walls etc.

My game board has walls, and multiple instances of food. There are 8 different categories, Walls, enemy food, my food, enemy powerup, my powerup, attackable enemies, threatening enemies, and current teammate.

I have one hot encoded all of this data into a tensor of size (8, 16, 32) where (16, 32) are the sizes of the game grid. However I'm not sure whether this is appropriate since many of the categories have multiple occurrences of each category in a single (walls, food). Is it appropriate to use one hot encoding to represent categories in spatial data, where multiple one's may be present?

The alternative I was considering was to use a CNN, however many posts have said it is inappropriate for one hot data. My reasoning was that since the data is a abstract Boolean grid representing the RGB frames, it might be appropriate.

Does anyone have any suggestions as to the best way to represent a spatial Boolean grid representing multiple categories for input to a network?


1 Answer 1


The way you describe with one hot encoding is correct.

Note that how the state is encoded is a separate question from the neural network, so I'm not sure what convolutional neural networks have to do with the question. In the famous atari game example, the input is a sequence of RGB images; a cnn is used to process the images. In your example you probably just want to use a regular Dense network, as your input is just the one hot encoding and not images.

  • $\begingroup$ Ahh, i've gone with a Dense network now. Do you think I should use activation functions? at the moment my network is outputting values between -1 and 1. I'm guessing it'd be better to use the probabilities as my reward function is a sum of percentages $\endgroup$ Sep 7, 2021 at 2:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .