Is it possible to generate an 1D dimensional output of a 2D convolutional layer in Keras? I'm trying to apply convolutional neural networks for dealing with a 2D input, which is a 2X300 matrix. It is basically a matrix with 2 lines, where each line is a vector of 300 positions.
I would like to apply a kernel of size 2X1 (two lines and one column). The idea is to apply the kernel to each position i of the two vectors. Intuitively, I think that this convolution operation would generate an output of size 1X300. That is, I think that the output will be an unidimensional vector with 300 columns. Am I right?
I would like to include a convolutional layer like this:
layers.Conv2D(10, kernel_size=(2, 1), activation="relu",name="conv1")

That makes sense? Will this layer generate a one-dimensional vector of 300 positions?
 A: Suppose $A$ is a $p \times n$ matrix and $x$ is a $p \times 1$ vector. The product
$y=A^\top x$ has shape $n \times 1$, where each entry $y_{ij} = \sum_{k=1}^p a_{ki}x_{kj}$.
If we choose $n=300$ and $p=2$, we end up with $A^\top x$ a $300 \times 1$ vector.
A single convolution filter computes a linear function over patches of a matrix. You've chosen a $2 \times 1$ convolution, so for this case, it is a matrix-vector product over patches of a matrix. This is because if we further require the filter to not "stick out" beyond the edges of the matrix (which is the Keras default), then the output of passing the filter over the image is computed as $\sum_{k=1}^p a_{ki}x_{kj}$. That is, the filter always covers an entire column of $A$ (equiv. entire row of $A^\top$). This is the same expression as the expression for a matrix vector product.
You've further specified using 10 filters, so you do this process 10 times. Or, more compactly, we can write this as a matrix-matrix product: $A^\top X$ for $X$ a $2 \times 10$ matrix, which produces a $300 \times 10$ matrix as an output.

This answer just builds on @displayname's helpful comment.
