Stats for training time and accuracy

username: shangguan91
cooked: <p>Dear all,</p>
<p>Firstly, i want to get the total time of running 100 epoch, what would be the best code?</p>
<p>Second, what is the final accuracy result for running 100 epoch. is the best test/validation result on certain epoch?<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/7/179ca0ba27275c4e2a5beeb9666829449e9e2aba.png" data-download-href="https://discuss.pytorch.org/uploads/default/179ca0ba27275c4e2a5beeb9666829449e9e2aba" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/1/7/179ca0ba27275c4e2a5beeb9666829449e9e2aba.png" alt="image" data-base62-sha1="3mSyr2lADZG2v6fHgVvC4izOxfQ" width="690" height="478" data-dominant-color="F0F0F0"><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">image</span><span class="informations">752×521 9.89 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: RaLo4
cooked: <p>for the first question:<br>
maybe something like:</p>
<pre><code class="lang-auto">import time
training_start_time = time.time()
#train your 100 epochs
print('Training finished, took {:.2f}s'.format(time.time() - training_start_time))
</code></pre>
<p>for the second question:<br>
It kinda depends. If you want to get the best accuracy you can take it from a specific epoch. You can also calculate averages. Even the way my calculate accuracy can differ. You can, for example, take top1 accuracy or top5 accuracy. It’s really up to you</p>

username: shangguan91
cooked: <p>i had right now four model running, as sample of my data is not that large, the best acc is all 0.9, which means nothing, should i get a overall accuracy of 100 epoch?</p>
<p>This is a <a href="https://paperswithcode.com/paper/dynamic-graph-cnn-for-learning-on-point/review/?hl=17002" rel="nofollow noopener">https://paperswithcode.com/paper/dynamic-graph-cnn-for-learning-on-point/review/?hl=17002</a>, how they evaluate the model acc. Do you know the formular of that?</p>

username: shangguan91
cooked: <p>thank you, but where should i put the training_start_time?</p>
<p>This is how i normally sum up my train time</p>
<pre><code class="lang-auto">dur = []
for epoch in range(1, 100):
    t0 = time.time()
    train(epoch)
    train_acc = test(train_loader)
    test_acc = test(test_loader)
  

    
    dur.append(time.time() - t0)

    print('Epoch: {:03d}, Train: {:.4f}, Test: {:.4f},Time(s) {:.4f}'.format(epoch,train_acc,test_acc,np.mean(dur)))
</code></pre>
<p>when i use your code, it isn’t working<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/1/81cc4b8922a3fc599c36e9e6bf4ce7ba08425e78.png" data-download-href="https://discuss.pytorch.org/uploads/default/81cc4b8922a3fc599c36e9e6bf4ce7ba08425e78" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/8/1/81cc4b8922a3fc599c36e9e6bf4ce7ba08425e78_2_690x156.png" alt="image" data-base62-sha1="iwfidvPGcM2bBbuTq1qXlEJpSfS" width="690" height="156" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/8/1/81cc4b8922a3fc599c36e9e6bf4ce7ba08425e78_2_690x156.png, https://discuss.pytorch.org/uploads/default/optimized/3X/8/1/81cc4b8922a3fc599c36e9e6bf4ce7ba08425e78_2_1035x234.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/8/1/81cc4b8922a3fc599c36e9e6bf4ce7ba08425e78_2_1380x312.png 2x" data-dominant-color="F7F7F7"><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">image</span><span class="informations">1536×348 15 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: RaLo4
cooked: <p>I checked the paper you linked. But they didn’t specify anything.<br>
The shown results are:<br>
<strong>Mean Per Class Accuracy:</strong> average of the accuracies of each class in your multi-class data set<br>
<strong>Overall Accuracy:</strong> Your normal overall accuracy across all classes<br>
Where there are measured/calculated is not specified</p>

username: RaLo4
cooked: <pre><code class="lang-auto">dur = []
training_start_time = time.time()
for epoch in range(1, 100):
    t0 = time.time()
    train(epoch)
    train_acc = test(train_loader)
    test_acc = test(test_loader)
  

    
    dur.append(time.time() - t0)

    print('Epoch: {:03d}, Train: {:.4f}, Test: {:.4f},Time(s) {:.4f}'.format(epoch,train_acc,test_acc,np.mean(dur)))
print('Training finished, took {:.2f}s'.format(time.time() - training_start_time))
</code></pre>

username: RaLo4
cooked: <p>Not directly related to your initial question, but if you want a more fancy way of tracking your training you can look into <a href="https://pytorch.org/tutorials/intermediate/tensorboard_tutorial.html" rel="nofollow noopener">this</a>.</p>

username: shangguan91
cooked: <p>Thank you so much!!!</p>

username: shangguan91
cooked: <aside class="quote no-group" data-username="RaLo4" data-post="6" data-topic="90786">
<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/r/65b543/48.png" class="avatar"> RaLo4:</div>
<blockquote>
<pre><code class="lang-auto">dur = []
training_start_time = time.time()
</code></pre>
</blockquote>
</aside>
<p>and do you happen to know the way to save accuracy for each epoch, so i can load and calculate average later?</p>