Hi all,
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:
import torch
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()[0]):
    for j in range(a.size()[0]):
        b[i] = b[i] + a[j]
        
b.backward(torch.Tensor(5, 3).normal_())

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?
Best,
Yikang