jiangtaoxie / fast-MPN-COV

@CVPR2018: Efficient unrolling iterative matrix square-root normalized ConvNets, implemented by PyTorch (and code of B-CNN,Compact bilinear pooling etc.) for training from scratch & finetuning.
http://peihuali.org/iSQRT-COV/index.html
MIT License
270 stars 56 forks source link

About the implementation of MPNCOV meta layer in pytorch 0.3.1 #22

Open BangguWu opened 4 years ago

BangguWu commented 4 years ago

I try to add mpncov layer in my network in pytorch 0.3.1. but I get error which is

Traceback (most recent call last):
  File "main.py", line 421, in <module>
    main()
  File "main.py", line 211, in main
    loss_temp, train_prec1_temp, train_prec5_temp = train(train_loader, model, criterion, optimizer, epoch)
  File "main.py", line 269, in train
    output = model(input)
  File "/home/zhangli/anaconda3/envs/pytorch-0.3.1/lib/python3.5/site-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/zhangli/anaconda3/envs/pytorch-0.3.1/lib/python3.5/site-packages/torch/nn/parallel/data_parallel.py", line 71, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "/home/zhangli/anaconda3/envs/pytorch-0.3.1/lib/python3.5/site-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/zhangli/wubanggu/darts/test_res/resnet.py", line 156, in forward
    x = self.representation(x)
  File "/home/zhangli/anaconda3/envs/pytorch-0.3.1/lib/python3.5/site-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/zhangli/wubanggu/darts/test_res/MPNCOV.py", line 69, in forward
    x = self._cov_pool(x)
  File "/home/zhangli/wubanggu/darts/test_res/MPNCOV.py", line 60, in _cov_pool
    return Covpool.apply(x)
RuntimeError: save_for_backward can only save input or output tensors, but argument 1 doesn't satisfy this condition

How can I fix it , Thank you very much.