Addressing ImageReader CR from Frank

This commit is contained in:
Eldar Akchurin 2016-02-03 16:30:58 +01:00
Родитель 27fd4e045b
Коммит f5a349a11a
11 изменённых файлов: 34 добавлений и 33 удалений

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

@ -188,6 +188,7 @@
<ClInclude Include="..\Common\Include\Basics.h" />
<ClInclude Include="..\Common\Include\BestGpu.h" />
<ClInclude Include="..\Common\Include\DataReader.h" />
<ClInclude Include="..\Common\Include\StringUtil.h" />
<ClInclude Include="..\Common\Include\TensorShape.h" />
<ClInclude Include="..\Common\Include\DataWriter.h" />
<ClInclude Include="..\Common\Include\File.h" />
@ -242,7 +243,8 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64' Or '$(Configuration)|$(Platform)'=='Debug_CpuOnly|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\Common\DebugUtil.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64' Or '$(Configuration)|$(Platform)'=='Debug_CpuOnly|x64'"></PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64' Or '$(Configuration)|$(Platform)'=='Debug_CpuOnly|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\Common\Include\ConcStack.h" />
<ClCompile Include="..\Common\TimerUtility.cpp" />

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

@ -193,6 +193,9 @@
<ClInclude Include="..\ComputationNetworkLib\TrainingNodes.h">
<Filter>from ComputationNetworkLib\Nodes</Filter>
</ClInclude>
<ClInclude Include="..\Common\Include\StringUtil.h">
<Filter>Common\Include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="modelEditor.txt">

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

@ -6,12 +6,11 @@
#pragma once
#include <string>
#include <locale>
namespace Microsoft { namespace MSR { namespace CNTK {
// Compares two ASCII strings ignoring the case.
// TODO: Should be moved to common CNTK library and after switching to boost, boost::iequal should be used instead.
// TODO: Should switch to boost, boost::iequal should be used instead.
inline bool AreEqualIgnoreCase(const std::string& s1, const std::string& s2)
{
return std::equal(s1.begin(), s1.end(), s2.begin(), [](const char& a, const char& b)
@ -19,4 +18,5 @@ inline bool AreEqualIgnoreCase(const std::string& s1, const std::string& s2)
return std::tolower(a) == std::tolower(b);
});
}
} } }

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

@ -5,7 +5,7 @@
#include "stdafx.h"
#include "ImageConfigHelper.h"
#include "StringUtils.h"
#include "StringUtil.h"
namespace Microsoft { namespace MSR { namespace CNTK {
@ -49,11 +49,11 @@ namespace Microsoft { namespace MSR { namespace CNTK {
size_t c = featureSection("channels");
std::string mbFmt = featureSection("mbFormat", "nchw");
if (AreEqualIgnoreCase(mbFmt, "nhwc"))
if (AreEqualIgnoreCase(mbFmt, "nhwc") || AreEqualIgnoreCase(mbFmt, "legacy"))
{
m_dataFormat = HWC;
}
else if (!AreEqualIgnoreCase(mbFmt, "nchw"))
else if (!AreEqualIgnoreCase(mbFmt, "nchw") || AreEqualIgnoreCase(mbFmt, "cudnn"))
{
RuntimeError("ImageReader does not support the sample format '%s', only 'nchw' and 'nhwc' are supported.", mbFmt.c_str());
}

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

@ -77,8 +77,7 @@ void ImageReader::StartEpoch(const EpochConfiguration& config)
{
if (config.m_totalEpochSizeInSamples <= 0)
{
RuntimeError("Unsupported minibatch size '%d'.",
static_cast<int>(config.m_totalEpochSizeInSamples));
RuntimeError("Unsupported minibatch size '%u'.", (int)config.m_totalEpochSizeInSamples);
}
m_transformer->StartEpoch(config);

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

@ -12,7 +12,7 @@
#include "Config.h"
#include "ConcStack.h"
#include "ImageConfigHelper.h"
#include "StringUtils.h"
#include "StringUtil.h"
#include "ElementTypeUtils.h"
namespace Microsoft { namespace MSR { namespace CNTK

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

@ -18,8 +18,8 @@ struct SequenceDescription
size_t m_id; // Sequence id, uniquely identifies the sequence.
size_t m_numberOfSamples; // Number of samples in a sequence.
size_t m_chunkId; // Each sequence belongs to an I/O chunk, how chunk is defined is specific to a
// particular data deserializer. The randomizer guarantees to request sequences
// from only limited subset of chunks at any moment in time.
// particular data deserializer (or bundler). The randomizer guarantees to request
// sequences from only limited subset of chunks at any moment in time.
bool m_isValid; // Indicates whether the sequence is valid.
};
typedef std::vector<const SequenceDescription*> SequenceDescriptions;
@ -73,6 +73,7 @@ class DataDeserializer
{
public:
// Describes streams this data deserializer can produce. Streams correspond to network inputs.
// TODO: Introduce the interface to reduce the size of the sequences available at any point in time (chunks/sequences).
virtual std::vector<StreamDescriptionPtr> GetStreamDescriptions() const = 0;
// Retrieves description of all sequences this data deserializer can produce.

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

@ -13,6 +13,7 @@
namespace Microsoft { namespace MSR { namespace CNTK {
// The class represents a randomizer that does not randomize input (identity function over the original timeline).
// This class is used for inference and for training where the training data has already been pre - randomized.
// TODO: currently this code moved from the old block randomizer.
// The class will be further refactored and common based will be extracted with BlockRandomizer.
// Currently works only for frame mode (numberOfSample in sequence == 1) and without chunking

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

@ -86,7 +86,6 @@
<ClInclude Include="MemoryProvider.h" />
<ClInclude Include="Reader.h" />
<ClInclude Include="ReaderShim.h" />
<ClInclude Include="StringUtils.h" />
<ClInclude Include="Transformer.h" />
</ItemGroup>
<ItemGroup>

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

@ -31,9 +31,6 @@
<ClInclude Include="ElementTypeUtils.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="StringUtils.h">
<Filter>Utils</Filter>
</ClInclude>
<ClInclude Include="TransformerBase.h">
<Filter>Transformers</Filter>
</ClInclude>

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

@ -15,8 +15,7 @@ SampleModePacker::SampleModePacker(
MemoryProviderPtr memoryProvider,
TransformerPtr transformer,
size_t minibatchSize,
const std::vector<StreamDescriptionPtr>& streams)
: m_transformer(transformer),
const std::vector<StreamDescriptionPtr>& streams) : m_transformer(transformer),
m_minibatchSize(minibatchSize),
m_outputStreams(streams),
m_minibatchLayout(std::make_shared<MBLayout>()),