print out the shape of the tensors for all operations, and then you will get a better idea of how Tensor shapes change with each operation.
After that, you can figure out what line to change to make the dimensions match.