Try to understand interssection over union from scratch

username: PytorchLearning
cooked: <p>Hi all,</p>
<p>I am trying to understand yolo v1 using pytorch from scratch. I have seen several codes how to code iou (interssection over union). In kaggle i found an example I try to understand it, here is the link:</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://www.kaggle.com/code/vexxingbanana/yolov1-from-scratch-pytorch/notebook">
  <header class="source">
      <img src="https://www.kaggle.com/static/images/favicon.ico" class="site-icon" width="32" height="32">

      <a href="https://www.kaggle.com/code/vexxingbanana/yolov1-from-scratch-pytorch/notebook" target="_blank" rel="noopener nofollow ugc">kaggle.com</a>
  </header>

  <article class="onebox-body">
    <img src="https://storage.googleapis.com/kaggle-avatars/thumbnails/default-thumb.png" class="thumbnail onebox-avatar" width="160" height="160">

<h3><a href="https://www.kaggle.com/code/vexxingbanana/yolov1-from-scratch-pytorch/notebook" target="_blank" rel="noopener nofollow ugc">YoloV1 From Scratch - Pytorch</a></h3>

  <p>Explore and run machine learning code with Kaggle Notebooks | Using data from Fruit Images for Object Detection</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>My questions are:<br>
What mean the three dots … founded in box1_x1 = boxes_preds[…, 0:1]</p>
<p>And can we write this instruction differently? Because I can’t find any examples in python or pytorch that contain three dots.</p>
<p>Many thanks in advance for your help.</p>

username: Matias_Vasquez
cooked: <p>This is a python constant.</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://docs.python.org/3/library/constants.html">
  <header class="source">
      <img src="https://docs.python.org/3/_static/py.svg" class="site-icon" width="16" height="16">

      <a href="https://docs.python.org/3/library/constants.html" target="_blank" rel="noopener nofollow ugc">Python documentation</a>
  </header>

  <article class="onebox-body">
    <img width="200" height="200" src="https://docs.python.org/3/_static/og-image.png" class="thumbnail onebox-avatar">

<h3><a href="https://docs.python.org/3/library/constants.html" target="_blank" rel="noopener nofollow ugc">Built-in Constants</a></h3>

  <p>A small number of constants live in the built-in namespace. They are: Constants added by the site module: The site module (which is imported automatically during startup, except if the-S command-li...</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>You can even print this constant</p>
<pre data-code-wrap="python"><code class="lang-python"># Try this
print(...)
# Output
# Ellipsis
</code></pre>
<p>You can use this for indexing, as way of saying “I don´t care”, thus accepting stuff with different dimensions.</p>
<p>In pytorch it would be the same when you put <strong>-1</strong> in view, for example.</p>
<pre data-code-wrap="python"><code class="lang-python">tensor = torch.rand(1, 2, 3, 4, 5)
print(tensor.view(-1, 2, 3, 4, 5).shape)
print(tensor.view(-1, 3, 4, 5).shape)
print(tensor.view(-1, 4, 5).shape)
print(tensor.view(-1, 5).shape)
print(tensor.view(-1).shape)
# Output
# torch.Size([1, 2, 3, 4, 5])
# torch.Size([2, 3, 4, 5])
# torch.Size([6, 4, 5])
# torch.Size([24, 5])
# torch.Size([120])
</code></pre>
<aside class="quote no-group" data-username="PytorchLearning" data-post="1" data-topic="148271">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/p/d2c977/48.png" class="avatar"> PytorchLearning:</div>
<blockquote>
<p>I can’t find any examples in python or pytorch that contain three dots.</p>
</blockquote>
</aside>
<p><a href="https://note.nkmk.me/en/python-numpy-ellipsis/" rel="noopener nofollow ugc">Here</a> are some examples to get yourself familiar with this.</p>
<p>But this is a useful and robust way to accept stuff with many different dimensions and address the thing that you actually want.</p>
<p>Hope this helps <img src="https://discuss.pytorch.org/images/emoji/apple/smile.png?v=12" title=":smile:" class="emoji" alt=":smile:" loading="lazy" width="20" height="20"></p>

username: PytorchLearning
cooked: <p>Hi <a class="mention" href="/u/matias_vasquez">@Matias_Vasquez</a>,</p>
<p>Thanks a lot for the explanation and for the examples. <img src="https://discuss.pytorch.org/images/emoji/apple/slightly_smiling_face.png?v=12" title=":slightly_smiling_face:" class="emoji" alt=":slightly_smiling_face:" loading="lazy" width="20" height="20"></p>
<p>Now I understand it very well.</p>