It will be handy to have a few tips that might be helpful while solving other problems, and also mention some topics that might help those who want to go further into deep learning. The first tip I am going to give you is about reshaping arrays. It is very common for R users to reshape arrays this way:
dim(<array object>) <- c(<new dimensions>)
Unfortunately, this might not work every single time because while R uses a column-major order, numpy and other libraries called by keras use a row-major order as default. For this, we can use something like the following pseudo code:
<array object> <- array_reshape(<array object>, c(<new dimensions>))
This is a really good trick, and I hope you don't get caught by it. If you are interested ...