This is most probably caused due to tensor shape, there is either an empty tensor that might have crept in at some point or there might be tensor size mismatch. A possible solution, in order to debug the code, print out the tensor shape for your entire net and remove the error accordingly.