Efficient Coding in Python
Learn efficient ways to write code in Python
We'll cover the following
Almost all of the popular deep learning tools (PyTorch, TensorFlow, Keras, MXNet, and so on) are written in Python. Python is easy to learn and easy to use, especially compared to other object-oriented programming (OOP) languages such as C++ and Java. However, using Python does not excuse us from lazy coding. We should never settle with it works. In deep learning, efficient code may save us hours of training time. In this section, we will give some tips and advice on writing efficient Python projects.
Reinventing the wheel wisely
Innovative developers are not enthusiastic about reinventing the wheel, that is, implementing every tiny component in the project that can be easily grabbed from GitHub or third-party libraries. Deep learning relies on being open source and anyone in the world can learn and do cool things with it. We encourage taking advantage of any available tool we can find to solve our practical problems as long as it saves us invaluable time.
Some of the model implementations in this course come from other people’s projects on GitHub. Imagine how long it would take us to figure out all the implementation details based on the papers that have already been published!
Advice for beginners in deep learning
The following is some advice that beginners in deep learning should definitely follow:
Set reasonable but solid goals and deadlines: Give yourself plenty of time to research, learn, and experiment with a subject. Start with the goal and then create a series of steps that will achieve that goal. Keep a log of your progress.
Search the web to find information on the project you are working on: The internet is often the fastest way to gather information about a particular subject. Start with simple but direct search text and then refine your searches to obtain the best resources.
Small steps are better than huge leaps: As you read an article or chapter on your subject of choice, copy the code into your IDE and run the project. Don’t move on until you understand the inputs, outputs, and the code that produces them.
Try to find pre-trained models: Once you have the basic information and understand the model process, use pre-trained models to save time and hardware resources. Again, keep the results in your log.
Take the results from your searches and experiment on your own: It’s likely that you will gather ideas about the subject as you do your research and testing. Jot them down and test your ideas against what you have learned.
Get the best hardware that you can afford without breaking the bank: This is probably the most important tip. A good computer with a good graphics card and GPU with as much memory as possible will potentially cut hours off your process.
Get hands-on with 1400+ tech skills courses.