I have got a batch of features (N features). Now I want to pass message among different features.
I found that if I manipulate the features along batch dim, then errors will be raised when backward(). The codes are like below:
from torch.autograd import Variable
import numpy as np
import torch.nn as nn
a = Variable(torch.Tensor(3, 5).normal_(), requires_grad=True)
b = Variable(torch.Tensor(3, 5).normal_(), requires_grad=True)
for i in range(b.size()):
for j in range(a.size()):
b[i] = b[i] + a[j]
When running, I got "inconsistent tensor size at /data/users/soumith/miniconda2/conda-bld/pytorch-0.1.7_1485444530918/work/torch/lib/TH/generic/THTensorCopy.c:40".
Is it possible to divid the original Variable into several parts and then process them?