mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Changed code to avoid advancing iterator beyond end since some compilers
complain about this (and it's technically not allowed in C++).
This commit is contained in:
parent
edb2790bcc
commit
3a096469ef
@ -2189,10 +2189,15 @@ namespace dlib
|
||||
{
|
||||
std::vector<label_type> results(std::distance(data.begin(), data.end()));
|
||||
auto o = results.begin();
|
||||
for (auto i = data.begin(); i < data.end(); i+=batch_size, o+=batch_size)
|
||||
auto i = data.begin();
|
||||
auto num_remaining = results.size();
|
||||
while(num_remaining != 0)
|
||||
{
|
||||
auto end = std::min(i+batch_size, data.end());
|
||||
(*this)(i, end, o);
|
||||
auto inc = std::min(batch_size, num_remaining);
|
||||
(*this)(i, i+inc, o);
|
||||
i += inc;
|
||||
o += inc;
|
||||
num_remaining -= inc;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user