This commit is contained in:
Mark Hillebrand 2016-12-19 13:49:05 +01:00
Родитель 62565efb17
Коммит 8f4cad8f40
44 изменённых файлов: 139 добавлений и 42 удалений

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import numpy as np
import sys
import os

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import os
import math
import numpy as np

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import os
import math
import argparse

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import numpy as np
import sys
import os

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import os
import argparse
import math

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import os
import argparse
import math

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import os
import math
from cntk.blocks import * # non-layer like building blocks such as LSTM()

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import numpy as np
import os
from cntk import Trainer, Axis

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import sys
import os
import csv

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

@ -40,7 +40,8 @@
# PYTHON_SUPPORT=true iff CNTK v2 Python module should be build
# SWIG_PATH= path to SWIG (>= 3.0.10)
# PYTHON_VERSIONS= list of Python versions to build for
# A Python version is identified by "34" or "35".
# A Python version is identified by "27", "34", or "35".
# PYTHON27_PATH= path to Python 2.7 interpreter
# PYTHON34_PATH= path to Python 3.4 interpreter
# PYTHON35_PATH= path to Python 3.5 interpreter
# These can be overridden on the command line, e.g. make BUILDTYPE=debug
@ -1207,6 +1208,7 @@ python: $(ALL_LIBS)
@bash -c '\
set -x -e; \
declare -A py_paths; \
py_paths[27]=$(PYTHON27_PATH); \
py_paths[34]=$(PYTHON34_PATH); \
py_paths[35]=$(PYTHON35_PATH); \
export LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$$(echo $(GDK_NVML_LIB_PATH) $(LIBPATH) $(KALDI_LIBPATH) | tr " " :); \

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

@ -0,0 +1,24 @@
name: cntk-py27
channels: !!python/tuple
- defaults
dependencies:
- enum34=1.1.6=py27_0
- jupyter=1.0.0=py27_3
- matplotlib=1.5.3=np111py27_0
- numpy=1.11.2=py27_0
- pandas=0.19.1=np111py27_0
- pillow=3.4.2=py27_0
- pip=8.1.2=py27_0
- python=2.7.11=5
- pyyaml=3.12=py27_0
- scipy=0.18.1=np111py27_0
- seaborn=0.7.1=py27_0
- setuptools=27.2.0=py27_0
- six=1.10.0=py27_0
- wheel=0.29.0=py27_0
- pip:
- pytest==3.0.3
- sphinx==1.4.8
- sphinx-rtd-theme==0.1.9
- twine==1.8.1
- gym==0.5.2

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

@ -0,0 +1,22 @@
name: cntk-py27
dependencies:
- enum34=1.1.6=py27_0
- jupyter=1.0.0=py27_3
- matplotlib=1.5.3=np111py27_0
- numpy=1.11.2=py27_0
- pandas=0.19.1=np111py27_0
- pillow=3.4.2=py27_0
- pip=8.1.2=py27_0
- python=2.7.11=5
- pyyaml=3.12=py27_0
- scipy=0.18.1=np111py27_0
- seaborn=0.7.1=py27_0
- setuptools=27.2.0=py27_1
- six=1.10.0=py27_0
- wheel=0.29.0=py27_0
- pip:
- pytest==3.0.3
- sphinx==1.4.8
- sphinx-rtd-theme==0.1.9
- twine==1.8.1
- gym==0.5.2

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

@ -0,0 +1,21 @@
name: cntk-py35
dependencies:
- jupyter=1.0.0=py35_3
- matplotlib=1.5.3=np111py35_0
- numpy=1.11.2=py35_0
- pandas=0.19.1=np111py35_0
- pillow=3.4.2=py35_0
- pip=8.1.2=py35_0
- python=3.5.2=0
- pyyaml=3.12=py35_0
- scipy=0.18.1=np111py35_0
- seaborn=0.7.1=py35_0
- setuptools=27.2.0=py35_1
- six=1.10.0=py35_0
- wheel=0.29.0=py35_0
- pip:
- pytest==3.0.3
- sphinx==1.4.8
- sphinx-rtd-theme==0.1.9
- twine==1.8.1
- gym==0.5.2

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

@ -28,6 +28,10 @@ def test_cifar_convnet_distributed_mpiexec(device_id):
cmd = ["mpiexec", "-n", "2", "python", os.path.join(abs_path, "run_cifar_convnet_distributed.py")]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
if sys.version_info[0] < 3:
# TODO add timeout for Py2?
out = p.communicate()[0]
else:
try:
out = p.communicate(timeout=TIMEOUT_SECONDS)[0] # in case we have a hang
except subprocess.TimeoutExpired:

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

