srl-zoo
srl-zoo copied to clipboard
Input is not contiguous for some models (Low priority)
DenseVAE
in ./models/models.py, has an issue when run on CPU
It seems that x
is not contiguous when training the VAE with --model_type mlp
from the raw pixels
def encode(self, x):
# Flatten input
x = x.view(x.size(0), -1)
x = self.relu(self.encoder_fc1(x))
return self.encoder_fc21(x), self.encoder_fc22(x)
As explained https://discuss.pytorch.org/t/runtimeerror-input-is-not-contiguous/930 , the simple fix is
def encode(self, x):
# Flatten input
x = x.contiguous()
x = x.view(x.size(0), -1)
x = self.relu(self.encoder_fc1(x))
return self.encoder_fc21(x), self.encoder_fc22(x)
However, i'm opening an issue, as I am not sure where else this error can occur, nor why it does occur.