This PR refactors the training loop from a script to a class in order to improve modularity, readability, and testability. The training loop, which was previously located in the main.py file, has been encapsulated within a new class named MNISTTrainer. This class has methods for loading the MNIST data, preprocessing it, and training the model. The api.py file has also been updated to import the MNISTTrainer class instead of the Net class.
Summary of Changes
Created a new class named MNISTTrainer in main.py
Moved the code for loading the MNIST data into a method named load_data
Moved the code for defining the model into a method named define_model
Created a new method named train_model for training the model
Created a new method named run to run the entire training process
Updated the script in main.py to create an instance of MNISTTrainer and call the run method
Updated the import statement in api.py to import the MNISTTrainer class
Updated the code in api.py to create an instance of MNISTTrainer and call the run method
Fixes #6.
🎉 Latest improvements to Sweep:
Sweep can now passively improve your repository! Check out Rules to learn more.
💡 To get Sweep to edit this pull request, you can:
Comment below, and Sweep can edit the entire PR
Comment on a file, Sweep will only modify the commented file
Edit the original issue to get Sweep to recreate the PR from scratch
Description
This PR refactors the training loop from a script to a class in order to improve modularity, readability, and testability. The training loop, which was previously located in the
main.py
file, has been encapsulated within a new class namedMNISTTrainer
. This class has methods for loading the MNIST data, preprocessing it, and training the model. Theapi.py
file has also been updated to import theMNISTTrainer
class instead of theNet
class.Summary of Changes
MNISTTrainer
inmain.py
load_data
define_model
train_model
for training the modelrun
to run the entire training processmain.py
to create an instance ofMNISTTrainer
and call therun
methodapi.py
to import theMNISTTrainer
classapi.py
to create an instance ofMNISTTrainer
and call therun
methodFixes #6.
🎉 Latest improvements to Sweep:
💡 To get Sweep to edit this pull request, you can: