NeuralFeatureExtractor (NFE) enables feature extraction from trained PyTorch model
current version supports following models:
- pytorch MNIST CNN example
- Keyword Spotting: Honk & Google Speech Command dataset
- CNN example for MNIST & Facial Expression Research Group Database (FERG-DB)
Details can be found below
- csv
To support new file type, simply write a class that inherits FileHandler
In order to add a new model, copy and paste your model to model folder and modify the forward
function to return the intermediate representation
The new model must be added to __init__.py as well.
Then, the trained model must be stored under pretrained_model folder
Next, copy and paste your DataLoader to data_loader folder
NFE requires two configurations
model_config
: configuration for the Modeldata_config
: configuration for the DataLoader
Samples can be found from config folder
The following command generates features and stored them at generated/<model name>
python main.py --model_config <model_config> --data_config <data_config>
target classes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] feature size : 196
python main.py --model_config config/mnist/model_config.json --data_config config/mnist/data_config.json
Relevant packages can be installted by running pip install -r per_model_requirements/kws_res_model.txt
The dataset must be downloaded prior to feature extraction. Please refer to official Google Speech Command dataset page
target classes: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"] feature size : 196
python main.py --model_config config/kws/model_config.json --data_config config/kws/data_config.json
Use the same CNN example for MNIST by loading FERG images with grey scale and reduce dimensions to [1, 28, 28]
target classes:
- anger: 0
- disgust: 1
- fear: 2
- joy: 3
- neutral: 4
- sadness: 5
- surprise: 6
feature size : 196
python main.py --model_config config/ferg/model_config.json --data_config config/ferg/data_config.json