Custom Neural Networks

Hello ,
After Feature processing stage in the impulse design. Can we add our Custom Networks which of our own set of parameters , for example if i want to apply Support Vector Machines algorithm??

Hello @madda,

I am not sure about about Vector Machine algorithm but you can switch to the expert mode in the Learning Blocks:
On the Neural Network page click and select Switch to Keras (expert) mode. And you will have access to the full Keras API: https://docs.edgeimpulse.com/docs/faq#can-i-use-a-model-that-has-been-trained-elsewhere-in-edge-impulse

Regards,

Louis

1 Like

Also, you can click the three dots on the neural network page => edit as iPython notebook, and you can work on some custom work directly from a notebook (although you can’t import the model back into Edge Impulse then, but at least you’ll have data acquisition etc working).

1 Like

Does anyone have an example of how to load a vision model for direct training into Edge Impulse. I would like to see if I can edit it.

I know most of the Edge Impulse models use transfer learning, but for the sake of understanding how things work, if we were to switch to Keras(expert) mode and wanted to train a model from scratch say with this set of sequential layers. (I am not really interested in accuracy just want to see if it works.)


model = tf.sequential();                                                                                                                                          
                                                                                                                                                                        
model.add(tf.layers.conv2d({                                                                                                                                            
    inputShape: [96, 96, 1],                                                                                                                                                  
    kernelSize: 2,                                                                                                                                                          
    filters: 4,                                                                                                                                                             
    strides: 8,                                                                                                                                                             
    activation: 'relu',                                                                                                                                                     
    kernelInitializer: 'varianceScaling'                                                                                                                                    
}));                                                                                                                                                                    
                                                                                                                                                                        
model.add(tf.layers.conv2d({ kernelSize: 2, filters: 4, strides: 8, activation: 'relu', kernelInitializer: 'varianceScaling' }));                                       
                                                                                                                                                                        
model.add(tf.layers.flatten());                                                                                                                                         
model.add(tf.layers.dense({ units: 30, kernelInitializer: 'varianceScaling', activation: 'softmax' }));                                                                 
model.add(tf.layers.dense({ units: 4, activation: 'linear' }) ); 

This model was written in TensorflowJS so it might look a bit different from Python.

Does anyone have an example link of how to load a very simple vision model for direct training into Edge Impulse, (96x96 Grayscale would be perfect) so I can edit it and see if I can train the above model?

@Rocksetta In Create impulse remove the transfer learning block, and add a Classification block. You’ll get an example architecture with 2 conv layers, and expert mode works too.

1 Like

Thanks @janjongboom I tried it all day and was aiming to make a smaller model at 224x224 Grayscale resolution than I could get working using MobileNet and transfer learning with the Arduino Portenta Vision shield. Strangely could not, even with a really small, from scratch conv layer model. Somehow the MobileNet final model is smaller even though I know the model has many more layers. I did get a 160x160 pixel model working from scratch, but that was it.

Lesson: Transfer learning rocks!

2 Likes

hi @madda try out this with expert mode on edge impulse A Quasi-SVM in Keras

1 Like