Skip to content
Snippets Groups Projects

MLPAlgorithm PAD algorithm V1 version

Merged Olegs NIKISINS requested to merge mlp_algorithm into master

Files

 
#!/usr/bin/env python2
 
# -*- coding: utf-8 -*-
 
"""
 
@author: Olegs Nikisins
 
"""
 
#==============================================================================
 
# Import here:
 
 
import torch
 
 
 
#==============================================================================
 
# Define parameters here:
 
 
"""
 
Transformations to be applied to the input 1D numpy arrays (feature vectors).
 
Only conversion to Tensor and unsqueezing is needed to match the input of
 
TwoLayerMLP network
 
"""
 
 
def transform(x):
 
"""
 
Convert input to Tensor and unsqueeze to match the input of
 
TwoLayerMLP network.
 
 
Arguments
 
---------
 
x : numpy array
 
1D numpy array / feature vector.
 
 
Return
 
------
 
x_transform : Tensor
 
Torch tensor, transformed ``x`` to be used as MLP input.
 
"""
 
 
return torch.Tensor(x).unsqueeze(0)
 
 
 
"""
 
Define the network to be trained as a class, named ``Network``.
 
Note: Do not change the name of the below class, always import as ``Network``.
 
"""
 
 
from bob.learn.pytorch.architectures import TwoLayerMLP as Network
 
 
 
"""
 
kwargs to be used for ``Network`` initialization. The name must be ``network_kwargs``.
 
"""
 
network_kwargs = {}
 
network_kwargs['in_features'] = 1296
 
network_kwargs['n_hidden_relu'] = 10
 
network_kwargs['apply_sigmoid'] = False # don't use sigmoid to make the scores more even
 
 
Loading