1
$\begingroup$

I have to train a feedforward neural network for pattern recognition in matlab. Each example has 4 matrices of the same size (e.g. $N$ x $K$).

The form I know to enter the values to the network is to convert each matrix into a vector and enter each value of each matrix as a single feature.

But I would like to know how to tell the network (and if I have to tell the network) that the element $(i,j)$ of one matrix is related with the element $(i,j)$ of all the other matrices.

Thanks.

$\endgroup$

2 Answers 2

1
$\begingroup$

Instead of converting matrices into a single vector, you can follow the structure of convolutional neural networks for images, where the four matrices correspond to four input channels, and the elements of the same position are connected together by definition.

If you don't need the assumption that an element is also related with its neighbors, you can use 1*1 convolutional layers and then fully connected layers.

If you don't need the assumption that common patterns are shared across different positions, you can remove/relax the parameter sharing scheme.

$\endgroup$
2
  • $\begingroup$ Thank you very much. I need the assumption that an element is related with this neighbors, but common patterns aren´t shared across different positions. I don´t know much about convolutional neural networks, I will read more. $\endgroup$
    – juan9793
    Commented Nov 17, 2016 at 16:19
  • $\begingroup$ @JuanLautaroMorenoMorrone you are welcome :) $\endgroup$
    – dontloo
    Commented Nov 17, 2016 at 16:45
2
$\begingroup$

So, the question you are asking is: "How do I tell the network that the values at the same position $(i,j)$ in different examples are related"?
Dontloo is answering the question: "How do I tell the network that values in the same example, at close positions are related, i.e. tell the network that $(i,j)$ is related to $(i-1,j)$, $(i+1,j)$, $(i,j+1)$, etc." For the second question, Dontloo is correct that convolutional neural networks are the way to go. However for the first question, the answer is much simpler: you don't really need to do anything. You just need to make sure that you feed $(i,j)$ into the same neuron of the neural network each time, and then everything works out. So if you vectorize the matrix, you for example need to make sure that you do that consistently row-wise or consistently column-wise and not mix that up. The neural network will then learn how to process each input value, and since each $(i,j)$ is supplied into the same input neuron each time, it will use the patterns it sees in the $(i,j)$ of different examples. So no need to do anything except keeping everything consistent

$\endgroup$
1
  • $\begingroup$ Thank you very much! The question was the one that Dontloo answers. I don´t know much about convolutional neural networks, but I will read more. $\endgroup$
    – juan9793
    Commented Nov 17, 2016 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.