add util tests

This commit is contained in:
Joerg Franke 2018-06-24 16:10:10 +02:00
parent 88308f70ac
commit cc6a25146a
4 changed files with 30 additions and 6 deletions

View File

@ -0,0 +1,24 @@
# Copyright 2018 Jörg Franke
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
from adnc.model.utils import EarlyStop
def test_early_stop():
test_seq = [1, 2, 1, 4, 2, 1, 3, 4, 5, 2, 7, 2, 3, 4, 5]
true_seq = [False, False, False, False, False, False, False, False, True, False, False, False, False, False, True]
e_stop = EarlyStop(4)
for test, true in zip(test_seq, true_seq):
assert true == e_stop(test)

View File

@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
import pytest
import numpy as np
import pytest
import tensorflow as tf
from adnc.utils.initialization import unit_simplex_initialization
from adnc.model.utils import unit_simplex_initialization
@pytest.fixture()

View File

@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
import pytest
import numpy as np
import pytest
import tensorflow as tf
from adnc.utils.normalization import layer_norm
from adnc.model.utils import layer_norm
@pytest.fixture()

View File

@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
import pytest
import numpy as np
import pytest
import tensorflow as tf
from adnc.utils.tf_functions import oneplus
from adnc.model.utils import oneplus
@pytest.fixture()