Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.ip.pytorch_extractor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.ip.pytorch_extractor
Merge requests
!4
MLPAlgorithm PAD algorithm V1 version
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
MLPAlgorithm PAD algorithm V1 version
mlp_algorithm
into
master
Overview
16
Commits
9
Pipelines
8
Changes
6
Merged
Olegs NIKISINS
requested to merge
mlp_algorithm
into
master
6 years ago
Overview
11
Commits
9
Pipelines
8
Changes
6
Expand
This is an MLP based PAD algorithm.
Edited
6 years ago
by
Olegs NIKISINS
0
0
Merge request reports
Compare
master
version 7
c51586ca
6 years ago
version 6
150166c7
6 years ago
version 5
55016a19
6 years ago
version 4
306e2efe
6 years ago
version 3
dba77525
6 years ago
version 2
405c8e83
6 years ago
version 1
48d8a345
6 years ago
master (base)
and
version 4
latest version
c94e1d3a
9 commits,
6 years ago
version 7
c51586ca
8 commits,
6 years ago
version 6
150166c7
7 commits,
6 years ago
version 5
55016a19
6 commits,
6 years ago
version 4
306e2efe
5 commits,
6 years ago
version 3
dba77525
4 commits,
6 years ago
version 2
405c8e83
3 commits,
6 years ago
version 1
48d8a345
1 commit,
6 years ago
6 files
+
321
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
bob/ip/pytorch_extractor/test_data/mlp_algo_test_config.py
0 → 100644
+
73
−
0
Options
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
@author: Olegs Nikisins
"""
#==============================================================================
# Import here:
import
numpy
as
np
import
torch
#==============================================================================
# Define parameters here:
"""
Transformations to be applied to the input 1D numpy arrays (feature vectors).
Here, for demonstrative purposes, the transformation is mean std-normalization,
where mean and std values are just numpy generated vectors. In real applications,
normalizers must be computed in the meaningfull way. This config is just for
test purposes.
"""
def
transform
(
x
):
"""
Transformation function applying dummy mean-std normalization and converting
input numpy feature vectors to PyTorch tensors, making them compatible with
MLP.
Arguments
---------
x : numpy array
1D numpy array / feature vector.
Return
------
x_transform : Tensor
Torch tensor, transformed ``x`` to be used as MLP input.
"""
features_mean
=
np
.
zeros
(
x
.
shape
)
features_std
=
np
.
ones
(
x
.
shape
)
row_norm_list
=
[]
for
row
in
x
:
# row is a sample
row_norm
=
(
row
-
features_mean
)
/
features_std
row_norm_list
.
append
(
row_norm
)
x_norm
=
np
.
vstack
(
row_norm_list
)
x_norm
.
squeeze
()
return
torch
.
Tensor
(
x_norm
).
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
'
]
=
100
network_kwargs
[
'
n_hidden_relu
'
]
=
10
network_kwargs
[
'
apply_sigmoid
'
]
=
False
# don't use sigmoid to make the scores more even
Loading