I am trying to train GCN model on my custom dataset and I have resized all the values but I am getting error:

RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 7 but got size 14515200 for tensor number 1 in the list.

This is the GCN code:

class Net(torch.nn.Module):
def init(self):
super(Net, self).init()
self.conv1 = GCNConv(3, 64)
self.conv2 = GCNConv(64, 64)
self.conv3 = GCNConv(64, 64)
self.conv4 = GCNConv(48, 64)
self.conv5 = GCNConv(64, 96)
self.conv6 = GCNConv(96, 128)
self.linear1 = torch.nn.Linear(64,2)
self.linear2 = torch.nn.Linear(64,8)
def forward(self, data):
    print(data)
    pixel_values = data.pixel_values.view(-1, 3)
    x = torch.cat([data.pos, pixel_values], dim=-1)
    x, edge_index = x, data.edge_index
    x = self.conv1(x, edge_index)
    x = F.relu(x)
    x = self.conv2(x, edge_index)
    x = F.relu(x)
    x = self.conv3(x, edge_index)
    x = F.relu(x)
    x = self.conv4(x, edge_index)
    x = F.relu(x)
    x = self.conv5(x, edge_index)
    x = F.relu(x)
    x = self.conv6(x, edge_index)
    x = F.relu(x)
    x, _ = scatter_max(x, data.batch, dim=0)
    x = self.linear1(x)
    x = F.relu(x)
    x = self.linear2(x)
    return x

def main():
data_list = load_data_graph(data_size=data_size)
device = torch.device(‘cuda’)
model = Net().to(device)
trainset = data_list[:train_size]
optimizer = torch.optim.Adam(model.parameters())
train_loader = DataLoader(trainset, batch_size=batch_size, shuffle=True)
testset = data_list[train_size:]
test_loader = DataLoader(testset, batch_size=batch_size)
criterion = nn.CrossEntropyLoss()
history = {
    "train_loss": [],
    "test_loss": [],
    "test_acc": []
}

print("Start Train")

model.train()
for epoch in range(epoch_num):
    train_loss = 0.0
    for i, batch in enumerate(train_loader):
        batch = batch.to("cuda")
        optimizer.zero_grad()
        outputs = model(batch)
        loss = criterion(outputs,batch.tensor)
        loss.backward()
        optimizer.step()
        
        train_loss += loss.cpu().item()
        if i % 10 == 9:
            progress_bar = '['+('='*((i+1)//10))+(' '*((train_size//100-(i+1))//10))+']'
            print('\repoch: {:d} loss: {:.3f}  {}'
                    .format(epoch + 1, loss.cpu().item(), progress_bar), end="  ")


The error:

RuntimeError                              Traceback (most recent call last)
/tmp/ipykernel_58/874853799.py in 
126
127 if name==“main”:
 → 128     main()
/tmp/ipykernel_58/874853799.py in main()
76             batch = batch.to(“cuda”)
77             optimizer.zero_grad()
—> 78             outputs = model(batch)
79             loss = criterion(outputs,batch.tensor)
80             loss.backward()
/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
1100         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1101                 or _global_forward_hooks or _global_forward_pre_hooks):
 → 1102             return forward_call(*input, **kwargs)
1103         # Do not call functions when jit is used
1104         full_backward_hooks, non_full_backward_hooks = [], []
/tmp/ipykernel_58/874853799.py in forward(self, data)
28         print(data)
29         pixel_values = data.pixel_values.view(-1, 3)
—> 30         x = torch.cat([data.pos, pixel_values], dim=-1)
31         x, edge_index = x, data.edge_index
32         x = self.conv1(x, edge_index)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 7 but got size 14515200 for tensor number 1 in the list.