I was trying to convert my torch model to tensorRT I encountered with this problem.
** Encountered known unsupported method torch.randn**
Please any help regarding this would be appreciated.
Please find the code snippet below
class VAEGen(nn.Module):
# VAE architecture
def init(self, input_dim):
super(VAEGen, self).init()
# dim = params[‘dim’]
# n_downsample = params[‘n_downsample’]
# n_res = params[‘n_res’]
# activ = params[‘activ’]
# pad_type = params[‘pad_type’]
# content encoder
self.enc = ContentEncoder(2, 4, 3, 64, 'in', 'relu', pad_type='reflect')
self.dec = Decoder(2, 4, self.enc.output_dim, 3, res_norm='in', activ='relu', pad_type='reflect')
def forward(self, images):
# This is a reduced VAE implementation where we assume the outputs are multivariate Gaussian distribution with mean = hiddens and std_dev = all ones.
hiddens,_ = self.encode(images)
if self.training == False:
noise = Variable(torch.randn(hiddens.size()).cuda(hiddens.data.get_device()))
images_recon = self.decode(hiddens + noise)
else:
images_recon = self.decode(hiddens)
return images_recon, hiddens
def encode(self, images):
hiddens = self.enc(images)
noise = Variable(torch.randn(hiddens.size()).cuda(hiddens.data.get_device()))
return hiddens, noise
def decode(self, hiddens):
images = self.dec(hiddens)
return images