Keras' convolutional and deconvolutional layers are designed for square grids. Is there was a way to adapt them for use in hexagonal grids?
For example, if we were using axial coordinates, the input of the kernel of radius 1 centered at (x,y)
should be:
[(x-1,y), (x-1,y+1), (x,y-1), (x,y+1), (x+1,y-1), (x+1, y)]
One option is to fudge it with a 3 by 3 box, but then you are using cells at different distances.
Some ideas:
- Modify Kera's convolutional layer code to use those inputs instead of the default inputs. The problem is that Kera calls its backend instead of implementing it itself, which means we need to modify the backend too.
- Use a 3 by 3 box, but set the weights at
(x-1,y-1)
and(x+1,y+1)
to zero. Unfortunately, I do not know how to permanently set weights to a given value in Kera. - Use cube coordinates instead of Axial coordinates. In this case, a 3 by 3 by 3 box will only contain the central hex's neighbors and inputs set to 0. The problem is that it makes the input array much bigger. Even more problematic, some coordinates that correspond to non-hexes (such as (1,0,0)) will be assigned non-zero outputs (since (0,0,0) falls within its 3 by 3 by 3 box).
Are there any better solutions?