Move models under layers and fix remaining UnitTests.

This commit is contained in:
Emad Barsoum 2017-03-07 18:10:08 -08:00
Родитель 868d834698
Коммит 324404a109
15 изменённых файлов: 192 добавлений и 48 удалений

Просмотреть файл

@ -55,6 +55,7 @@
<None Include="cntk\conftest.py" />
<None Include="cntk\core.py" />
<None Include="cntk\debugging\debug.py" />
<None Include="cntk\debugging\tests\__init__.py" />
<None Include="cntk\debugging\__init__.py" />
<None Include="cntk\device.py" />
<None Include="cntk\initializer.py" />
@ -66,7 +67,11 @@
<None Include="cntk\layers\blocks.py" />
<None Include="cntk\layers\higher_order_layers.py" />
<None Include="cntk\layers\layers.py" />
<None Include="cntk\layers\models\attention.py" />
<None Include="cntk\layers\models\__init__.py" />
<None Include="cntk\layers\sequence.py" />
<None Include="cntk\layers\tests\layers_test.py" />
<None Include="cntk\layers\tests\__init__.py" />
<None Include="cntk\layers\typing.py" />
<None Include="cntk\layers\__init__.py" />
<None Include="cntk\learners\tests\__init__.py" />
@ -74,6 +79,7 @@
<None Include="cntk\logging\graph.py" />
<None Include="cntk\logging\progress_print.py" />
<None Include="cntk\logging\tests\graph_test.py" />
<None Include="cntk\logging\tests\__init__.py" />
<None Include="cntk\logging\__init__.py" />
<None Include="cntk\losses\tests\__init__.py" />
<None Include="cntk\losses\__init__.py" />
@ -87,9 +93,11 @@
<None Include="cntk\pytest.ini" />
<None Include="cntk\sample_installer.py" />
<None Include="cntk\tensor.py" />
<None Include="cntk\tests\training_session_test.py" />
<None Include="cntk\tests\user_learner.py" />
<None Include="cntk\train\distributed.py" />
<None Include="cntk\train\tests\distributed_test.py" />
<None Include="cntk\train\tests\trainer_test.py" />
<None Include="cntk\train\tests\training_session_test.py" />
<None Include="cntk\train\tests\__init__.py" />
<None Include="cntk\train\trainer.py" />
<None Include="cntk\train\training_session.py" />
@ -118,14 +126,11 @@
<None Include="cntk\ops\tests\__init__.py" />
<None Include="cntk\tests\attributes_test.py" />
<None Include="cntk\tests\axis_test.py" />
<None Include="cntk\tests\distributed_test.py" />
<None Include="cntk\tests\initializer_test.py" />
<None Include="cntk\tests\layers_test.py" />
<None Include="cntk\tests\learner_test.py" />
<None Include="cntk\tests\persist_test.py" />
<None Include="cntk\tests\tensor_test.py" />
<None Include="cntk\tests\test_utils.py" />
<None Include="cntk\tests\trainer_test.py" />
<None Include="cntk\tests\__init__.py" />
<None Include="cntk\utils\__init__.py" />
<None Include="cntk\utils\tests\utils_test.py" />

Просмотреть файл

@ -73,6 +73,15 @@
<Filter Include="cntk\layers">
<UniqueIdentifier>{4358c7a8-d1e3-44a5-95e4-73b5f14df6ae}</UniqueIdentifier>
</Filter>
<Filter Include="cntk\layers\tests">
<UniqueIdentifier>{f2a13ca6-fd43-45a5-9e51-d3c85f6c2a4e}</UniqueIdentifier>
</Filter>
<Filter Include="cntk\layers\models">
<UniqueIdentifier>{5c4f70d4-147b-4bba-8ad9-861ec07ba3c5}</UniqueIdentifier>
</Filter>
<Filter Include="cntk\debugging\tests">
<UniqueIdentifier>{57d82204-6a94-4563-a561-160d9ded9961}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="cntk\__init__.py">
@ -152,9 +161,6 @@
<None Include="cntk\ops\tests\comparison_test.py">
<Filter>cntk\ops\tests</Filter>
</None>
<None Include="cntk\tests\distributed_test.py">
<Filter>cntk\tests</Filter>
</None>
<None Include="cntk\ops\tests\evaluation_test.py">
<Filter>cntk\ops\tests</Filter>
</None>
@ -170,9 +176,6 @@
<None Include="cntk\ops\tests\kernel_test.py">
<Filter>cntk\ops\tests</Filter>
</None>
<None Include="cntk\tests\layers_test.py">
<Filter>cntk\tests</Filter>
</None>
<None Include="cntk\tests\learner_test.py">
<Filter>cntk\tests</Filter>
</None>
@ -215,9 +218,6 @@
<None Include="cntk\tests\test_utils.py">
<Filter>cntk\tests</Filter>
</None>
<None Include="cntk\tests\trainer_test.py">
<Filter>cntk\tests</Filter>
</None>
<None Include="cntk\utils\tests\utils_test.py">
<Filter>cntk\utils\tests</Filter>
</None>
@ -239,9 +239,6 @@
<None Include="cntk\train\training_session.py">
<Filter>cntk\train</Filter>
</None>
<None Include="cntk\tests\training_session_test.py">
<Filter>cntk\tests</Filter>
</None>
<None Include="cntk\tests\user_learner.py">
<Filter>cntk\tests</Filter>
</None>
@ -320,5 +317,32 @@
<None Include="cntk\ops\tests\block_test.py">
<Filter>cntk\ops\tests</Filter>
</None>
<None Include="cntk\layers\tests\__init__.py">
<Filter>cntk\layers\tests</Filter>
</None>
<None Include="cntk\train\tests\distributed_test.py">
<Filter>cntk\train\tests</Filter>
</None>
<None Include="cntk\train\tests\trainer_test.py">
<Filter>cntk\train\tests</Filter>
</None>
<None Include="cntk\train\tests\training_session_test.py">
<Filter>cntk\train\tests</Filter>
</None>
<None Include="cntk\layers\tests\layers_test.py">
<Filter>cntk\layers\tests</Filter>
</None>
<None Include="cntk\layers\models\__init__.py">
<Filter>cntk\layers\models</Filter>
</None>
<None Include="cntk\layers\models\attention.py">
<Filter>cntk\layers\models</Filter>
</None>
<None Include="cntk\debugging\tests\__init__.py">
<Filter>cntk\debugging\tests</Filter>
</None>
<None Include="cntk\logging\tests\__init__.py">
<Filter>cntk\logging\tests</Filter>
</None>
</ItemGroup>
</Project>

Просмотреть файл

