I am also trying to concatenate two tensors to use as input to a linear layer. Each tensor is the output of a subnetwork that independently processes two input tensors. I am getting the following error:

```
RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.
```

I suspect the error has to do with the temporary assignment of a variable to hold the concatenated data `x3 = torch.cat((x1, x2), dim=1)`

. The network is defined below:

```
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
# Energy map net
self.conv1 = nn.Conv2d(19, 32, (1,3), padding=(0,1))
self.pool = nn.MaxPool2d((1,3))
self.conv2 = nn.Conv2d(32, 64, (1,3))
self.fc1 = nn.Linear(64 * 9 * 10, 120)
self.fc2 = nn.Linear(120, 60)
# Sequence net
self.fc3 = nn.Linear(9 * 22, 120)
self.fc4 = nn.Linear(120, 60)
# Combine (concatenated 60 + 60)
self.fc5 = nn.Linear(60 + 60, 120)
self.fc6 = nn.Linear(120, 2)
def forward(self, x1, x2):
# Energy map net
x1 = self.pool(F.relu(self.conv1(x1)))
x1 = self.pool(F.relu(self.conv2(x1)))
x1 = x1.view(-1, 64 * 9 * 10)
x1 = F.relu(self.fc1(x1))
x1 = F.relu(self.fc2(x1))
# Sequence net
x2 = x2.view(-1, 9 * 22)
x2 = F.relu(self.fc3(x2))
x2 = F.relu(self.fc4(x2))
# Combine
x3 = torch.cat((x1, x2), dim=1)
x3 = F.relu(self.fc5(x3))
x3 = self.fc5(x3)
return x3
```