Skip to content

Commit

Permalink
MNIST images should have an extra dim (pytorch#13060)
Browse files Browse the repository at this point in the history
Summary:
Our convolution ops and such expect three dimensional images, but the images in the MNIST dataset of the C++ frontend currently only have two.

apaszke ebetica soumith
Pull Request resolved: pytorch#13060

Differential Revision: D10560754

Pulled By: goldsborough

fbshipit-source-id: a2cc877b4f43434482bec902c941fafb7a157d5d
  • Loading branch information
goldsborough authored and facebook-github-bot committed Oct 24, 2018
1 parent 6727133 commit 86881cd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion torch/csrc/api/src/data/datasets/mnist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ Tensor read_images(const std::string& root, bool train) {
expect_int32(images, kImageRows);
expect_int32(images, kImageColumns);

auto tensor = torch::empty({count, kImageRows, kImageColumns}, torch::kByte);
auto tensor =
torch::empty({count, 1, kImageRows, kImageColumns}, torch::kByte);
images.read(reinterpret_cast<char*>(tensor.data_ptr()), tensor.numel());
return tensor.to(torch::kFloat32).div_(255);
}
Expand Down

0 comments on commit 86881cd

Please sign in to comment.