@ -64,8 +64,9 @@ def nb(tmpdir_factory, request, device_id):
inPath = getattr(request.module, "notebook")
outPath = str(tmpdir_factory.mktemp('notebook').join('out.ipynb'))
assert os.path.isfile(inPath)
kernel_name_opt = "--ExecutePreprocessor.kernel_name=python%d" % (sys.version_info[0])
args = ["jupyter", "nbconvert", "--to", "notebook", "--execute",
"--ExecutePreprocessor.timeout=300", "--output", outPath, inPath]
"--ExecutePreprocessor.timeout=300", kernel_name_opt, "--output", outPath, inPath]
subprocess.check_call(args)
nb = nbformat.read(outPath, nbformat.current_nbformat)
return nb

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import print_function
import os, sys
import numpy as np
from cntk import DeviceDescriptor

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

@ -677,6 +677,8 @@ def runCommand(args):
convertPythonPath = lambda path: os.pathsep.join([cygpath(y) for y in path.split(',')])
pyPaths = {}
if args.py27_paths:
pyPaths['py27'] = convertPythonPath(args.py27_paths)
if args.py34_paths:
pyPaths['py34'] = convertPythonPath(args.py34_paths)
if args.py35_paths:
@ -784,6 +786,7 @@ if __name__ == "__main__":
runSubparser.add_argument("-d", "--device", help="cpu|gpu - run on a specified device")
runSubparser.add_argument("-f", "--flavor", help="release|debug - run only a specified flavor")
runSubparser.add_argument("-s", "--build-sku", default=defaultBuildSKU, help="cpu|gpu|1bitsgd - run tests only for a specified build SKU")
runSubparser.add_argument("--py27-paths", help="comma-separated paths to prepend when running a test against Python 2.7")
runSubparser.add_argument("--py34-paths", help="comma-separated paths to prepend when running a test against Python 3.4")
runSubparser.add_argument("--py35-paths", help="comma-separated paths to prepend when running a test against Python 3.5")
tmpDir = os.getenv("TEMP") if windows else "/tmp"

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

@ -173,6 +173,8 @@ cp -r $buildPath/* $baseBinariesPath
# General TODO: Implement White List of Binary Drop contents.
# For the time being "cherry pick" removal of unneeded files
#
# Remove Py 2.7 for the time being
rm -f $baseBinariesPath/python/cntk*27*27*.whl
rm -f $baseBinariesPath/bin/brainscripttests
rm -f $baseBinariesPath/bin/cppevalclient
rm -f $baseBinariesPath/bin/cppevalextendedclient

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

@ -80,16 +80,10 @@ Remove-Item $baseDropPath\cntk\*.lib -Exclude EvalDll.lib, CNTKLibrary-2.0.lib
Remove-Item $baseDropPath\cntk\*.exp
Remove-Item $baseDropPath\cntk\*.metagen
# Remove specific items
# Add Python artefacts to 2.0 Beta Drop
# If (Test-Path $baseDropPath\cntk\Python)
# {
# Remove-Item $baseDropPath\cntk\Python -Recurse
# }
# Add CNTKLibrary-2.0.dll to 2.0 Beta Drop
# If (Test-Path $baseDropPath\cntk\CNTKLibrary-2.0.dll)
# {
# Remove-Item $baseDropPath\cntk\CNTKLibrary-2.0.dll
# }
If (Test-Path $baseDropPath\cntk\Python\cntk-*-cp27*.whl
{
Remove-Item $baseDropPath\cntk\Python\cntk-*-cp27*.whl
}
If (Test-Path $baseDropPath\cntk\CPPEvalClientTest.exe)
{
Remove-Item $baseDropPath\cntk\CPPEvalClientTest.exe

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

@ -67,6 +67,7 @@
"outputs": [],
"source": [
"# Import the relevant components\n",
"from __future__ import print_function\n",
"import numpy as np\n",
"import sys\n",
"import os\n",

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

@ -59,6 +59,7 @@
"outputs": [],
"source": [
"# Import the relevant components\n",
"from __future__ import print_function\n",
"import numpy as np\n",
"import sys\n",
"import os\n",

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

@ -46,6 +46,7 @@
"outputs": [],
"source": [
"# Import the relevant components\n",
"from __future__ import print_function\n",
"import matplotlib.image as mpimg\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",

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

@ -24,6 +24,7 @@
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"import numpy as np\n",
"import cntk\n",
"import cntk.ops as C\n",

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

@ -164,6 +164,7 @@
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"import os\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",

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

@ -57,6 +57,7 @@
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"import requests\n",
"import os\n",
"\n",

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

@ -58,6 +58,7 @@
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib import style\n",
"import numpy as np\n",

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

@ -91,6 +91,7 @@
},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"import numpy as np\n",
"import os\n",
"from cntk import Trainer, Axis\n",

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

@ -9,6 +9,7 @@
# TODO: This has become too large. Need to break out some locally used stuff into another module.
# TODO: further clean up the dependencies
from __future__ import division
import numpy as np
from cntk import parameter, constant, input_variable, placeholder_variable, combine, alias
from cntk.ops import times, slice, sigmoid, tanh, log, exp, past_value, future_value

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

@ -8,6 +8,7 @@
# e.g. a fully connected layer with non-linearity
# TODO: clean up the dependencies
from __future__ import division
import numpy as np
from .ops import parameter, input_variable, placeholder_variable, combine
from .ops import times, convolution, pooling, batch_normalization, dropout

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

@ -46,8 +46,8 @@ def Sequential(layers):
# LayerStack(3, lambda i: Dense(3))
# LayerStack(3, lambda: Dense(3))
def LayerStack(N, constructor):
from inspect import signature
takes_arg = len(signature(constructor).parameters) > 0
from inspect import getargspec
takes_arg = len(getargspec(constructor).args) > 0
# helper to call the layer constructor
def call(i):
if takes_arg:

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

@ -4,6 +4,7 @@
# ==============================================================================
from __future__ import division
from __future__ import print_function
import numpy as np
from . import sequence
from .functions import CloneMethod, Function, load_model
@ -1502,8 +1503,8 @@ def optimized_rnnstack(operand, weights, hidden_size, num_layers,
>>> x = C.input_variable(shape=(4,))
>>> s = np.reshape(np.arange(20.0, dtype=np.float32), (5,4))
>>> f = C.optimized_rnnstack(x, W, 8, 2)
>>> f.eval({x:s}).shape
(1, 5, 8)
>>> print(*f.eval({x:s}).shape)
1 5 8
Returns:
:class:`~cntk.ops.functions.Function`

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

@ -507,8 +507,8 @@ class Function(cntk_py.Function):
>>> a = C.input_variable(shape=1, name='a')
>>> b = C.input_variable(shape=1, name='b')
>>> c = C.plus(a, b, name='c')
>>> c.find_by_name('b').name
'b'
>>> print(c.find_by_name('b').name)
b
>>> c.find_by_name('z') is None
True

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

@ -7,6 +7,7 @@
Unit tests for kernel operations, tested for the forward and the backward pass
"""
from __future__ import division
import numpy as np
import pytest
from .ops_test_utils import unittest_helper, _test_unary_op, AA, I, precision, PRECISION_TO_TYPE, constant

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

@ -8,6 +8,7 @@
Unit tests random sampling related operations
"""
from __future__ import division
import numpy as np
import pytest
from .ops_test_utils import AA, precision

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

@ -8,6 +8,7 @@
Unit tests for reduction operations, tested for the forward and the backward pass
"""
from __future__ import division
import numpy as np
import pytest
from .ops_test_utils import unittest_helper, _test_unary_op, AA, I, precision, PRECISION_TO_TYPE, constant

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

@ -3,7 +3,7 @@ from cntk import cntk_py, utils
from ..tensor import TensorOpsMixin
from ..utils import typemap, sanitize_precision, sanitize_value, sanitize_dtype_cntk, _create_NDArrayView_from_NumPy
class VariableMixin:
class VariableMixin(object):
'''
Standard properties for :class:`Variable` and its derived classes
:class:`Parameter` and :class:`Constant`.
@ -182,9 +182,9 @@ class Parameter(VariableMixin, TensorOpsMixin, cntk_py.Parameter):
def value(self, val):
if isinstance(val, np.ndarray):
ndarray = _create_NDArrayView_from_NumPy(val.astype(self.dtype))
super().set_value(ndarray)
super(Parameter, self).set_value(ndarray)
elif isinstance(val, cntk_py.NDArrayView):
super().set_value(val)
super(Parameter, self).set_value(val)
else:
raise TypeError("Unsupported value type: %s", type(val))

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

@ -159,7 +159,7 @@ def _add_tensor_ops(klass):
raise ValueError('class "%s" already has operator overload "%s"' %
(klass, overload_name))
setattr(klass, overload_name, getattr(TensorOpsMixin, overload_name))
setattr(klass, overload_name, TensorOpsMixin.__dict__[overload_name])
class ArrayMixin(object):

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

@ -4,6 +4,7 @@
# for full license information.
# ==============================================================================
from __future__ import division
import numpy as np
from ..learner import *
from .. import parameter, input_variable

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

@ -3,11 +3,12 @@
# Licensed under the MIT license. See LICENSE.md file in the project root
# for full license information.
# ==============================================================================
from __future__ import print_function
import time
import sys
# TODO: Let's switch to import logging in the future instead of print. [ebarsoum]
class ProgressPrinter:
class ProgressPrinter(object):
'''
Accumulates training time statistics (loss and metric)
and pretty prints them as training progresses.

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

@ -1,3 +1,4 @@
from __future__ import print_function
import numpy as np
import cntk as C
from cntk.learner import sgd, learning_rate_schedule, UnitType

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

@ -9,18 +9,13 @@ import numpy
IS_WINDOWS = platform.system() == 'Windows'
if IS_WINDOWS and sys.version_info.major < 3:
print("Detected Python v2 on Windows, which is not yet supported")
sys.exit(1)
# TODO should handle swig path specified via build_ext --swig-path
if os.system('swig -version 1>%s 2>%s' % (os.devnull, os.devnull)) != 0:
print("Please install swig (>= 3.0.10) and include it in your path.\n")
sys.exit(1)
if IS_WINDOWS:
if os.system('cl /? -version 1>%s 2>%s' % (os.devnull, os.devnull)) != 0:
if os.system('cl 1>%s 2>%s' % (os.devnull, os.devnull)) != 0:
print("Compiler was not found in path. Please run this from a Visual Studio 2013 x64 Native Tools Command Prompt,\n"
"e.g., by running the following command:\n"
" \"C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\vcvarsall\" amd64\n")

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

@ -31,9 +31,9 @@ if not defined p_CNTK_PY_VERSIONS (
)
REM Validate p_CNTK_PY_VERSIONS contents.
REM TODO Python 3.4 only for now
REM TODO no Python 3.5 for now
for %%p in (%p_CNTK_PY_VERSIONS%) do (
if not "%%~p" == "34" echo Build for unsupported Python version '%%~p' requested, stopping&exit /b 1
if not "%%~p" == "27" if not "%%~p" == "34" echo Build for unsupported Python version '%%~p' requested, stopping&exit /b 1
set nothingToBuild=
)

12
configure поставляемый
Просмотреть файл

@ -297,7 +297,7 @@ function find_python ()
function default_use_python ()
{
# Keeping it default "no" for a little while:
# if test x$(find_swig) = x || test x$(find_python 34)$(find_python 35) = x
# if test x$(find_swig) = x || test x$(find_python 27)$(find_python 34)$(find_python 35) = x
# then
echo no
# else
@ -343,7 +343,8 @@ function show_help ()
echo " --with-code-coverage[=(yes|no)] $(show_default ${default_use_code_coverage})"
echo " --with-boost[=directory] $(show_default $(find_boost))"
echo " --with-protobuf[=directory] $(show_default $(find_protobuf))"
echo " --with-py-versions=(space-separated list of 34, 35)"
echo " --with-py-versions=(space-separated list of 27, 34, 35)"
echo " --with-py27-path[=directory] $(show_default $(find_python 27))"
echo " --with-py34-path[=directory] $(show_default $(find_python 34))"
echo " --with-py35-path[=directory] $(show_default $(find_python 35))"
echo " --with-swig[=directory] $(show_default $(find_swig))"
@ -449,7 +450,7 @@ do
for ver in $optarg
do
case $ver in
34 | 35)
27 | 34 | 35)
;;
*)
echo "Invalid value for --with-py-versions $optarg: invalid version $ver"
@ -462,7 +463,7 @@ do
fi
;;
--with-py34-path*|--with-py35-path*)
--with-py27-path*|--with-py34-path*|--with-py35-path*)
enable_python=yes
py_version=${key:9:2}
if test x$optarg = x
@ -904,6 +905,7 @@ fi
if test $enable_python = yes
then
# Fill unfilled default paths
[ -z "${py_paths[27]}" ] && find_python 27 && py_paths[27]=$(find_python 27)
[ -z "${py_paths[34]}" ] && find_python 34 && py_paths[34]=$(find_python 34)
[ -z "${py_paths[35]}" ] && find_python 35 && py_paths[35]=$(find_python 35)
@ -912,7 +914,7 @@ then
py_versions="$py_versions "
# Make sure each requested version is configured, remove other parts
for ver in 34 35
for ver in 27 34 35
do
case $py_versions in
*$ver\ *)