This commit is contained in:
Frank Seide 2016-08-24 08:05:13 -07:00
Родитель 835985bda2 e27af11d9b
Коммит 9d6345b2fa
45 изменённых файлов: 2270 добавлений и 505423 удалений

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

@ -29,6 +29,9 @@
<HasOpenCv>false</HasOpenCv>
<HasOpenCv Condition="Exists('$(OPENCV_PATH)') Or Exists('$(OPENCV_PATH_V31)')">true</HasOpenCv>
<HasBoost>false</HasBoost>
<HasBoost Condition="Exists('$(BOOST_INCLUDE_PATH)') And Exists('$(BOOST_LIB_PATH)')">true</HasBoost>
<UseZip>false</UseZip>
<UseZip Condition="Exists('$(ZLIB_PATH)')">true</UseZip>

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

@ -713,6 +713,9 @@ endif
########################################
ifdef OPENCV_PATH
ifdef BOOST_PATH
INCLUDEPATH += $(BOOST_PATH)/include
IMAGE_READER_LIBS += -lopencv_core -lopencv_imgproc -lopencv_imgcodecs
@ -743,6 +746,7 @@ $(IMAGEREADER): $(IMAGEREADER_OBJ) | $(CNTKMATH_LIB)
@echo $(SEPARATOR)
$(CXX) $(LDFLAGS) -shared $(patsubst %,-L%, $(LIBDIR) $(LIBPATH)) $(patsubst %,$(RPATH)%, $(ORIGINDIR) $(LIBPATH)) -o $@ $^ -l$(CNTKMATH) $(IMAGE_READER_LIBS)
endif
endif
########################################
# 1bit SGD setup
@ -841,7 +845,6 @@ UNITTEST_READER_SRC = \
$(SOURCEDIR)/../Tests/UnitTests/ReaderTests/HTKLMFReaderTests.cpp \
$(SOURCEDIR)/../Tests/UnitTests/ReaderTests/ImageReaderTests.cpp \
$(SOURCEDIR)/../Tests/UnitTests/ReaderTests/ReaderLibTests.cpp \
$(SOURCEDIR)/../Tests/UnitTests/ReaderTests/UCIFastReaderTests.cpp \
$(SOURCEDIR)/../Tests/UnitTests/ReaderTests/stdafx.cpp \
$(SOURCEDIR)/Readers/CNTKTextFormatReader/Indexer.cpp \
$(SOURCEDIR)/Readers/CNTKTextFormatReader/TextParser.cpp \

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

