Skip to content
Snippets Groups Projects
Commit a9495978 authored by Olegs NIKISINS's avatar Olegs NIKISINS
Browse files

Temporal replacement of algo with SVM

parent dc285953
No related branches found
No related tags found
1 merge request!85WIP: Config for complete PAD experiment
This commit is part of merge request !85. Comments created here will be created in the context of that merge request.
......@@ -80,35 +80,55 @@ auto-encoder.
#=======================================================================================
# define algorithm:
from bob.pad.face.algorithm import CustomFunc
import torch.nn.functional as F
CONFIG_FILE = "autoencoder/face_features_net_128x128/batl/batl_mlp_algorithm_celeba_and_partial_3_layers_batl_features/batl_mlp_10_relu_algorithm.py"
CONFIG_GROUP = "bob.pad.face.config.pytorch"
MODEL_FILE = "/idiap/temp/onikisins/project/ODIN/experiment_data/pad_experiments_bob4/batl_db/autoencoder_face_features_128x128/batl_train_mlp_10_relu_algo_celeba_and_partial_3_layers_batl_features/experiment_8/model_17.pth"
INVERT_SCORES_FLAG = True
def _prediction_function(local_model, x):
x = x.squeeze()
x = local_model.fc1(x)
x = F.relu(x)
# second fully connected NO sigmoid:
x = local_model.fc2(x)
return x
KWARGS = {}
KWARGS["config_file"] = CONFIG_FILE
KWARGS["config_group"] = CONFIG_GROUP
KWARGS["model_file"] = MODEL_FILE
KWARGS["invert_scores_flag"] = INVERT_SCORES_FLAG
KWARGS["prediction_function"] = _prediction_function
FUNCTION_NAME = "net_forward"
algorithm = CustomFunc(function_name = FUNCTION_NAME,
frame_level_scores_flag = True,
kwargs = KWARGS)
from bob.pad.base.algorithm import SVM
MACHINE_TYPE = 'C_SVC'
KERNEL_TYPE = 'RBF'
N_SAMPLES = 10000
TRAINER_GRID_SEARCH_PARAMS = {
'cost': [2**P for P in range(-3, 14, 2)],
'gamma': [2**P for P in range(-15, 0, 2)]
}
MEAN_STD_NORM_FLAG = True # enable mean-std normalization
FRAME_LEVEL_SCORES_FLAG = True # one score per frame(!) in this case
algorithm = SVM(
machine_type=MACHINE_TYPE,
kernel_type=KERNEL_TYPE,
n_samples=N_SAMPLES,
trainer_grid_search_params=TRAINER_GRID_SEARCH_PARAMS,
mean_std_norm_flag=MEAN_STD_NORM_FLAG,
frame_level_scores_flag=FRAME_LEVEL_SCORES_FLAG)
#from bob.pad.face.algorithm import CustomFunc
#import torch.nn.functional as F
#
#
#CONFIG_FILE = "autoencoder/face_features_net_128x128/batl/batl_mlp_algorithm_celeba_and_partial_3_layers_batl_features/batl_mlp_10_relu_algorithm.py"
#CONFIG_GROUP = "bob.pad.face.config.pytorch"
#MODEL_FILE = "/idiap/temp/onikisins/project/ODIN/experiment_data/pad_experiments_bob4/batl_db/autoencoder_face_features_128x128/batl_train_mlp_10_relu_algo_celeba_and_partial_3_layers_batl_features/experiment_8/model_17.pth"
#INVERT_SCORES_FLAG = True
#
#def _prediction_function(local_model, x):
# x = x.squeeze()
# x = local_model.fc1(x)
# x = F.relu(x)
# # second fully connected NO sigmoid:
# x = local_model.fc2(x)
# return x
#
#KWARGS = {}
#KWARGS["config_file"] = CONFIG_FILE
#KWARGS["config_group"] = CONFIG_GROUP
#KWARGS["model_file"] = MODEL_FILE
#KWARGS["invert_scores_flag"] = INVERT_SCORES_FLAG
#KWARGS["prediction_function"] = _prediction_function
#
#FUNCTION_NAME = "net_forward"
#
#algorithm = CustomFunc(function_name = FUNCTION_NAME,
# frame_level_scores_flag = True,
# kwargs = KWARGS)
"""
In this case, score is predicted by a pre-trained MLP, **excluding** output sigmoid.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment