# n * one_hot VS n_hot encoding for modeling input layer for a card game

How should I design my input layer for the following classification problem?

Input: 5 cards in a card game; vocabulary is 52 cards

Output: some classification using a neural network

How should I model the input layer?

Option A: 5 one hot encodings for the 5 cards, i.e. 5 one_hot vectors of length 52 = 260 input vector E.g.

[
[0,0,0,0,0,0,1,...],
[1,0,0,0,0,0,0,...],
[0,0,0,0,0,1,0,...],
[0,0,1,0,0,0,0,...],
[0,0,0,0,1,0,0,...]
]


Option B: 5 hot encoding encompassing all 5 cards in one 52 element vector

[1,0,1,0,1,1,1,...]


What are the disadvantages between A and B?

Option (A) - This would be the naive way to put it in network that operates on series. like RNN. (example of where you would need it - texas holdem)

Option (B) - This would be the way to put entire configuration at once, where you are dealt the entire hand in one shot. this would be the naive way to put it in a MLP (example - sorry, dont know many card games. Any card game where you are dealt entire hand at once)

my suggestion - Neither.

since there are relations among the cards dependent upon the design of the game use distributed representation and learn them along with network

• Thanks for your insight. Just to confirm - you're saying it is OK to use n_hot inputs for MLPs right? I've only ever seen one_hot representations and I was wondering if n_hot is ok too or if it hinders learning in some way. – deekay42 Jun 28 '18 at 18:11
• Yes it is. The reason you have seen only one-hot representations is because of NLP where it is used in time series data like natural language. But in this one hot representation make a tweak - instead of 0s in the places where the cards are not there, use some other number and be consistent with it. it would be hard to train this neural network. I would again recommend distributed representation – MiloMinderbinder Jun 28 '18 at 18:18
• Why use some other number and not 0? – deekay42 Jun 28 '18 at 18:27
• 0*anynumber = 0. for other numbers the network can learn some interactions – MiloMinderbinder Jun 28 '18 at 18:28
• I was actually considering using an embedding layer as a distributed representation as you suggested. However, same question applies as above: How do I structure the input layer? Do I feed five separate one_hot encodings (for my five cards) into my embedding layer or one 5_hot encoding? I am clear how to encode one card (one_hot -> embedding layer->network) but how do I feed in 5 cards? – deekay42 Jun 28 '18 at 18:35