khanrc / pt.darts

PyTorch Implementation of DARTS: Differentiable Architecture Search
MIT License
439 stars 108 forks source link

batch_size issue #40

Open buttercutter opened 3 years ago

buttercutter commented 3 years ago

I ran python search.py --name cifar10 --dataset cifar10 --batch_size 32 , but I have the following error at utils.py. Why ?

Traceback (most recent call last):
  File "/home/phung/Downloads/darts/pt.darts/search.py", line 201, in <module>
    main()
  File "/home/phung/Downloads/darts/pt.darts/search.py", line 84, in main
    train(train_loader, valid_loader, model, architect, w_optim, alpha_optim, lr, epoch)
  File "/home/phung/Downloads/darts/pt.darts/search.py", line 144, in train
    prec1, prec5 = utils.accuracy(logits, trn_y, topk=(1, 5))
  File "/home/phung/Downloads/darts/pt.darts/utils.py", line 103, in accuracy
    correct_k = correct[:k].view(-1).float().sum(0)
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
buttercutter commented 3 years ago

Problem solved using https://github.com/promach/pt.darts/

skbhat commented 3 years ago

First apply .contiguous() before view. Eg:

correct_k = correct[:k].view(-1).float().sum(0) must be changed to correct_k = correct[:k].contiguous().view(-1).float().sum(0)

Suggested by https://github.com/cezannec/capsule_net_pytorch/issues/4