# The SVM baseline for BO4D
import shared_defs_BP4D
import shared_defs_SEMAINE
import shared_defs_DISFA

import data_preparation
import numpy

import mlp

pca_loc = "../pca_generation/generic_face_rigid"

(all_aus_bp4d, train_recs, devel_recs, BP4D_dir,
 hog_data_dir) = shared_defs_BP4D.shared_defs()

# load the training and testing data for the current fold
[train_samples_bp4d, train_labels_bp4d, valid_samples_bp4d, valid_labels_bp4d, _, PC, means, scaling] = \
    data_preparation.Prepare_HOG_AU_data_generic_BP4D_dynamic(train_recs, devel_recs, all_aus_bp4d, BP4D_dir, hog_data_dir, pca_loc, geometry=True)

(all_aus_semaine, train_recs, devel_recs, semaine_dir,
 hog_data_dir) = shared_defs_SEMAINE.shared_defs()

# load the training and testing data for the current fold
[train_samples_semaine, train_labels_semaine, valid_samples_semaine, valid_labels_semaine, _, PC, means, scaling] = \
    data_preparation.Prepare_HOG_AU_data_generic_SEMAINE_dynamic(train_recs, devel_recs, all_aus_semaine,
                                                         semaine_dir, hog_data_dir, pca_loc, geometry=True)

(all_aus_disfa, train_recs, disfa_dir,
 hog_data_dir) = shared_defs_DISFA.shared_defs()
devel_recs = train_recs[0:1]
[train_samples_disfa, train_labels_disfa, _, _, _, PC, means, scaling] = \
# The SVM baseline for BO4D
import shared_defs_BP4D
import data_preparation
import numpy

import mlp

(all_aus, train_recs, devel_recs, BP4D_dir, hog_data_dir) = shared_defs_BP4D.shared_defs()

pca_loc = "../pca_generation/generic_face_rigid"

f = open("./trained/BP4D_train_mlp_joint_scale.txt", 'w')

# load the training and testing data for the current fold
[train_samples, train_labels, valid_samples, valid_labels, raw_valid, PC, means, scaling] = \
    data_preparation.Prepare_HOG_AU_data_generic_BP4D(train_recs, devel_recs, all_aus, BP4D_dir, hog_data_dir, pca_loc,
                                                      scale=True)

import validation_helpers

train_fn = mlp.train_mlp_probe
test_fn = mlp.test_mlp

hyperparams = {
   'batch_size': [100],
   'learning_rate': [0.2],
   'lambda_reg': [0.0001],
   'num_hidden': [300],
   'n_epochs': 1000,
   'validate_params': ["batch_size", "learning_rate", "lambda_reg", 'num_hidden']}
Ejemplo n.º 3
0
# The MLP baseline for SEMAINE
import shared_defs_BP4D
import data_preparation
(all_aus, train_recs, devel_recs, BP4D_dir, hog_data_dir) = shared_defs_BP4D.shared_defs();

pca_loc = "../pca_generation/generic_face_rigid";

for au in all_aus:
               
    # load the training and testing data for the current fold
    [train_samples, train_labels, valid_samples, valid_labels, raw_valid, PC, means, scaling] = data_preparation.Prepare_HOG_AU_data_generic_BP4D(train_recs, devel_recs, [au], BP4D_dir, hog_data_dir, pca_loc);

    # Cross-validate here                
    #( best_params, _ ) = validate_grid_search(svm_train, svm_test, False, train_samples, train_labels, valid_samples, valid_labels, hyperparams);

    # model = svm_train(train_labels, train_samples, best_params);        

    # [prediction, a, actual_vals] = predict(valid_labels, valid_samples, model);

    # Go from raw data to the prediction
    #w = model.w(1:end-1)';
    #b = model.w(end);

    #svs = bsxfun(@times, PC, 1./scaling') * w;

    # Attempt own prediction
    #preds_mine = bsxfun(@plus, raw_valid, -means) * svs + b;

    # assert(norm(preds_mine - actual_vals) < 1e-8);#

    # name = sprintf('trained/AU_%d_static.dat', au);