Retraining a pretrained model - transfer learning

I have a decent keras model, trained on timeseries data, from some industrial machines accelerometer data.

Initially i would like to re-train my edge device using the pretrained model and the same sampled data, played on a speaker, and recorded on a microphone on the edge device. Later on i will use an accelerometer on the live machine.

The question is: Can i load my trained & non quantised .h5 model using keras/expert mode ?
To then freeze and retrain only the lower layers on the microphone data captured in EI.


Hi Morten,

This is an interesting question! We don’t currently provide a mechanism for developers to upload files into Edge Impulse, so the most viable option for loading a pre-trained model would be to in-line the H5 model into the expert mode editor in some kind of string encoding.

For example, using base64 it might look something like this:

# Decode the string
model_data_base64 = '...'
model_data = model_data_base64.encode('utf-8')
model_data = base64.decodebytes(model_data)
# Wrap in the correct class
h5_file = h5py.File(model_data)
# Load as Keras model
model = tf.keras.models.load_model(h5_file)

I haven’t run the above code so it may need some debugging, but give this a try and let me know if it works! The downside will be that the Python editor will be mostly filled with a long base64-encoded string, which isn’t a great user experience. If this seems like a helpful approach, we can think about ways to enable it that are more seamless.


@opprud Question here would also be whether transfer learning is actually viable on this type of data. We see it working really well on images because the lower layers of the network always embed similar things (contrast, shapes, colors) and training these layers against a well-validated and balanced dataset helps generalize the network when retraining the upper layers with a smaller dataset.

We don’t see it working very well on audio / accelerometer data - but would be interested to see what you find!