MCPcopy Create free account
hub / github.com/apache/singa / DecodeTransform

Method DecodeTransform

examples/cpp/imagenet/ilsvrc12.h:351–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351void ILSVRC::DecodeTransform(int flag, int thid, int nthreads,
352 vector<string *> images, Tensor *x, Tensor *y) {
353 int nimg = images.size();
354 int start = nimg / nthreads * thid;
355 int end = start + nimg / nthreads;
356 for (int k = start; k < end; k++) {
357 std::vector<Tensor> pair = decoder->Decode(*images.at(k));
358 auto tmp_image = pair[0] - mean;
359 Tensor aug_image = transformer->Apply(flag, tmp_image);
360 CopyDataToFrom(x, aug_image, aug_image.Size(), k * aug_image.Size());
361 CopyDataToFrom(y, pair[1], 1, k);
362 }
363 if (thid == 0) {
364 for (int k = nimg / nthreads * nthreads; k < nimg; k++) {
365 std::vector<Tensor> pair = decoder->Decode(*images.at(k));
366 auto tmp_image = pair[0] - mean;
367 Tensor aug_image = transformer->Apply(flag, tmp_image);
368 CopyDataToFrom(x, aug_image, aug_image.Size(), k * aug_image.Size());
369 CopyDataToFrom(y, pair[1], 1, k);
370 }
371 }
372}
373} // namespace singa
374
375#endif // SINGA_EXAMPLES_IMAGENET_ILSVRC12_H_

Callers

nothing calls this directly

Calls 5

CopyDataToFromFunction · 0.85
sizeMethod · 0.45
DecodeMethod · 0.45
ApplyMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected