This example is for when you would like to pass sets of input features to independent branches of a neural network and then combine the results for a final classification.If you plan on passing all input features through a fully connected network, then these steps are unnecessary; Edge Impulse automatically concatenates output features from processing blocks and learning blocks operate on the concatenated array.
Example use cases
By using this architecture, you can perform sophisticated sensor fusion tasks, potentially improving classification accuracy and robustness compared to single-input models. This type of model is particularly useful in situations such as:- Combining data from different sensor types (e.g. accelerometer and gyroscope)
- Handling output from multiple feature extractors (e.g. time-domain and frequency-domain features)
- Analyzing data from sensors in different locations
Model architecture
The architecture in this tutorial consists of separating the model input into two sets of 2D input features (input layer and reshape layers), passing them through independent convolutional branches, and then combining the results for classification (concatenate layer and dense layer). See below for additional details.Input layer
The input layer accepts a one-dimensional (1D) input of lengthinput_length
. The input_length
argument is available if you are using the learning blocks pre-built by Edge Impulse and modifying them through expert mode. By default, Edge Impulse flattens the output of all processing blocks before passing them to the learning block, so the shape is a 1D array.
Reshape layers
The model input is first split into two halves and then reshaped back into 2D formats. In this example, we assumed spectrogram inputs with 50 columns (time frames) each. We calculated the number of rows based on the number of columns and channels, then used the row and column information for the reshape layer.Convolutional branches
Each half of the input goes through its own convolutional branch that contains multiple layers:- Conv2D layers (8 and 16 filters)
- MaxPooling2D layers for downsampling
- Dropout layers for regularization
- Flatten layer to prepare for concatenation
Output layers
Finally, the outputs of the two independent branches are combined with a concatenation layer. This combined output is then passed through a final dense layer with a softmax activation to perform classification.Keras model
The following code snippet can be copied and pasted into a classification learning block using the expert mode feature within Studio.Extending the model architecture
To extend this model architecture to handle more inputs, you can:- Split the input into more sections (e.g. thirds or quarters instead of halves).
- Create additional convolutional branches for each new input section.
- Include the new branches in the concatenation step before the final dense layer.