@ -311,10 +311,10 @@ public:
wstring key;
if (!labels.empty()) // empty means unsupervised mode (don't load any)
{
#ifdef _MSC_VER
#ifdef _WIN32
key = regex_replace((wstring) ppath, wregex(L"\\.[^\\.\\\\/:]*$"), wstring()); // delete extension (or not if none)
#else
key = removeExtension(basename(ppath));
key = removeExtension(ppath);
#endif
if (labels.find(key) == labels.end())
{
@ -630,9 +630,8 @@ public:
{
#ifdef _WIN32
key = regex_replace((wstring) ppath, wregex(L"\\.[^\\.\\\\/:]*$"), wstring()); // delete extension (or not if none)
#endif
#ifdef __unix__
key = removeExtension(basename(ppath));
#else
key = removeExtension(ppath);
#endif
if (labels[0].find(key) == labels[0].end())
{

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

@ -74,7 +74,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)Source\Common\Include;$(SolutionDir)Source\Math;$(OpenCvInclude);$(ZipInclude);$(SolutionDir)Source\Readers\ReaderLib</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)Source\Common\Include;$(SolutionDir)Source\Math;$(OpenCvInclude);$(ZipInclude);$(SolutionDir)Source\Readers\ReaderLib;$(BOOST_INCLUDE_PATH)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(OutDir);$(OpenCvLibPath);$(ZipLibPath)</AdditionalLibraryDirectories>
@ -127,10 +127,11 @@
<ClCompile Include="ZipByteReader.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Target Name="Build" Condition="$(HasOpenCv)" Outputs="$(TargetPath)" DependsOnTargets="$(BuildDependsOn)" />
<Target Name="Build" Condition="$(HasOpenCv) And $(HasBoost)" Outputs="$(TargetPath)" DependsOnTargets="$(BuildDependsOn)" />
<ImportGroup Label="ExtensionTargets" />
<Target Name="CheckDependencies">
<Warning Condition="!$(HasBoost)" Text="ImageReader requires the Boost library to build. Please see https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-Windows#boost for installation instructions." />
<Warning Condition="!$(HasOpenCv)" Text="ImageReader requires the OpenCV library to build. Please see https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-Windows#opencv for installation instructions." />
<Warning Condition="!$(UseZip)" Text="zlib and libzip libraries were not found, ImageReader will be built without zip container support. Please see https://github.com/Microsoft/CNTK/wiki/Setup-CNTK-on-Windows#libzip for installation instructions." />
</Target>
</Project>
</Project>

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

@ -7,6 +7,8 @@
#include <algorithm>
#include <unordered_map>
#include <random>
#include <boost/random/bernoulli_distribution.hpp>
#include <boost/random/normal_distribution.hpp>
#include "ImageTransformers.h"
#include "Config.h"
#include "ConcStack.h"
@ -156,7 +158,7 @@ void CropTransformer::Apply(size_t id, cv::Mat &mat)
int viewIndex = m_cropType == CropType::MultiView10 ? (int)(id % 10) : 0;
mat = mat(GetCropRect(m_cropType, viewIndex, mat.rows, mat.cols, ratio, *rng));
if ((m_hFlip && std::bernoulli_distribution()(*rng)) ||
if ((m_hFlip && boost::random::bernoulli_distribution<>()(*rng)) ||
viewIndex >= 5)
{
cv::flip(mat, mat, 1);
@ -208,7 +210,7 @@ cv::Rect CropTransformer::GetCropRect(CropType type, int viewIndex, int crow, in
double factor = 1.0 + UniRealT(-m_curAspectRatioRadius, m_curAspectRatioRadius)(rng);
double area = cropSize * cropSize;
double newArea = area * factor;
if (std::bernoulli_distribution()(rng))
if (boost::random::bernoulli_distribution<>()(rng))
{
cropSizeX = (int)std::sqrt(newArea);
cropSizeY = (int)(area / cropSizeX);
@ -533,7 +535,7 @@ void IntensityTransformer::Apply(cv::Mat &mat)
auto rng = m_rngs.pop_or_create([seed]() { return std::make_unique<std::mt19937>(seed); } );
// Using single precision as EigVal and EigVec matrices are single precision.
std::normal_distribution<float> d(0, (float)m_curStdDev);
boost::random::normal_distribution<float> d(0, (float)m_curStdDev);
cv::Mat alphas(1, 3, CV_32FC1);
assert(m_eigVal.rows == 1 && m_eigVec.cols == 3);
alphas.at<float>(0) = d(*rng) * m_eigVal.at<float>(0);

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

@ -13,6 +13,8 @@
#include "ConcStack.h"
#include "Config.h"
#include "ImageConfigHelper.h"
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/random/uniform_real_distribution.hpp>
namespace Microsoft { namespace MSR { namespace CNTK {
@ -41,8 +43,8 @@ protected:
}
using Base = Transformer;
using UniRealT = std::uniform_real_distribution<double>;
using UniIntT = std::uniform_int_distribution<int>;
using UniRealT = boost::random::uniform_real_distribution<double>;
using UniIntT = boost::random::uniform_int_distribution<int>;
// The only function that should be redefined by the inherited classes.
virtual void Apply(size_t id, cv::Mat &from) = 0;

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

@ -25,11 +25,7 @@
<ProjectName>BrainScriptTests</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(SolutionDir)\CNTK.Cpp.props" />
<PropertyGroup>
<HasBoost>false</HasBoost>
<HasBoost Condition="Exists('$(BOOST_INCLUDE_PATH)') And Exists('$(BOOST_LIB_PATH)')">true</HasBoost>
</PropertyGroup>
<Import Project="$(SolutionDir)\CNTK.Cpp.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>

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

@ -40,19 +40,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Choose>
<When Condition="Exists('$(BOOST_INCLUDE_PATH)') And Exists('$(BOOST_LIB_PATH)')">
<PropertyGroup>
<HasBoost>true</HasBoost>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<HasBoost>false</HasBoost>
</PropertyGroup>
</Otherwise>
</Choose>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Condition="$(GpuBuild)" Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA $(CudaVersion).props" />

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

@ -7,6 +7,7 @@
#include <array>
#include <random>
#include <numeric>
#include <boost/random/normal_distribution.hpp>
#include "../../../Source/Math/Matrix.h"
#include "../../../Source/Math/CPUMatrix.h"
#include "../../../Source/Math/GPUMatrix.h"
@ -76,7 +77,7 @@ BOOST_AUTO_TEST_SUITE(BatchNormalizationSuite)
BOOST_AUTO_TEST_CASE(BatchNormalizationForward)
{
std::mt19937 rng(0);
std::normal_distribution<float> nd;
boost::random::normal_distribution<float> nd;
auto initMat = [&](SingleMatrix& buf, size_t r, size_t c, vec& data) -> SingleMatrix
{
@ -202,96 +203,10 @@ BOOST_AUTO_TEST_CASE(BatchNormalizationForward)
}
}
//
//BOOST_AUTO_TEST_CASE(BatchNormalizationForwardInferenceCpu)
//{
// if (!IsCuDnnSupported())
// return;
//
// std::mt19937 rng(0);
// std::normal_distribution<float> nd;
//
// auto initMat = [&](SingleMatrix& buf, size_t r, size_t c, vec& data) -> SingleMatrix
// {
// data.resize(r * 3 * c);
// std::fill(begin(data), end(data), std::numeric_limits<float>::quiet_NaN());
// std::generate(begin(data) + r * c, begin(data) + 2 * r * c, [&] { return nd(rng); });
// buf.SetValue(r, 3 * c, buf.GetDeviceId(), data.data());
// // Get center slice.
// return buf.ColumnSlice(c, c);
// };
//
// int deviceId = -1;
// int cudnnDeviceId = deviceId < 0 ? 0 : deviceId;
// auto fact = ConvFact::Create(cudnnDeviceId, ConvFact::EngineType::CuDnn, ImageLayoutKind::CHW);
// auto engCudnn = fact->CreateConvEngine(cudnnDeviceId, ImageLayoutKind::CHW, 0, BatchNormImpl::CuDnn);
// auto testFact = ConvFact::Create(deviceId, ConvFact::EngineType::Auto, ImageLayoutKind::CHW);
// auto engCntk = testFact->CreateConvEngine(deviceId, ImageLayoutKind::CHW, 0, BatchNormImpl::Cntk);
// for (auto& cfg : GenerateBNTestConfigs(*fact))
// {
// auto& t = *std::move(std::get<0>(cfg));
// bool spatial = std::get<1>(cfg);
//
// size_t crow = t.w() * t.h() * t.c();
// size_t ccol = t.n();
//
// vec buf(crow * t.n());
// std::generate(begin(buf), end(buf), [&] { return nd(rng); });
// SingleMatrix in(crow, ccol, buf.data(), deviceId, matrixFlagNormal);
// SingleMatrix inExp(crow, ccol, buf.data(), cudnnDeviceId, matrixFlagNormal);
//
// Tensor4DPtr scaleBiasT = spatial ? fact->CreateTensor(1, 1, t.c(), 1) : fact->CreateTensor(t.w(), t.h(), t.c(), 1);
// size_t crowScaleBias = scaleBiasT->w() * scaleBiasT->h() * scaleBiasT->c();
// buf.resize(crowScaleBias);
//
// std::generate(begin(buf), end(buf), [&] { return nd(rng); });
// SingleMatrix scale(crowScaleBias, 1, buf.data(), deviceId, matrixFlagNormal);
// SingleMatrix scaleExp(crowScaleBias, 1, buf.data(), cudnnDeviceId, matrixFlagNormal);
// std::generate(begin(buf), end(buf), [&] { return nd(rng); });
// SingleMatrix bias(crowScaleBias, 1, buf.data(), deviceId, matrixFlagNormal);
// SingleMatrix biasExp(crowScaleBias, 1, buf.data(), cudnnDeviceId, matrixFlagNormal);
//
// std::generate(begin(buf), end(buf), [&] { return nd(rng); });
// SingleMatrix runMean(crowScaleBias, 1, buf.data(), deviceId, matrixFlagNormal);
// SingleMatrix runMeanExp(crowScaleBias, 1, buf.data(), cudnnDeviceId, matrixFlagNormal);
// std::generate(begin(buf), end(buf), [&] { return nd(rng); });
// SingleMatrix runInvStdDev(crowScaleBias, 1, buf.data(), deviceId, matrixFlagNormal);
// SingleMatrix runInvStdDevExp(crowScaleBias, 1, buf.data(), cudnnDeviceId, matrixFlagNormal);
//
// SingleMatrix outBuf(deviceId);
// SingleMatrix out = initMat(outBuf, crow, ccol, buf);
// SingleMatrix outExp(crow, ccol, out.CopyToArray(), cudnnDeviceId, matrixFlagNormal);
//
// CudaTimer time1;
// time1.Start();
// engCntk->NormalizeBatchInference(t, in, *scaleBiasT, scale, bias, spatial, runMean, runInvStdDev, out);
// time1.Stop();
//
// CudaTimer time2;
// time2.Start();
// engCudnn->NormalizeBatchInference(t, inExp, *scaleBiasT, scaleExp, biasExp, spatial, runMeanExp, runInvStdDevExp, outExp);
// time2.Stop();
//
// std::stringstream tmsg;
// tmsg << "tensor: (w = " << t.w() << ", h = " << t.h() << ", c = " << t.c() << ", n = " << t.n() << ", spatial = " << (spatial ? "true" : "false") << ")";
// std::string msg = " are not equal, " + tmsg.str();
// std::string msgNan = " has NaNs, " + tmsg.str();
// std::string msgNotNan = " has buffer overflow/underflow, " + tmsg.str();
//
// float relErr = Err<float>::Rel;
// float absErr = Err<float>::Abs;
// std::string emsg;
//
// BOOST_REQUIRE_MESSAGE(!out.HasNan("out"), "out" << msgNan);
// BOOST_REQUIRE_MESSAGE(CheckEqual(out, outExp, emsg, relErr, absErr * 20), "out" << msg << ". " << emsg);
// BOOST_REQUIRE_MESSAGE(CountNans(outBuf) == crow * 2 * ccol, "out" << msgNotNan);
// }
//}
BOOST_AUTO_TEST_CASE(BatchNormalizationBackward)
{
std::mt19937 rng(0);
std::normal_distribution<float> nd;
boost::random::normal_distribution<float> nd;
auto initMat = [&](SingleMatrix& buf, size_t r, size_t c, vec& data) -> SingleMatrix
{
@ -381,11 +296,13 @@ BOOST_AUTO_TEST_CASE(BatchNormalizationBackward)
// REVIEW alexeyk: add cases for testing numerical stability.
BOOST_REQUIRE_MESSAGE(!dScale.HasNan("dScale"), "dScale" << msgNan);
BOOST_REQUIRE_MESSAGE(CheckEqual(dScale, dScaleB, emsg, relErr * 32, absErr * 16), "dScale" << msg << ". " << emsg);
// After using boost norm_distribution, we have to adapt the tolerance value. But we get the same result on Windows and Linux.
// When using std norm_distribution, different tolerance values are needed for Windows than for Linux.
BOOST_REQUIRE_MESSAGE(CheckEqual(dScale, dScaleB, emsg, relErr * 88, absErr * 16), "dScale" << msg << ". " << emsg);
BOOST_REQUIRE_MESSAGE(CountNans(dScaleBuf) == crowScaleBias * 2, "dScale" << msgNotNan);
BOOST_REQUIRE_MESSAGE(!dBias.HasNan("dBias"), "dBias" << msgNan);
BOOST_REQUIRE_MESSAGE(CheckEqual(dBias, dBiasB, emsg, relErr * 32, absErr * 16), "dBias" << msg << ". " << emsg);
BOOST_REQUIRE_MESSAGE(CheckEqual(dBias, dBiasB, emsg, relErr * 50, absErr * 16), "dBias" << msg << ". " << emsg);
BOOST_REQUIRE_MESSAGE(CountNans(dBiasBuf) == crowScaleBias * 2, "dBias" << msgNotNan);
#if 0

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

@ -7,6 +7,8 @@
#include <array>
#include <random>
#include <numeric>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include "../../../Source/Math/Matrix.h"
#include "../../../Source/Math/CPUMatrix.h"
#include "../../../Source/Math/GPUMatrix.h"
@ -165,8 +167,8 @@ BOOST_AUTO_TEST_SUITE(ConvolutionSuite)
BOOST_AUTO_TEST_CASE(ConvolutionForward)
{
std::mt19937 rng(0);
std::uniform_int_distribution<> batchSizeG(1, 8);
std::normal_distribution<float> nd;
boost::random::uniform_int_distribution<> batchSizeG(1, 8);
boost::random::normal_distribution<float> nd;
auto initMat = [&](SingleMatrix& buf, size_t r, size_t c, vec& data) -> SingleMatrix
{
@ -224,7 +226,7 @@ BOOST_AUTO_TEST_CASE(ConvolutionForward)
std::string emsg;
BOOST_REQUIRE_MESSAGE(!out.HasNan("out"), "out" << msgNan);
BOOST_REQUIRE_MESSAGE(CheckEqual(out, outB, emsg, relErr * 4, absErr * 9), "out" << msg << ". " << emsg);
BOOST_REQUIRE_MESSAGE(CheckEqual(out, outB, emsg, relErr * 4, absErr * 10), "out" << msg << ". " << emsg);
BOOST_REQUIRE_MESSAGE(CountNans(outBuf) == crowOut * 2 * n, "out" << msgNotNan);
}
}
@ -233,8 +235,8 @@ BOOST_AUTO_TEST_CASE(ConvolutionForward)
BOOST_AUTO_TEST_CASE(ConvolutionBackwardData)
{
std::mt19937 rng(0);
std::uniform_int_distribution<> batchSizeG(1, 8);
std::normal_distribution<float> nd;
boost::random::uniform_int_distribution<> batchSizeG(1, 8);
boost::random::normal_distribution<float> nd;
auto initMat = [&](SingleMatrix& buf, size_t r, size_t c, vec& data) -> SingleMatrix
{
@ -301,8 +303,8 @@ BOOST_AUTO_TEST_CASE(ConvolutionBackwardData)
BOOST_AUTO_TEST_CASE(ConvolutionBackwardKernel)
{
std::mt19937 rng(0);
std::uniform_int_distribution<> batchSizeG(1, 8);
std::normal_distribution<float> nd;
boost::random::uniform_int_distribution<> batchSizeG(1, 8);
boost::random::normal_distribution<float> nd;
auto initMat = [&](SingleMatrix& buf, size_t r, size_t c, vec& data) -> SingleMatrix
{
@ -361,7 +363,8 @@ BOOST_AUTO_TEST_CASE(ConvolutionBackwardKernel)
std::string emsg;
BOOST_REQUIRE_MESSAGE(!kernel.HasNan("kernel"), "kernel" << msgNan);
BOOST_REQUIRE_MESSAGE(CheckEqual(kernel, kernelB, emsg, relErr * 32, absErr * 32), "kernel" << msg << ". " << emsg);
// Todo: check the threashold value after we have setttings regard determinstics in place.
BOOST_REQUIRE_MESSAGE(CheckEqual(kernel, kernelB, emsg, relErr * 192, absErr * 32), "kernel" << msg << ". " << emsg);
BOOST_REQUIRE_MESSAGE(CountNans(kernelBuf) == kernel.GetNumElements() * 2, "kernel" << msgNotNan);
}
}
@ -370,8 +373,8 @@ BOOST_AUTO_TEST_CASE(ConvolutionBackwardKernel)
BOOST_AUTO_TEST_CASE(PoolingForward)
{
std::mt19937 rng(0);
std::uniform_int_distribution<> batchSizeG(1, 8);
std::normal_distribution<float> nd;
boost::random::uniform_int_distribution<> batchSizeG(1, 8);
boost::random::normal_distribution<float> nd;
auto initMat = [&](SingleMatrix& buf, size_t r, size_t c, vec& data) -> SingleMatrix
{
@ -430,8 +433,8 @@ BOOST_AUTO_TEST_CASE(PoolingForward)
BOOST_AUTO_TEST_CASE(PoolingBackward)
{
std::mt19937 rng(0);
std::uniform_int_distribution<> batchSizeG(1, 8);
std::normal_distribution<float> nd;
boost::random::uniform_int_distribution<> batchSizeG(1, 8);
boost::random::normal_distribution<float> nd;
auto initMat = [&](SingleMatrix& buf, size_t r, size_t c, vec& data) -> SingleMatrix
{
@ -504,7 +507,7 @@ BOOST_AUTO_TEST_CASE(MaxUnpooling)
using IntMatrix = Matrix<int>;
std::mt19937 rng(0);
std::uniform_int_distribution<> batchSizeG(1, 8);
boost::random::uniform_int_distribution<> batchSizeG(1, 8);
// Using uniform distribution with positive values to avoid issues with
// unpooling negative values.
std::uniform_real_distribution<float> nd(0, 1);

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

@ -10,6 +10,7 @@
#include <crtdefs.h>
#endif
#include "../../../Source/Math/GPUSparseMatrix.h"
#include "common.h"
using namespace Microsoft::MSR::CNTK;
@ -51,14 +52,15 @@ BOOST_FIXTURE_TEST_CASE(GPUSparseMatrixConstructorsAndInitializers, RandomSeedFi
BOOST_FIXTURE_TEST_CASE(GPUSparseMatrixScaleAndAdd, RandomSeedFixture)
{
const int m = 4;
const int n = 5;
const int n = 5;
float a[m * n];
float b[m * n];
std::mt19937 rng(0);
for (int i = 0; i < m * n; i++)
{
a[i] = static_cast<float>(rand());
b[i] = static_cast<float>(rand());
a[i] = static_cast<float>(rng());
b[i] = static_cast<float>(rng());
}
const GPUMatrix<float> denseMatrixA(m, n, c_deviceIdZero, a, MatrixFlags::matrixFlagNormal);
@ -79,8 +81,12 @@ BOOST_FIXTURE_TEST_CASE(GPUSparseMatrixScaleAndAdd, RandomSeedFixture)
const GPUMatrix<float> denseMatrixC = sparseMatrixC.CopyToDenseMatrix();
unique_ptr<float[]> c(denseMatrixC.CopyToArray());
for (int i = 0; i < m * n; i++)
{
BOOST_CHECK_EQUAL(alpha * (alpha * a[i] + beta * b[i]), c[i]);
{
float res1 = alpha * (alpha * a[i] + beta * b[i]);
float res2 = c[i];
BOOST_REQUIRE_MESSAGE(AreEqual(res1, res2, Err<float>::Rel, Err<float>::Abs),
"first mismatch at " << i << ", " << res1 << "!=" << res2 << ", relErr=" << (std::abs(res1 - res2) / std::max(std::abs(res1), \
std::abs(res2))) << ", absErr = " << std::abs(res1 - res2));
}
}

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

@ -39,19 +39,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Choose>
<When Condition="Exists('$(BOOST_INCLUDE_PATH)') And Exists('$(BOOST_LIB_PATH)')">
<PropertyGroup>
<HasBoost>true</HasBoost>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<HasBoost>false</HasBoost>
</PropertyGroup>
</Otherwise>
</Choose>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Condition="$(GpuBuild)" Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA $(CudaVersion).props" />

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

@ -121,7 +121,8 @@ BOOST_FIXTURE_TEST_CASE(MatrixMultiplyAndPlusAndMinus, RandomSeedFixture)
BOOST_FIXTURE_TEST_CASE(MatrixScaleAndAdd, RandomSeedFixture)
{
const int seed = rand();
std::mt19937 rng(0);
const int seed = rng();
const SingleMatrix singleMatrixA = SingleMatrix::RandomUniform(1024, 512, c_deviceIdZero , - 12.34f, 55.2312f, seed + 0);
const SingleMatrix singleMatrixB = SingleMatrix::RandomUniform(1024, 512, c_deviceIdZero, -12.34f, 55.2312f, seed + 1);
SingleMatrix singleMatrixC(singleMatrixB.DeepClone());
@ -161,7 +162,8 @@ BOOST_FIXTURE_TEST_CASE(MatrixScaleAndAdd, RandomSeedFixture)
BOOST_FIXTURE_TEST_CASE(MatrixScaleAndAdd_double, RandomSeedFixture)
{
const int seed = rand();
std::mt19937 rng(0);
const int seed = rng();
DoubleMatrix matrixA = DoubleMatrix::RandomUniform(1024, 512, c_deviceIdZero, -12.34, 55.2312, seed + 0);
DoubleMatrix matrixB = DoubleMatrix::RandomUniform(1024, 512, c_deviceIdZero, -12.34, 55.2312, seed + 1);
DoubleMatrix matrixC(matrixB.DeepClone());

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

@ -5,6 +5,7 @@
// Tests for sparse and dense matrix interaction should go here
//
#include "stdafx.h"
#include <random>
#include "../../../Source/Math/Matrix.h"
using namespace Microsoft::MSR::CNTK;
@ -191,6 +192,7 @@ BOOST_FIXTURE_TEST_CASE(MatrixSparseTimesSparse, RandomSeedFixture)
BOOST_FIXTURE_TEST_CASE(MatrixSparsePlusSparse, RandomSeedFixture)
{
std::mt19937 rng(0);
Matrix<float> mAdense(c_deviceIdZero);
mAdense.AssignTruncateBottomOf(Matrix<float>::RandomUniform(dim1, dim2, c_deviceIdZero, -3.0f, 0.1f, IncrementCounter()), 0);
Matrix<float> mAsparse(mAdense.DeepClone());
@ -199,7 +201,7 @@ BOOST_FIXTURE_TEST_CASE(MatrixSparsePlusSparse, RandomSeedFixture)
mBdense.AssignTruncateBottomOf(Matrix<float>::RandomUniform(dim1, dim2, c_deviceIdZero, -5.0f, 0.4f, IncrementCounter()), 0);
Matrix<float> mBsparse(mBdense.DeepClone());
float alpha = 1.0f * rand() / RAND_MAX;
float alpha = 1.0f * rng() / rng.max();
Matrix<float>::ScaleAndAdd(alpha, mAdense, mBdense);
mAsparse.SwitchToMatrixType(MatrixType::SPARSE, matrixFormatSparseCSR, true);
@ -212,6 +214,7 @@ BOOST_FIXTURE_TEST_CASE(MatrixSparsePlusSparse, RandomSeedFixture)
BOOST_FIXTURE_TEST_CASE(MatrixDensePlusSparse, RandomSeedFixture)
{
std::mt19937 rng(0);
Matrix<float> mAdense(c_deviceIdZero);
mAdense.AssignTruncateBottomOf(Matrix<float>::RandomUniform(dim1, dim2, c_deviceIdZero, -3.0f, 0.1f, IncrementCounter()), 0);
@ -219,7 +222,7 @@ BOOST_FIXTURE_TEST_CASE(MatrixDensePlusSparse, RandomSeedFixture)
mBdense.AssignTruncateBottomOf(Matrix<float>::RandomUniform(dim1, dim2, c_deviceIdZero, -5.0f, 0.4f, IncrementCounter()), 0);
Matrix<float> mBsparse(mBdense.DeepClone());
float alpha = 1.0f * rand() / RAND_MAX;
float alpha = 1.0f * rng() / rng.max();
Matrix<float>::ScaleAndAdd(alpha, mAdense, mBdense);
mBsparse.SwitchToMatrixType(MatrixType::SPARSE, matrixFormatSparseCSR, true);
@ -231,6 +234,7 @@ BOOST_FIXTURE_TEST_CASE(MatrixDensePlusSparse, RandomSeedFixture)
BOOST_FIXTURE_TEST_CASE(MatrixSparsePlusDense, RandomSeedFixture)
{
std::mt19937 rng(0);
Matrix<float> mAdense(c_deviceIdZero);
mAdense.AssignTruncateBottomOf(Matrix<float>::RandomUniform(dim1, dim2, c_deviceIdZero, -3.0f, 0.1f, IncrementCounter()), 0);
Matrix<float> mAsparse(mAdense.DeepClone());
@ -239,7 +243,7 @@ BOOST_FIXTURE_TEST_CASE(MatrixSparsePlusDense, RandomSeedFixture)
mBdense.AssignTruncateBottomOf(Matrix<float>::RandomUniform(dim1, dim2, c_deviceIdZero, -5.0f, 0.4f, IncrementCounter()), 0);
Matrix<float> Bd1(mBdense.DeepClone());
float alpha = 1.0f * rand() / RAND_MAX;
float alpha = 1.0f * rng() / rng.max();
Matrix<float>::ScaleAndAdd(alpha, mAdense, mBdense);
mAsparse.SwitchToMatrixType(MatrixType::SPARSE, matrixFormatSparseCSR, true);

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

@ -5,14 +5,15 @@
#pragma once
#include "Matrix.h"
#include "CPUMatrix.h"
#include "TensorView.h"
#include "Sequences.h"
#include <chrono>
#include <iostream>
#include <vector>
#include <algorithm>
#include <boost/random/uniform_real_distribution.hpp>
#include "Matrix.h"
#include "CPUMatrix.h"
#include "TensorView.h"
#include "Sequences.h"
namespace Microsoft { namespace MSR { namespace CNTK { namespace Test {
@ -49,8 +50,8 @@ struct TensorTest
cout << " \t// " << (deviceId < 0 ? "C" : "G") << "PU\n " << flush;
// random init
mt19937 rng(randomSeed);
uniform_real_distribution<float> nd(-1, 1);
std::mt19937 rng(randomSeed);
boost::random::uniform_real_distribution<float> nd(-1, 1);
vector<ElemType> init(numElements);
generate(begin(init), end(init), [&] { return nd(rng); });

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

@ -25,11 +25,7 @@
<ProjectName>NetworkTests</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(SolutionDir)\CNTK.Cpp.props" />
<PropertyGroup>
<HasBoost>false</HasBoost>
<HasBoost Condition="Exists('$(BOOST_INCLUDE_PATH)') And Exists('$(BOOST_LIB_PATH)')">true</HasBoost>
</PropertyGroup>
<Import Project="$(SolutionDir)\CNTK.Cpp.props" />
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>

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

@ -5,13 +5,14 @@
#pragma once
#include <boost/test/unit_test.hpp>
#include "boost/filesystem.hpp"
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include "DataReader.h"
using namespace Microsoft::MSR::CNTK;
namespace Microsoft { namespace MSR { namespace CNTK { namespace Test {
const double relError = 1e-5f;
struct ReaderFixture
{
// This fixture sets up paths so the tests can assume the right location for finding the configuration
@ -113,7 +114,7 @@ struct ReaderFixture
string m_initialWorkingPath;
string m_testDataPath;
string m_parentPath;
string initialPath()
{
return m_initialWorkingPath;
@ -164,22 +165,34 @@ struct ReaderFixture
}
// Helper function to compare files and verify that they are equivalent content-wise
// (identical character content ignoring differences in white spaces).
// if allowTolerace is false, character based comparison ignoring differences in white spaces.
// if allowTolerance is true, the content is treated as a sequence of double, and tolerance is allowed when comparing content.
void CheckFilesEquivalent(
string filename1,
string filename2)
string filename2,
bool allowTolerance = false)
{
std::ifstream ifstream1(filename1);
std::ifstream ifstream2(filename2);
std::istream_iterator<string> beginStream1(ifstream1), endStream1;
std::istream_iterator<string> beginStream2(ifstream2), endStream2;
std::istream_iterator<string> beginStream1(ifstream1), endStream1, it1;
std::istream_iterator<string> beginStream2(ifstream2), endStream2, it2;
BOOST_CHECK_EQUAL_COLLECTIONS(beginStream1, endStream1, beginStream2, endStream2);
if (allowTolerance)
{
for (it1 = beginStream1, it2 = beginStream2; it1 != endStream1 && it2 != endStream2; it1++, it2++)
{
BOOST_REQUIRE_CLOSE_FRACTION(boost::lexical_cast<double>(*it1), boost::lexical_cast<double>(*it2), relError);
}
BOOST_REQUIRE_MESSAGE(it1 == endStream1 && it2 == endStream2, "Different number of elements in file " << filename1 << " and " << filename2);
}
else
{
BOOST_REQUIRE_EQUAL_COLLECTIONS(beginStream1, endStream1, beginStream2, endStream2);
}
}
// Helper function to write the Reader's content to a file.
// testDataFilePath : the file path for writing the minibatch data (used for comparing against control data)
// dataReader : the DataReader to get minibatches from
@ -392,6 +405,7 @@ struct ReaderFixture
// sparseFeatures : indicates whether the corresponding matrix type should be set to sparse or not
// sparseLabels : same as above, but for labels
// useSharedLayout : if false, an individual layout is created for each input
// allowTolerance : if true, a predefined tolerance is allowed when comparing results
template <class ElemType>
void HelperRunReaderTest(
@ -409,14 +423,16 @@ struct ReaderFixture
size_t numSubsets,
bool sparseFeatures = false,
bool sparseLabels = false,
bool useSharedLayout = true,
std::vector<std::wstring> additionalConfigParameters = {})
bool useSharedLayout = true,
std::vector<std::wstring> additionalConfigParameters = {},
bool allowTolerance = false)
{
HelperReadInAndWriteOut<ElemType>(configFileName, testDataFilePath, testSectionName, readerSectionName,
epochSize, mbSize, epochs, numFeatureFiles, numLabelFiles, subsetNum,numSubsets,
sparseFeatures, sparseLabels, useSharedLayout, additionalConfigParameters);
CheckFilesEquivalent(controlDataFilePath, testDataFilePath);
CheckFilesEquivalent(controlDataFilePath, testDataFilePath, allowTolerance);
}
// Helper function to run a Reader test and catch an expected exception.

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

@ -8,8 +8,9 @@ precision = "double"
Simple_Test = [
reader = [
useMersenneTwisterRand = true
readerType = "HTKMLFReader"
readMethod = "rollingWindow"
readMethod = "blockRandomize"
miniBatchMode = "full"
randomize = "auto"
verbosity = 0

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

@ -1,32 +0,0 @@
RootDir = .
DataDir = $RootDir$
# deviceId = -1 for CPU, >= 0 for GPU devices
deviceId = -1
precision = "double"
Simple_Test = [
reader = [
readerType = "HTKMLFReader"
readMethod = "rollingWindow"
miniBatchMode = "full"
randomize = "auto"
verbosity = 0
frameMode = true
truncated = true
features = [
dim = 363
type = "real"
scpFile = "$DataDir$/glob_0000.scp"
]
labels = [
mlfFile = "$DataDir$/glob_0000.mlf"
labelMappingFile = "$DataDir$/state.list"
labelDim = 132
labelType = "category"
]
]
]

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

@ -1,32 +0,0 @@
RootDir = .
DataDir = $RootDir$
# deviceId = -1 for CPU, >= 0 for GPU devices
deviceId = -1
precision = "float"
Simple_Test = [
reader = [
readerType = "HTKMLFReader"
readMethod = "rollingWindow"
miniBatchMode = "full"
randomize = "auto"
verbosity = 0
frameMode = true
truncated = false
features = [
dim = 363
type = "real"
scpFile = "$DataDir$/glob_0000.scp"
]
labels=[
mlfFile = "$DataDir$/glob_0000.mlf"
labelMappingFile = "$DataDir$/state.list"
labelDim = 132
labelType = "category"
]
]
]

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

@ -8,8 +8,9 @@ precision = "float"
Simple_Test = [
reader = [
useMersenneTwisterRand = true
readerType = "HTKMLFReader"
readMethod = "rollingWindow"
readMethod = "blockRandomize"
miniBatchMode = "full"
randomize = "auto"
verbosity = 0

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

@ -1,42 +0,0 @@
RootDir = .
ModelDir = "models"
command = "Simple_Test"
precision = "float"
modelPath = "$ModelDir$/UCIFastReaderSimpleDataLoop_Model.dnn"
# deviceId = -1 for CPU, >= 0 for GPU devices
deviceId = -1
outputNodeNames = "ScaledLogLikelihood"
traceLevel = 1
#######################################
# CONFIG (Simple, Fixed LR) #
#######################################
Simple_Test = [
# Parameter values for the reader
reader = [
# reader to use
readerType = "UCIFastReader"
file = "$RootDir$/UCIFastReaderSimpleDataLoop_Train.txt"
miniBatchMode = "partial"
randomize = "auto"
verbosity = 1
features = [
dim = 2 # two-dimensional input data
start = 0 # Start with first element on line
]
labels = [
start = 2 # Skip two elements
dim = 1 # One label dimension
labelDim = 2 # Two labels possible
labelMappingFile = "$RootDir$/UCIFastReaderSimpleDataLoop_Mapping.txt"
]
]
]

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,2 +1,2 @@
255 0 0 0 255 255 128 0 0 255 255 0 0 0 255 255 255 0 0 255 0 255 128 0 255 0 255 0 0 255 0 255 255 0 255 0 0 255 128 255 0 0 255 0 255 0 0 255
254.982 0 0 0 254.982 254.982 127.982 0 0 254.982 254.982 0 0 0 254.982 254.982 254.985 0 0 254.985 0 254.985 127.985 0 254.985 0 254.985 0 0 254.985 0 254.985 254.989 0 254.989 0 0 254.989 127.989 254.989 0 0 254.989 0 254.989 0 0 254.989
255 0.00711415 0.00711415 0.00711415 255 255 128.007 0.00711415 0.00711415 255 255 0.00711415 0.00711415 0.00711415 255 255 255 0.00813221 0.00813221 255 0.00813221 255 128.008 0.00813221 255 0.00813221 255 0.00813221 0.00813221 255 0.00813221 255 255 0.0103512 255 0.0103512 0.0103512 255 128.01 255 0.0103512 0.0103512 255 0.0103512 255 0.0103512 0.0103512 255

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,4 +1,4 @@
1 images\black.jpg 0
2 images\blue.jpg 1
3 images\green.jpg 2
4 images\red.jpg 3
1 images/black.jpg 0
2 images/blue.jpg 1
3 images/green.jpg 2
4 images/red.jpg 3

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

@ -1,4 +1,4 @@
images\black.jpg 0
images\blue.jpg blah
images\green.jpg 2
images\red.jpg 3
images/black.jpg 0
images/blue.jpg blah
images/green.jpg 2
images/red.jpg 3

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

@ -1,4 +1,4 @@
images\black.jpg 0
images\blue.jpg 1
images\green.jpg
images\red.jpg 3
images/black.jpg 0
images/blue.jpg 1
images/green.jpg
images/red.jpg 3

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

@ -1 +1 @@
images\grayscale.png 0
images/grayscale.png 0

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

@ -1,4 +1,4 @@
images\black.jpg 0
images\blue.jpg 1
images\green.jpg 2
images\red.jpg 10
images/black.jpg 0
images/blue.jpg 1
images/green.jpg 2
images/red.jpg 10

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

@ -1,4 +1,4 @@
imageDoesNotExists\black.jpg 0
images\blue.jpg 1
images\green.jpg 2
images\red.jpg 3
imageDoesNotExists/black.jpg 0
images/blue.jpg 1
images/green.jpg 2
images/red.jpg 3

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

@ -1 +1 @@
images\multi.png 0
images/multi.png 0

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

@ -1,4 +1,4 @@
images\black.jpg 0
images\blue.jpg 1
images\green.jpg 2
images\red.jpg 3
images/black.jpg 0
images/blue.jpg 1
images/green.jpg 2
images/red.jpg 3

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

@ -1,2 +1,2 @@
images\black.jpg 0
images\multi.png 1
images/black.jpg 0
images/multi.png 1

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

@ -1,5 +1,5 @@
images\simple.zip@\chunk0\black.jpg 0
images\simple.zip@\chunk0\blue.jpg 1
images\simple.zip@\chunk1\green.jpg 2
images\simple.zip@\missing.jpg 3
images\simple.zip@\chunk1\red.jpg 3
images/simple.zip@/chunk0/black.jpg 0
images/simple.zip@/chunk0/blue.jpg 1
images/simple.zip@/chunk1/green.jpg 2
images/simple.zip@/missing.jpg 3
images/simple.zip@/chunk1/red.jpg 3

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

@ -1,4 +1,4 @@
images\simple.zip@\chunk0\black.jpg 0
images\simple.zip@\chunk0\blue.jpg 1
images\simple.zip@\chunk1\green.jpg 2
images\simple.zip@\chunk1\red.jpg 3
images/simple.zip@/chunk0/black.jpg 0
images/simple.zip@/chunk0/blue.jpg 1
images/simple.zip@/chunk1/green.jpg 2
images/simple.zip@/chunk1/red.jpg 3

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

@ -1,2 +0,0 @@
0
1

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -49,7 +49,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop1)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop2)
@ -117,24 +122,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop5)
1,
1,
0,
1);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop6)
{
HelperRunReaderTest<float>(
testDataPath() + "/Config/HTKMLFReaderSimpleDataLoop6_Config.cntk",
testDataPath() + "/Control/HTKMLFReaderSimpleDataLoop6_16_17_Control.txt",
testDataPath() + "/Control/HTKMLFReaderSimpleDataLoop6_Output.txt",
"Simple_Test",
"reader",
500,
250,
2,
1,
1,
0,
1);
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop7)
@ -145,7 +138,6 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop7)
"reader");
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop8)
{
HelperRunReaderTest<float>(
@ -177,7 +169,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop10)
2,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop11)
@ -194,7 +191,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop11)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop12)
@ -262,7 +264,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop16)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop19)
@ -279,7 +286,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop19)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop20)
@ -296,7 +308,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop20)
2,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop21_0)
@ -330,7 +347,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop21_1)
1,
1,
1,
2);
2,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop22)
@ -347,7 +369,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop22)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop1)
@ -364,7 +391,12 @@ BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop1)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop5)
@ -381,7 +413,12 @@ BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop5)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop11)
@ -398,7 +435,12 @@ BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop11)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop21_0)
@ -432,7 +474,12 @@ BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop21_1)
1,
1,
1,
2);
2,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop4)
@ -500,7 +547,12 @@ BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop9)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop9)
@ -517,7 +569,12 @@ BOOST_AUTO_TEST_CASE(HTKMLFReaderSimpleDataLoop9)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop19)
@ -534,7 +591,12 @@ BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop19)
1,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop10)
@ -551,7 +613,12 @@ BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop10)
2,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop20)
@ -568,7 +635,12 @@ BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop20)
2,
1,
0,
1);
1,
false,
false,
true,
{},
true);
};
BOOST_AUTO_TEST_CASE(HTKDeserializersSimpleDataLoop3)

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

