Use previously implemented ML models — ML Practitioner Quick bits

Anas R.
3 min readFeb 12, 2022

--

From (https://twitter.com/DeepLearningAI_) — NEVER HAPPENS

When it comes to implementing a machine learning model, it can often be a frustrating process. Whether it’s getting the model to work with a specific framework, adapting it for a different type of data, or simply getting it to perform well, there are a multitude of obstacles that can arise. However, there are some steps you can take to help streamline the process and make it more successful.

Step 1: Implement the previous code as is. The first step is to copy and paste the code for the model you’re working with and get it running. This will help you to get a sense of how the model is structured and what its dependencies are. To minimize setup issues, try using a platform like Google Colab, which requires minimal setup and is less prone to distractions.

Step 2: Understand individual parts of the model. Many models are divided into separate parts, such as a patch extractor module, a patch embedding module, and an attention module. Try to understand how data points are transformed from one module to another by looking at the shapes of the data at each step. This will give you a better understanding of what the model is actually doing.

Step 3: Determine what needs to be changed for your problem. For example, if the model is implemented for images and you want to adapt it for videos, you may need to add an extra dimension to account for the time component. This could involve changing convolution from 2D to 3D, or using a time-distributed image feature extractor.

Step 4: Simulate the dataset and change every single piece. Create a dataset that returns random tensors of the same shape as your data. This will allow you to test the model and make any necessary changes without having to work with a large amount of real data. Keep in mind framework specificities such as image format and input/output shapes.

Step 5: Forward pass on a small piece of real data. Before running the model on all of your data, test it on a small sample to ensure that it is working correctly. This will help you to identify any discrepancies between the simulated dataset and the real data, and make any necessary adjustments.

Step 6: Choose appropriate loss, optimizers and metrics. Your problem may be different from others, so it’s important to choose the right loss function, optimizer, and metrics that are appropriate for your specific task.

Step 7: Test it more. Once you have the model running, continue to test it and make adjustments as needed. This may include changing the data preprocessing, applying augmentations, or adjusting model hyperparameters. Always keep in mind that everything can be improved, so don’t be afraid to experiment and try new things.

By following these steps, you can help to streamline the process of implementing a machine-learning model and increase the chances of success. Remember to keep the engineer in you awake, always be curious, and don’t hesitate to share your feedback.

--

--