AttributeError: 'Tensor' object has no attribute 'tensors'

username: tanabe.d.zc32s
cooked: <p>Hi</p>
<p>I have built and tried to train a custom model based on Faster R-CNN, but I got the error in the title.</p>
<p>The error message is attached.</p>
<p>From this, I guess I need to adjust the code on the package side, such as anchor_utils.py. What is the possible solution?</p>
<p>I would appreciate your answer.</p>
<p>Thank you for your time.</p>
<pre><code class="lang-auto">---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:\Users\TANABE~1\AppData\Local\Temp/ipykernel_19356/445376774.py in &lt;module&gt;
     14         x2 = [{k: v.to(device) for k, v in t.items()} for t in j]
     15 
---&gt; 16         loss_dict = model(x1, x2)
     17 
     18         losses = sum(loss for loss in loss_dict.values())

C:\anaconda\envs\pytorch-gpu\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
   1100         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1101                 or _global_forward_hooks or _global_forward_pre_hooks):
-&gt; 1102             return forward_call(*input, **kwargs)
   1103         # Do not call functions when jit is used
   1104         full_backward_hooks, non_full_backward_hooks = [], []

C:\Users\TANABE~1\AppData\Local\Temp/ipykernel_19356/3481601504.py in forward(self, images, targets)
     43 
     44         features = self.backbone(images)
---&gt; 45         pred_bbox = self.rpn(images, features, targets)
     46         pred_label, pred_leaf_age = self.roi_heads(features, pred_bbox, targets)
     47 

C:\anaconda\envs\pytorch-gpu\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
   1100         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1101                 or _global_forward_hooks or _global_forward_pre_hooks):
-&gt; 1102             return forward_call(*input, **kwargs)
   1103         # Do not call functions when jit is used
   1104         full_backward_hooks, non_full_backward_hooks = [], []

C:\anaconda\envs\pytorch-gpu\lib\site-packages\torchvision\models\detection\rpn.py in forward(self, images, features, targets)
    342         features = list(features.values())
    343         objectness, pred_bbox_deltas = self.head(features)
--&gt; 344         anchors = self.anchor_generator(images, features)
    345 
    346         num_images = len(anchors)

C:\anaconda\envs\pytorch-gpu\lib\site-packages\torch\nn\modules\module.py in _call_impl(self, *input, **kwargs)
   1100         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1101                 or _global_forward_hooks or _global_forward_pre_hooks):
-&gt; 1102             return forward_call(*input, **kwargs)
   1103         # Do not call functions when jit is used
   1104         full_backward_hooks, non_full_backward_hooks = [], []

C:\anaconda\envs\pytorch-gpu\lib\site-packages\torchvision\models\detection\anchor_utils.py in forward(self, image_list, feature_maps)
    118     def forward(self, image_list: ImageList, feature_maps: List[Tensor]) -&gt; List[Tensor]:
    119         grid_sizes = [feature_map.shape[-2:] for feature_map in feature_maps]
--&gt; 120         image_size = image_list.tensors.shape[-2:]
    121         dtype, device = feature_maps[0].dtype, feature_maps[0].device
    122         strides = [[torch.tensor(image_size[0] // g[0], dtype=torch.int64, device=device),

AttributeError: 'Tensor' object has no attribute 'tensors'

</code></pre>