Skip to content
Snippets Groups Projects
Commit 2845132d authored by lukas leufen's avatar lukas leufen
Browse files

update tests for keras namings

/close #65

See merge request toar/machinelearningtools!55
parents 033555f1 a3e4a957
No related branches found
No related tags found
2 merge requests!59Develop,!55update tests for keras namings
Pipeline #31239 passed
......@@ -32,7 +32,7 @@ tests:
- django
stage: test
variables:
FAILURE_THRESHOLD: 90
FAILURE_THRESHOLD: 100
before_script:
- chmod +x ./CI/update_badge.sh
- ./CI/update_badge.sh > /dev/null
......
import keras
import pytest
import re
from src.model_modules.inception_model import InceptionModelBase
from src.helpers import PyTestRegex
class TestInceptionModelBase:
......@@ -144,16 +146,17 @@ class TestInceptionModelBase:
concatenated = block._keras_history[0].input
assert len(concatenated) == 4
block_1a, block_1b, block_pool1, block_pool2 = concatenated
assert block_1a.name == 'Block_1a_act_2/Relu:0' # <- sometimes keras changes given name (I don't know why yet)
assert block_1b.name == 'Block_1b_act_2_tanh/Tanh:0'
assert block_pool1.name == 'Block_1c_act_1/Relu:0'
assert block_pool2.name == 'Block_1d_act_1/Relu:0'
# keras_name_part_split
assert block_1a.name == PyTestRegex(r'Block_1a_act_2(_\d*)?/Relu:0')
assert block_1b.name == PyTestRegex(r'Block_1b_act_2_tanh(_\d*)?/Tanh:0')
assert block_pool1.name == PyTestRegex(r'Block_1c_act_1(_\d*)?/Relu:0')
assert block_pool2.name == PyTestRegex(r'Block_1d_act_1(_\d*)?/Relu:0')
assert self.step_in(block_1a._keras_history[0]).name == "Block_1a_3x3"
assert self.step_in(block_1b._keras_history[0]).name == "Block_1b_5x5"
assert isinstance(self.step_in(block_pool1._keras_history[0], depth=2), keras.layers.pooling.MaxPooling2D)
assert isinstance(self.step_in(block_pool2._keras_history[0], depth=2), keras.layers.pooling.AveragePooling2D)
# check naming of concat layer
assert block.name == 'Block_1_Co/concat:0'
assert block.name == PyTestRegex('Block_1_Co(_\d*)?/concat:0')
assert block._keras_history[0].name == 'Block_1_Co'
assert isinstance(block._keras_history[0], keras.layers.merge.Concatenate)
# next block
......@@ -164,14 +167,14 @@ class TestInceptionModelBase:
concatenated = block._keras_history[0].input
assert len(concatenated) == 3
block_2a, block_2b, block_pool = concatenated
assert block_2a.name == 'Block_2a_act_2/Relu:0'
assert block_2b.name == 'Block_2b_act_2_tanh/Tanh:0'
assert block_pool.name == 'Block_2c_act_1/Relu:0'
assert block_2a.name == PyTestRegex(r'Block_2a_act_2(_\d*)?/Relu:0')
assert block_2b.name == PyTestRegex(r'Block_2b_act_2_tanh(_\d*)?/Tanh:0')
assert block_pool.name == PyTestRegex(r'Block_2c_act_1(_\d*)?/Relu:0')
assert self.step_in(block_2a._keras_history[0]).name == "Block_2a_3x3"
assert self.step_in(block_2b._keras_history[0]).name == "Block_2b_5x5"
assert isinstance(self.step_in(block_pool._keras_history[0], depth=2), keras.layers.pooling.MaxPooling2D)
# check naming of concat layer
assert block.name == 'Block_2_Co/concat:0'
assert block.name == PyTestRegex(r'Block_2_Co(_\d*)?/concat:0')
assert block._keras_history[0].name == 'Block_2_Co'
assert isinstance(block._keras_history[0], keras.layers.merge.Concatenate)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment