Add layers to ResNet18

username: Beginwithtorch
cooked: <p>Hello everyone for my research I have to make some experiments with a Git-Repo.</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://github.com/lafeat/apbench">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" width="32" height="32">

      <a href="https://github.com/lafeat/apbench" target="_blank" rel="noopener nofollow ugc">GitHub</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/344;"><img src="https://opengraph.githubassets.com/091206d54c76f9e7dc2fcb657aa48fba62dbb219feb3eb36bd97d14c77c5f71c/lafeat/apbench" class="thumbnail" width="690" height="345"></div>

<h3><a href="https://github.com/lafeat/apbench" target="_blank" rel="noopener nofollow ugc">GitHub - lafeat/apbench</a></h3>

  <p>Contribute to lafeat/apbench development by creating an account on GitHub.</p>


  </article>

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

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

<p>So I should Experiment with the project where I add additional layers to the ResNet18 and try some different activation-functions. They almost use relu.<br>
To be honest im not good with PyTorch, I just have some experience with Yolo and that’s it.</p>
<p>Can you guys help me to solve this task?</p>

username: ptrblck
cooked: <p>Could you describe where exactly you are stuck and what kind of assignment this is? I’m more than happy to help you out in case you are stuck at a specific point or don’t understand some PyTorch ops, but we should not solve homework or other assignments.</p>

username: Beginwithtorch
cooked: <aside class="quote no-group" data-username="ptrblck" data-post="2" data-topic="193393">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p>you describe where exactly you are stuck and what kind of assignment this is? I’m more than happy to help you out in case you are stuck at a specific point or don’t understand some PyTorch ops, but we should not solve homework or other assignments.</p>
</blockquote>
</aside>
<p>You got it wrong, I don’t want you to do the entire task for me, I have read up on how to add additional layers. But when I look at the Git project, there are several ResNet files. And I don’t know which one I need to edit</p>

username: ptrblck
cooked: <p>Which model definitions are you using? I would start by checking your imports to check which file needs to be edited.</p>

username: Beginwithtorch
cooked: <p>What did you mean with definitions.<br>
So I almost know that I have modify the train.py and I think the resent.py but the thing what confuses me is, that in the resnet.pay are many models see picture<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/e/3e9ed9738def6aa1c29d13b4e8f1cd5485d21691.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/3e9ed9738def6aa1c29d13b4e8f1cd5485d21691" title="IMG_0440"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3e9ed9738def6aa1c29d13b4e8f1cd5485d21691_2_230x500.jpeg" alt="IMG_0440" data-base62-sha1="8VXW3Ph70mBXsbN7YhD63AAGoBb" width="230" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3e9ed9738def6aa1c29d13b4e8f1cd5485d21691_2_230x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3e9ed9738def6aa1c29d13b4e8f1cd5485d21691_2_345x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3e9ed9738def6aa1c29d13b4e8f1cd5485d21691_2_460x1000.jpeg 2x" data-dominant-color="E2E1E2"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">IMG_0440</span><span class="informations">1125×2436 271 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: ptrblck
cooked: <p>Somewhere in your code you are most likely defining <code>model = resnet()</code> where <code>resnet</code> would correspond to the model definition. Search for this <code>class</code> in your source files and check which modules are used internally to understand what needs to be changed.</p>

username: Beginwithtorch
cooked: <p>Please correct me if I am wrong. In this project several models and attacks are tested.<br>
When I run the Train.py I also have to select the architecture (see picture)<br>
Normally I would have to add the argument r18mod to the Train.pay and put this model in the folder nets ?</p>

username: Beginwithtorch
cooked: <p>So i have solve it.<br>
But now I don’t know why the train.py don’t use the total gpu power</p>

username: Beginwithtorch
cooked: <p>I’m about to go crazy. Yesterday everything worked perfectly and today it doesn’t even though I haven’t changed anything since then. The training is always stuck at epoch 0.</p>
<p>here is my loader:</p>
<pre><code class="lang-auto">def get_loader(args, train_dataset, test_dataset):
    if args.dataset == "imagenet100":
        train_loader = torch.utils.data.DataLoader(
            train_dataset, batch_size=args.bs, shuffle=True, num_workers=4, drop_last=True
        )
        test_loader = torch.utils.data.DataLoader(
            test_dataset, batch_size=args.bs, shuffle=True, num_workers=4
        )
    else:
        train_loader = torch.utils.data.DataLoader(
            train_dataset, batch_size=args.bs, shuffle=False, num_workers=8, drop_last=True
        )
        test_loader = torch.utils.data.DataLoader(
            test_dataset, batch_size=args.bs, shuffle=False, num_workers=8
        )
    return train_loader, test_loader
</code></pre>