PacktPublishing/Hands-On-Machine-Learning-with-CPP

Chapter 11 MNIST example dimension error

Opened this issue · 0 comments

When I tried to run MNIST example from chapter 11 this error appeared:

Dimension out of range (expected to be in range of [-1, 0], but got 1)
Exception raised from maybe_wrap_dim_slow at ../c10/core/WrapDimMinimal.cpp:22 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) + 0x6c (0x7de538d4d2ac in /home/libtorch/lib/libc10.so)
frame #1: long c10::detail::maybe_wrap_dim_slow<long>(long, long, bool) + 0x2a7 (0x7de538d35857 in /home/libtorch/lib/libc10.so)
frame #2: at::native::squeeze(at::Tensor const&, long) + 0x60 (0x7de514763540 in /home/libtorch/lib/libtorch_cpu.so)
frame #3: <unknown function> + 0x3069828 (0x7de515669828 in /home/libtorch/lib/libtorch_cpu.so)
frame #4: at::_ops::squeeze_dim::redispatch(c10::DispatchKeySet, at::Tensor const&, long) + 0x8a (0x7de514c6440a in /home/libtorch/lib/libtorch_cpu.so)
frame #5: <unknown function> + 0x53e2e02 (0x7de5179e2e02 in /home/libtorch/lib/libtorch_cpu.so)
frame #6: <unknown function> + 0x53e310b (0x7de5179e310b in /home/libtorch/lib/libtorch_cpu.so)
frame #7: at::_ops::squeeze_dim::redispatch(c10::DispatchKeySet, at::Tensor const&, long) + 0x8a (0x7de514c6440a in /home/libtorch/lib/libtorch_cpu.so)
frame #8: <unknown function> + 0x495b5d8 (0x7de516f5b5d8 in /home/libtorch/lib/libtorch_cpu.so)
frame #9: <unknown function> + 0x495bc0b (0x7de516f5bc0b in /home/libtorch/lib/libtorch_cpu.so)
frame #10: at::_ops::squeeze_dim::call(at::Tensor const&, long) + 0x165 (0x7de514cdfe45 in /home/libtorch/lib/libtorch_cpu.so)
frame #11: <unknown function> + 0xfd8c (0x5cc30b51fd8c in ./mnist_example)
frame #12: <unknown function> + 0xd331 (0x5cc30b51d331 in ./mnist_example)
frame #13: <unknown function> + 0x25c88 (0x7de4b8839c88 in /usr/lib/libc.so.6)
frame #14: __libc_start_main + 0x8c (0x7de4b8839d4c in /usr/lib/libc.so.6)
frame #15: <unknown function> + 0xcb05 (0x5cc30b51cb05 in ./mnist_example)
make[2]: *** [CMakeFiles/mnist_example.dir/build.make:210: mnist_example] Помилка 1
make[2]: *** Вилучаємо файл "mnist_example"
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/mnist_example.dir/all] Помилка 2
make: *** [Makefile:136: all] Помилка 2

How to fix it?