@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(ImageReaderLabelOutOfRange)
0,
1),
std::runtime_error,
[](std::runtime_error const& ex) { return string("Image 'images\\red.jpg' has invalid class id '10'. Expected label dimension is '4'. Line 3 in file ./ImageReaderLabelOutOfRange_map.txt.") == ex.what(); });
[](std::runtime_error const& ex) { return string("Image 'images/red.jpg' has invalid class id '10'. Expected label dimension is '4'. Line 3 in file ./ImageReaderLabelOutOfRange_map.txt.") == ex.what(); });
}
BOOST_AUTO_TEST_CASE(ImageReaderZip)
@ -253,7 +253,7 @@ BOOST_AUTO_TEST_CASE(ImageReaderMissingImage)
0,
1),
std::runtime_error,
[](const std::runtime_error& ex) { return string("Cannot open file 'imageDoesNotExists\\black.jpg'") == ex.what(); });
[](const std::runtime_error& ex) { return string("Cannot open file 'imageDoesNotExists/black.jpg'") == ex.what(); });
}
BOOST_AUTO_TEST_CASE(ImageReaderEmptyTransforms)

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

@ -4,15 +4,14 @@
//
#include "stdafx.h"
#include <numeric>
#include <random>
#include <boost/random/uniform_int_distribution.hpp>
#include "NoRandomizer.h"
#include "DataDeserializer.h"
#include "BlockRandomizer.h"
#include "CorpusDescriptor.h"
#include <numeric>
#include <random>
using namespace Microsoft::MSR::CNTK;
using namespace std;
@ -305,8 +304,8 @@ void BlockRandomizerChaosMonkeyTest(bool prefetch)
const int windowSize = 18;
vector<float> data(numChunks * numSequencesPerChunk);
iota(data.begin(), data.end(), 0.0f);
mt19937 rng(seed);
uniform_int_distribution<int> distr(1, 10);
std::mt19937 rng(seed);
boost::random::uniform_int_distribution<int> distr(1, 10);
auto mockDeserializer = make_shared<MockDeserializer>(numChunks, numSequencesPerChunk, data, sequenceLength);
@ -443,8 +442,8 @@ BOOST_AUTO_TEST_CASE(NoRandomizerOneEpoch)
BOOST_AUTO_TEST_CASE(DefaultCorpusDescriptor)
{
const int seed = 13;
mt19937 rng(seed);
uniform_int_distribution<int> distr(50, 60);
std::mt19937 rng(seed);
boost::random::uniform_int_distribution<int> distr(50, 60);
string randomKey(10, (char)distr(rng));

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

@ -26,9 +26,7 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(SolutionDir)\CNTK.Cpp.props" />
<PropertyGroup>
<HasBoost>false</HasBoost>
<HasBoost Condition="Exists('$(BOOST_INCLUDE_PATH)') And Exists('$(BOOST_LIB_PATH)')">true</HasBoost>
<PropertyGroup>
<ImageReaderDefine Condition="$(HasOpenCv)">ENABLE_IMAGEREADER_TESTS</ImageReaderDefine>
</PropertyGroup>
<PropertyGroup Label="Configuration">
@ -115,7 +113,6 @@
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="UCIFastReaderTests.cpp" />
<ClCompile Include="..\..\..\Source\Readers\CNTKTextFormatReader\Indexer.cpp" />
<ClCompile Include="..\..\..\Source\Readers\CNTKTextFormatReader\TextParser.cpp" />
</ItemGroup>

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

@ -10,7 +10,6 @@
<ItemGroup>
<ClCompile Include="stdafx.cpp" />
<ClCompile Include="HTKLMFReaderTests.cpp" />
<ClCompile Include="UCIFastReaderTests.cpp" />
<ClCompile Include="ReaderLibTests.cpp" />
<ClCompile Include="ImageReaderTests.cpp" />
<ClCompile Include="CNTKTextFormatReaderTests.cpp" />

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

@ -1,41 +0,0 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
#include "stdafx.h"
#include "Common/ReaderTestHelper.h"
using namespace Microsoft::MSR::CNTK;
namespace Microsoft { namespace MSR { namespace CNTK { namespace Test {
struct UCIReaderFixture : ReaderFixture
{
UCIReaderFixture()
: ReaderFixture("/Data")
{
}
};
BOOST_FIXTURE_TEST_SUITE(ReaderTestSuite, UCIReaderFixture)
BOOST_AUTO_TEST_CASE(UCIFastReaderSimpleDataLoop)
{
HelperRunReaderTest<float>(
testDataPath() + "/Config/UCIFastReaderSimpleDataLoop_Config.cntk",
testDataPath() + "/Control/UCIFastReaderSimpleDataLoop_Control.txt",
testDataPath() + "/Control/UCIFastReaderSimpleDataLoop_Output.txt",
"Simple_Test",
"reader",
500,
250,
2,
1,
1,
0,
1);
};
BOOST_AUTO_TEST_SUITE_END()
} } } }

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

@ -684,7 +684,7 @@ then
if test x$boost_path = x
then
echo Cannot locate Boost libraries
echo Unit tests will NOT be built.
echo ImageReader and Unit tests will NOT be built.
else
echo Found Boost at $boost_path
fi