Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.pytorch
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.pytorch
Commits
482bfddb
Commit
482bfddb
authored
6 years ago
by
Olegs NIKISINS
Browse files
Options
Downloads
Patches
Plain Diff
Added a unit test for the TwoLayerMLP class
parent
8881e90f
No related branches found
No related tags found
1 merge request
!14
MLP class and config to train it
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/pytorch/test/test.py
+23
-3
23 additions, 3 deletions
bob/learn/pytorch/test/test.py
with
23 additions
and
3 deletions
bob/learn/pytorch/test/test.py
+
23
−
3
View file @
482bfddb
...
@@ -41,7 +41,7 @@ def test_architectures():
...
@@ -41,7 +41,7 @@ def test_architectures():
output
,
emdedding
=
net
.
forward
(
t
)
output
,
emdedding
=
net
.
forward
(
t
)
assert
output
.
shape
==
torch
.
Size
([
1
,
79077
])
assert
output
.
shape
==
torch
.
Size
([
1
,
79077
])
assert
emdedding
.
shape
==
torch
.
Size
([
1
,
256
])
assert
emdedding
.
shape
==
torch
.
Size
([
1
,
256
])
# LightCNN29
# LightCNN29
a
=
numpy
.
random
.
rand
(
1
,
1
,
128
,
128
).
astype
(
"
float32
"
)
a
=
numpy
.
random
.
rand
(
1
,
1
,
128
,
128
).
astype
(
"
float32
"
)
t
=
torch
.
from_numpy
(
a
)
t
=
torch
.
from_numpy
(
a
)
...
@@ -119,7 +119,7 @@ def test_transforms():
...
@@ -119,7 +119,7 @@ def test_transforms():
tt
=
ToTensor
()
tt
=
ToTensor
()
tt
(
sample
)
tt
(
sample
)
assert
isinstance
(
sample
[
'
image
'
],
torch
.
Tensor
)
assert
isinstance
(
sample
[
'
image
'
],
torch
.
Tensor
)
# grayscale
# grayscale
image_gray
=
numpy
.
random
.
rand
(
128
,
128
).
astype
(
"
uint8
"
)
image_gray
=
numpy
.
random
.
rand
(
128
,
128
).
astype
(
"
uint8
"
)
sample_gray
=
{
'
image
'
:
image_gray
}
sample_gray
=
{
'
image
'
:
image_gray
}
tt
(
sample_gray
)
tt
(
sample_gray
)
...
@@ -253,7 +253,7 @@ def test_conv_autoencoder():
...
@@ -253,7 +253,7 @@ def test_conv_autoencoder():
Test the ConvAutoencoder class.
Test the ConvAutoencoder class.
"""
"""
from
bob.learn.pytorch.architectures
import
ConvAutoencoder
from
bob.learn.pytorch.architectures
import
ConvAutoencoder
batch
=
torch
.
randn
(
1
,
3
,
64
,
64
)
batch
=
torch
.
randn
(
1
,
3
,
64
,
64
)
model
=
ConvAutoencoder
()
model
=
ConvAutoencoder
()
output
=
model
(
batch
)
output
=
model
(
batch
)
...
@@ -290,3 +290,23 @@ def test_extractors():
...
@@ -290,3 +290,23 @@ def test_extractors():
output
=
extractor
(
data
)
output
=
extractor
(
data
)
assert
output
.
shape
[
0
]
==
256
assert
output
.
shape
[
0
]
==
256
def
test_two_layer_mlp
():
"""
Test the TwoLayerMLP class.
"""
from
bob.learn.pytorch.architectures
import
TwoLayerMLP
batch
=
torch
.
randn
(
10
,
1
,
100
)
model
=
TwoLayerMLP
(
in_features
=
100
,
n_hidden_relu
=
10
,
apply_sigmoid
=
True
)
output
=
model
(
batch
)
assert
list
(
output
.
shape
)
==
[
10
,
1
]
model
.
apply_sigmoid
=
False
output
=
model
(
batch
)
assert
list
(
output
.
shape
)
==
[
10
,
1
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment