title: reshape tensor in an autoencoder model using fashion mnist
body: <p>my code works fine for epoch number1 but when the epoch changes it stops working because of different shaping.
  could you please help me to solve this problem?
  I really appreciate your time</p>
  <pre><code>transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,))])
          trainTransform  = torchvision.transforms.Compose([torchvision.transforms.ToTensor(), torchvision.transforms.Normalize((0.1307,), (0.3081,))])
          trainset = torchvision.datasets.FashionMNIST(root='{}/./data'.format(path_prefix), train = True, download = True, transform = transform)
          train_loader = torch.utils.data.DataLoader(trainset, batch_size=32, shuffle=False, num_workers=4)
          valset = torchvision.datasets.FashionMNIST(root='{}/./data'.format(path_prefix), train=False, download=True, transform=transform)
          val_loader = torch.utils.data.DataLoader(valset, batch_size=32, shuffle=False, num_workers=4)
  
  
  def train(self, epoch):
          # Note that you need to modify both trainer and loss_function for the VAE model
          self.model.train()
          train_loss = 0
          for batch_idx, (data, _) in tqdm(enumerate(self.train_loader), total=len(self.train_loader) ) :
              data = data.view(data.shape[0], -1)
  
              data = data.to(self.device)
              #print(data.shape)
              #print(data)
              self.optimizer.zero_grad()
              recon_batch = self.model(data)
              loss = self.loss_function(recon_batch, data)
              loss.backward()
              train_loss += loss.item()
              self.optimizer.step()
  
          train_loss /= len(self.train_loader.dataset)/32 # 32 is the batch size
          print('====&gt; Epoch: {} Average loss: {:.4f}'.format(
                epoch, train_loss ))
  </code></pre>