result = torch.cat([result,temp]) throws the below error.
RuntimeError: dimension specified as 0 but tensor has no dimensions
This is with reference to this part of code, that I’m trying to port to pytorch. Thank you.
EDIT: some like below tensorflow code
result = []
input_downsampled = input
for i in range(3):
result.append(self.forward(model, input_downsampled))
if i != (2):
input_downsampled = self.downsample(input_downsampled)
return result
result = []
input_downsampled = input
for i in range(3):
result.append(self.forward(model, input_downsampled))
if i != (2):
input_downsampled = self.downsample(input_downsampled)
return result
result = None
input_downsampled = input
for i in range(3):
if result is None:
result = self.forward(model, input_downsampled)
else:
result = torch.cat([model, self.forward(model, input_downsampled)])
if i != (2):
input_downsampled = self.downsample(input_downsampled)
return result
The tensorflow code you posted returns a list. How is this list used? If it is used as a list of tensors and not as a tensor itself, then the code you posted should do the job just fine.