Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
esde
machine-learning
MLAir
Commits
a8274c1b
Commit
a8274c1b
authored
3 years ago
by
Falco Weichselbaum
Browse files
Options
Downloads
Patches
Plain Diff
changed assertions to be compatible with new tf2 outputs
parent
0a92109c
No related branches found
No related tags found
4 merge requests
!413
update release branch
,
!412
Resolve "release v2.0.0"
,
!349
trying a new requirements.txt list that was generated using pipreqs (an...
,
!335
Resolve "upgrade code to TensorFlow V2"
Pipeline
#82037
failed
3 years ago
Stage: test
Stage: docs
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_model_modules/test_flatten_tail.py
+22
-14
22 additions, 14 deletions
test/test_model_modules/test_flatten_tail.py
with
22 additions
and
14 deletions
test/test_model_modules/test_flatten_tail.py
+
22
−
14
View file @
a8274c1b
import
tensorflow
import
tensorflow.keras
as
keras
import
pytest
from
mlair.model_modules.flatten
import
flatten_tail
,
get_activation
from
tensorflow.python.keras.layers.advanced_activations
import
ELU
,
ReLU
class
TestGetActivation
:
...
...
@@ -18,10 +19,13 @@ class TestGetActivation:
def
test_sting_act_unknown
(
self
,
model_input
):
with
pytest
.
raises
(
ValueError
)
as
einfo
:
get_activation
(
model_input
,
activation
=
'
invalid_activation
'
,
name
=
'
String
'
)
assert
'
Unknown activation function:invalid_activation
'
in
str
(
einfo
.
value
)
assert
'
Unknown activation function: invalid_activation.
'
\
'
Please ensure this object is passed to the `custom_objects` argument.
'
\
'
See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object
'
\
'
for details.
'
in
str
(
einfo
.
value
)
def
test_layer_act
(
self
,
model_input
):
x_in
=
get_activation
(
model_input
,
activation
=
keras
.
layers
.
advanced_activations
.
ELU
,
name
=
'
adv_layer
'
)
x_in
=
get_activation
(
model_input
,
activation
=
ELU
,
name
=
'
adv_layer
'
)
act
=
x_in
.
_keras_history
[
0
]
assert
act
.
name
==
'
adv_layer
'
...
...
@@ -44,7 +48,7 @@ class TestFlattenTail:
return
element
def
test_flatten_tail_no_bound_no_regul_no_drop
(
self
,
model_input
):
tail
=
flatten_tail
(
input_x
=
model_input
,
inner_neurons
=
64
,
activation
=
keras
.
layers
.
advanced_activations
.
ELU
,
tail
=
flatten_tail
(
input_x
=
model_input
,
inner_neurons
=
64
,
activation
=
ELU
,
output_neurons
=
2
,
output_activation
=
'
linear
'
,
reduction_filter
=
None
,
name
=
'
Main_tail
'
,
...
...
@@ -67,10 +71,10 @@ class TestFlattenTail:
flatten
=
self
.
step_in
(
inner_dense
)
assert
flatten
.
name
==
'
Main_tail
'
input_layer
=
self
.
step_in
(
flatten
)
assert
input_layer
.
input_shape
==
(
None
,
7
,
1
,
2
)
assert
input_layer
.
input_shape
==
[
(
None
,
7
,
1
,
2
)
]
def
test_flatten_tail_all_settings
(
self
,
model_input
):
tail
=
flatten_tail
(
input_x
=
model_input
,
inner_neurons
=
64
,
activation
=
keras
.
layers
.
advanced_activations
.
ELU
,
tail
=
flatten_tail
(
input_x
=
model_input
,
inner_neurons
=
64
,
activation
=
ELU
,
output_neurons
=
3
,
output_activation
=
'
linear
'
,
reduction_filter
=
32
,
name
=
'
Main_tail_all
'
,
...
...
@@ -84,36 +88,40 @@ class TestFlattenTail:
final_dense
=
self
.
step_in
(
final_act
)
assert
final_dense
.
name
==
'
Main_tail_all_out_Dense
'
assert
final_dense
.
units
==
3
assert
isinstance
(
final_dense
.
kernel_regularizer
,
keras
.
regularizers
.
L1
L2
)
assert
isinstance
(
final_dense
.
kernel_regularizer
,
keras
.
regularizers
.
L2
)
final_dropout
=
self
.
step_in
(
final_dense
)
assert
final_dropout
.
name
==
'
Main_tail_all_Dropout_2
'
assert
final_dropout
.
rate
==
0.35
inner_act
=
self
.
step_in
(
final_dropout
)
assert
inner_act
.
get_config
()
==
{
'
name
'
:
'
activation_1
'
,
'
trainable
'
:
True
,
'
activation
'
:
'
tanh
'
}
assert
inner_act
.
get_config
()
==
{
'
name
'
:
'
activation
'
,
'
trainable
'
:
True
,
'
dtype
'
:
'
float32
'
,
'
activation
'
:
'
tanh
'
}
inner_dense
=
self
.
step_in
(
inner_act
)
assert
inner_dense
.
units
==
64
assert
isinstance
(
inner_dense
.
kernel_regularizer
,
keras
.
regularizers
.
L1
L2
)
assert
isinstance
(
inner_dense
.
kernel_regularizer
,
keras
.
regularizers
.
L2
)
inner_dropout
=
self
.
step_in
(
inner_dense
)
assert
inner_dropout
.
get_config
()
==
{
'
name
'
:
'
Main_tail_all_Dropout_1
'
,
'
trainable
'
:
True
,
'
rate
'
:
0.35
,
assert
inner_dropout
.
get_config
()
==
{
'
name
'
:
'
Main_tail_all_Dropout_1
'
,
'
trainable
'
:
True
,
'
dtype
'
:
'
float32
'
,
'
rate
'
:
0.35
,
'
noise_shape
'
:
None
,
'
seed
'
:
None
}
flatten
=
self
.
step_in
(
inner_dropout
)
assert
flatten
.
get_config
()
==
{
'
name
'
:
'
Main_tail_all
'
,
'
trainable
'
:
True
,
'
data_format
'
:
'
channels_last
'
}
assert
flatten
.
get_config
()
==
{
'
name
'
:
'
Main_tail_all
'
,
'
trainable
'
:
True
,
'
dtype
'
:
'
float32
'
,
'
data_format
'
:
'
channels_last
'
}
reduc_act
=
self
.
step_in
(
flatten
)
assert
reduc_act
.
get_config
()
==
{
'
name
'
:
'
Main_tail_all_conv_act
'
,
'
trainable
'
:
True
,
'
alpha
'
:
1.0
}
assert
reduc_act
.
get_config
()
==
{
'
name
'
:
'
Main_tail_all_conv_act
'
,
'
trainable
'
:
True
,
'
dtype
'
:
'
float32
'
,
'
alpha
'
:
1.0
}
reduc_conv
=
self
.
step_in
(
reduc_act
)
assert
reduc_conv
.
kernel_size
==
(
1
,
1
)
assert
reduc_conv
.
name
==
'
Main_tail_all_Conv_1x1
'
assert
reduc_conv
.
filters
==
32
assert
isinstance
(
reduc_conv
.
kernel_regularizer
,
keras
.
regularizers
.
L1
L2
)
assert
isinstance
(
reduc_conv
.
kernel_regularizer
,
keras
.
regularizers
.
L2
)
input_layer
=
self
.
step_in
(
reduc_conv
)
assert
input_layer
.
input_shape
==
(
None
,
7
,
1
,
2
)
assert
input_layer
.
input_shape
==
[
(
None
,
7
,
1
,
2
)
]
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