diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f0da24d54dd183d0a4d40667ea0a9619b94f1e6e..9f1ba73f5a3b3fada8624dfd89fa6f12488a877b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/test/test_model_modules/test_inception_model.py b/test/test_model_modules/test_inception_model.py index ae227184eb575b8192ffc008413e327d0aca4ba1..f9d30ea7740cbb0f07497e9898ae3d4f449216ac 100644 --- a/test/test_model_modules/test_inception_model.py +++ b/test/test_model_modules/test_inception_model.py @@ -1,7 +1,9 @@ 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)