Discover and compare top software alternatives, find the best fit for your needs, and explore the latest trends in software solutions.
while True: learn() is a Python coding pattern often used when training machine learning models. The while True: creates an infinite loop so that the code inside the loop will run continuously. The learn() portion runs whatever machine learning code is inside, typically model.fit() or something similar to train the model.
This allows a machine learning model like a neural network to train indefinitely, until some other condition is met like reaching a certain accuracy level, instead of just running for a set number of epochs. As models like neural nets benefit from very long training times, letting them train inside an infinite while loop allows them to keep improving for as long as computationally feasible.
Some downsides are that it could potentially train for too long and start overfitting. So it's common to check inside the loop whether a desired accuracy or loss threshold was reached and break out when it has trained 'enough'. But overall while True: learn() is very useful for state-of-the-art deep learning models that benefit from very long train times.
Here are some alternatives to While True: learn():
Suggest an alternative ❐