title: AttributeError: 'UneXt50' object has no attribute 'encoder'
body: <p>The <code>UneXt50</code> class defines a convolutional multilayer perceptron.
  I'm not sure where to add the 'encoder' attribute because the traceback did not make sense.</p>
  <pre><code>from fastai.vision.all import *
  import torch
  import torch.nn.functional as F
  from tqdm.notebook import tqdm
  
  
  class UneXt50(nn.Module):
      def __init__(self, stride=1, **kwargs):
          super().__init__()
          # encoder
          m = torch.hub.load('facebookresearch/semi-supervised-ImageNet1K-models',
                             'resnext50_32x4d_ssl')
          self.enc0 = nn.Sequential(m.conv1, m.bn1, nn.ReLU(inplace=True))
          self.enc1 = nn.Sequential(nn.MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1),
                                    m.layer1)  # 256
          self.enc2 = m.layer2  # 512
          self.enc3 = m.layer3  # 1024
          self.enc4 = m.layer4  # 2048
  
  
  # split the model to encoder and decoder for fast.ai
  split_layers = lambda m: [list(m.enc0.parameters()) + list(m.enc1.parameters()) +
                            list(m.enc2.parameters()) + list(m.enc3.parameters()) +
                            list(m.enc4.parameters()),
                            list(m.aspp.parameters()) + list(m.dec4.parameters()) +
                            list(m.dec3.parameters()) + list(m.dec2.parameters()) +
                            list(m.dec1.parameters()) + list(m.fpn.parameters()) +
                            list(m.final_conv.parameters())]
  
  dice = Dice_th_pred(np.arange(0.2, 0.7, 0.01))
  for fold in range(nfolds):
      for idx, row in tqdm(df_sample.iterrows(), total=len(df_sample)):
          idx = str(row['id'])
          data = ImageDataLoaders.from_dsets(ds_t, ds_v, bs=bs, num_workers=NUM_WORKERS, pin_memory=True).cuda()
          model = UneXt50().cuda()
          learn = Learner(data, model, loss_func=symmetric_lovasz, metrics=[Dice_soft(), Dice_th()],
                          splitter=split_layers).to_fp16()
  
          # start with training the head
          learn.freeze_to(-1)   
  </code></pre>
  <p>Traceback:</p>
  <pre><code>Using cache found in /root/.cache/torch/hub/facebookresearch_semi-supervised-ImageNet1K-models_master
  ---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  /tmp/ipykernel_33/1067530021.py in &lt;module&gt;
       10 
       11         #start with training the head
  ---&gt; 12         learn.freeze_to(-1) 
       13         for param in learn.opt.param_groups[0]['params']:
       14             param.requires_grad = False
  
  /opt/conda/lib/python3.7/site-packages/fastai/learner.py in freeze_to(self, n)
      575 @patch
      576 def freeze_to(self:Learner, n):
  --&gt; 577     if self.opt is None: self.create_opt()
      578     self.opt.freeze_to(n)
      579     self.opt.clear_state()
  
  /opt/conda/lib/python3.7/site-packages/fastai/learner.py in create_opt(self)
      151             if 'lr' in self.opt_func.keywords:
      152                 self.lr = self.opt_func.keywords['lr']
  --&gt; 153         self.opt = self.opt_func(self.splitter(self.model), lr=self.lr)
      154         if not self.wd_bn_bias:
      155             for p in self._bn_bias_state(True ): p['do_wd'] = False
  
  /tmp/ipykernel_33/2513745382.py in &lt;lambda&gt;(m)
       92 #split the model to encoder and decoder for fast.ai
       93 split_layers = lambda m: [
  ---&gt; 94                 list(m.encoder.parameters()),
       95                 list(m.aspp.parameters())+list(m.dec4.parameters())+
       96                 list(m.dec3.parameters())+list(m.dec2.parameters())+
  
  /opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py in __getattr__(self, name)
     1184                 return modules[name]
     1185         raise AttributeError(&quot;'{}' object has no attribute '{}'&quot;.format(
  -&gt; 1186             type(self).__name__, name))
     1187 
     1188     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -&gt; None:
  
  AttributeError: 'UneXt50' object has no attribute 'encoder'
  </code></pre>