@ -34,6 +34,27 @@ if errorlevel 1 exit /b 1
echo(
popd
pushd cntk\io\tests
echo RUNNING cntk\io unit tests...
pytest --deviceid gpu
if errorlevel 1 exit /b 1
echo(
popd
pushd cntk\layers\tests
echo RUNNING cntk\layers unit tests...
pytest --deviceid gpu
if errorlevel 1 exit /b 1
echo(
popd
pushd cntk\logging\tests
echo RUNNING cntk\logging unit tests...
pytest --deviceid gpu
if errorlevel 1 exit /b 1
echo(
popd
pushd cntk\ops\tests
echo RUNNING cntk\ops unit tests...
pytest --deviceid gpu
@ -41,4 +62,18 @@ if errorlevel 1 exit /b 1
echo(
popd
pushd cntk\train\tests
echo RUNNING cntk\train unit tests...
pytest --deviceid gpu
if errorlevel 1 exit /b 1
echo(
popd
pushd cntk\utils\tests
echo RUNNING cntk\utils unit tests...
pytest --deviceid gpu
if errorlevel 1 exit /b 1
echo(
popd
endlocal

Просмотреть файл

@ -10,3 +10,5 @@ from .blocks import *
from .higher_order_layers import *
from .sequence import *
from .layers import *
from .models import *

Просмотреть файл

@ -0,0 +1,10 @@
# ==============================================================================
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE.md file in the project root
# for full license information.
# ==============================================================================
# CNTK models collection
# Layers and building blocks that are not generic but represent more specific model types go here.
from .attention import *

Просмотреть файл

@ -9,9 +9,9 @@ attention -- standard attention model
'''
from __future__ import division
from ..ops.functions import Function
from ..layers.blocks import _inject_name # helpers
from ..layers import *
from cntk.ops.functions import Function
from ..blocks import _inject_name # helpers
from .. import *
# AttentionModel block

Просмотреть файл

@ -0,0 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE.md file in the project root
# for full license information.
# ==============================================================================

Просмотреть файл

@ -4,7 +4,5 @@
# for full license information.
# ==============================================================================
# CNTK models collection
# Layers and building blocks that are not generic but represent more specific model types go here.
from .attention import *
# To __remove__
from cntk.layers.models.attention import *

Просмотреть файл

@ -948,7 +948,7 @@ class Function(cntk_py.Function):
See also:
:func:`find_by_name`
'''
from .. import graph
from cntk.logging import graph
return graph.find_all_with_name(self, name)
# TODO have a better name for combine() in this case

Просмотреть файл

@ -7,12 +7,13 @@
import math
import numpy as np
import pytest
from .. import Function
from ..train.trainer import *
from ..learners import *
from cntk import Function
from ..trainer import *
from cntk.learners import *
from .. import distributed
from .. import cross_entropy_with_softmax, classification_error, parameter, \
input_variable, times, plus, reduce_sum
from cntk.losses import cross_entropy_with_softmax
from cntk.metrics import classification_error
from cntk import parameter, input_variable, times, plus, reduce_sum
def create_data_parallel_distributed_learner(learner, quantized, distributed_after):
return distributed.data_parallel_distributed_learner(

Просмотреть файл

@ -8,14 +8,15 @@ import os
import math
import numpy as np
from cntk import Value
from .. import Function
from ..ops import times, sequence, as_block, element_select
from ..ops.tests.ops_test_utils import cntk_device
from ..train.trainer import *
from ..learners import *
from ..layers import *
from .. import cross_entropy_with_softmax, classification_error, parameter, \
input_variable, times, plus, reduce_sum, Axis, cntk_py
from cntk import Function
from cntk import times, sequence, as_block, element_select
from cntk.ops.tests.ops_test_utils import cntk_device
from ..trainer import *
from cntk.learners import *
from cntk.layers import *
from cntk.losses import cross_entropy_with_softmax
from cntk.metrics import classification_error
from cntk import parameter, input_variable, times, plus, reduce_sum, Axis, cntk_py
import pytest
from scipy.sparse import csr_matrix as csr

Просмотреть файл

@ -8,14 +8,15 @@ import os
import math
import re
import numpy as np
from .. import Function
from ..ops import times, sequence, as_block, element_select
from ..ops.tests.ops_test_utils import cntk_device
from ..train.trainer import *
from ..train.training_session import *
from ..learners import *
from .. import cross_entropy_with_softmax, classification_error, parameter, \
input_variable, times, plus, reduce_sum, Axis, cntk_py
from cntk import Function
from cntk import times, sequence, as_block, element_select
from cntk.ops.tests.ops_test_utils import cntk_device
from ..trainer import *
from ..training_session import *
from cntk.learners import *
from cntk.losses import cross_entropy_with_softmax
from cntk.metrics import classification_error
from cntk import parameter, input_variable, times, plus, reduce_sum, Axis, cntk_py
from cntk.io import MinibatchSource, CTFDeserializer, StreamDef, StreamDefs, FULL_DATA_SWEEP, INFINITELY_REPEAT
import pytest

Просмотреть файл

@ -13,6 +13,8 @@ from cntk.device import default
from cntk.tests.test_utils import precision, PRECISION_TO_TYPE
from cntk.ops import *
from cntk.utils import *
from cntk.internal import *
from cntk import Value
AA = np.asarray
@ -91,7 +93,7 @@ def test_sanitize_batch_sparse():
[True, False],
[[2, 1, 1], [1, 0, 0]]),
(one_hot([[3, 4, 5, 1], [60, 61]], num_classes=62),
(Value.one_hot([[3, 4, 5, 1], [60, 61]], num_classes=62),
[True, False],
ValueError),
])
@ -107,9 +109,9 @@ def test_mask(batch, seq_starts, expected):
def test_one_hot():
with pytest.raises(ValueError):
s = one_hot([[1.0, 2.0], [3.]], 4)
s = Value.one_hot([[1.0, 2.0], [3.]], 4)
with pytest.raises(ValueError):
s = one_hot([1, 2], 4)
s = Value.one_hot([1, 2], 4)
def test_sanitize_batch_contiguity():
a1 = AA([[1,2],[3,4]])

Просмотреть файл

@ -11,12 +11,72 @@ pytest --deviceid gpu
echo(
popd
pushd cntk\debugging\tests
echo RUNNING cntk\debugging unit tests...
pytest
echo(
popd
pushd cntk\internal\tests
echo RUNNING cntk\internal unit tests...
pytest
echo(
popd
pushd cntk\io\tests
echo RUNNING cntk\io unit tests...
pytest
echo(
popd
pushd cntk\layers\tests
echo RUNNING cntk\layers unit tests...
pytest
echo(
popd
pushd cntk\learners\tests
echo RUNNING cntk\learners unit tests...
pytest
echo(
popd
pushd cntk\logging\tests
echo RUNNING cntk\logging unit tests...
pytest
echo(
popd
pushd cntk\losses\tests
echo RUNNING cntk\losses unit tests...
pytest
echo(
popd
pushd cntk\metrics\tests
echo RUNNING cntk\metrics unit tests...
pytest
echo(
popd
pushd cntk\ops\tests
echo RUNNING cntk\ops unit tests...
pytest
echo(
popd
pushd cntk\train\tests
echo RUNNING cntk\train unit tests...
pytest
echo(
popd
pushd cntk\utils\tests
echo RUNNING cntk\utils unit tests...
pytest
echo(
popd
pushd ..\..\Tests\EndToEndTests\CNTKv2Python\Examples
echo RUNNING cntk\Tests\EndToEndTests\CNTKv2Python\Examples tests
pytest