/NeuralFeatureExtractor

NeuralFeatureExtractor (NFE) enables feature extraction from trained PyTorch model

Primary LanguagePython

NeuralFeatureExtractor

NeuralFeatureExtractor (NFE) enables feature extraction from trained PyTorch model

Supported models & datasets

current version supports following models:

Details can be found below

Supported file types

  • csv

To support new file type, simply write a class that inherits FileHandler

How to extract features for new dataset using a new model

Step 1: Link PyTorch model

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

Step 2: Link DataLoader

Next, copy and paste your DataLoader to data_loader folder

Step 3: Generate config files

NFE requires two configurations

  • model_config : configuration for the Model
  • data_config : configuration for the DataLoader

Samples can be found from config folder

Step 4: Extract features

The following command generates features and stored them at generated/<model name>

python main.py --model_config <model_config> --data_config <data_config>

Supported feature extraction

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