I used thoses expression and encountered some problem.
my mask is a Variable, when I use mask.nonzero() it errors as Variable object has no attribute 'nonzero';
when I use mask.data.nonzero(),it shows
{RuntimeError}invalid argument 3: expecting vector of indices at /opt/conda/conda-bld/pytorch_1502006348621/work/torch/lib/THC/generic/THCTensorIndex.cu:405
so I used input.index_select(dim, mask.data.nonzero().suqeeze(1)), but It throwed another error:
{RuntimeError}save_for_backward can only save input or output tensors, but argument 0 doesn't satisfy this condition, Here my input is a variable .
Any idea what to do next? thanks in advance!