HI, All
I would like to read in libtorch with MNIST dataset, where the ptorch code is doing
raw_dataset = datasets.MNIST(’…/data’, train=True, download=True,
transform=transforms.Compose([
transforms.ToTensor(),
]))
perm = np.random.permutation(raw_dataset.len())
for i in range(raw_dataset.len()):
datum, label = raw_dataset.getitem(perm[i])
In libtorch code, I write:
auto raw_dataset= torch::data::datasets::MNIST("…/data").map(torch::data::transforms::Normalize<>(0.13707,0.3081)).map(torch::data::transforms::Stack<>());
torch::Tensor perm=torch::randperm(sizeof(raw_dataset));

for (int i=0; i<sizeof(raw_dataset);i++)
{
torch::Tensor datum=raw_dataset.get_batch(perm([i])).data;
torch::Tensor label1=raw_dataset.get_batch(perm([i])).target;
//torch::Tensor datum=raw_dataset.targets;
}
I get the error “expected body of lambda expression”  in (perm[i]), any suggestions to fix it please ?
Thanks a lot .
Much appreciated.