Category Machine Learning

85. Keras Model Transfer-Learning

Load model model_A = keras.models.load_model(“model_A.h5″) Clone Architecture model_A_clone = keras.models.clone_model(model_A) Clone Weights model_A_clone.set_weights(model_A.get_weights()) Delete Last Layer model_B = keras.models.Sequential(model_A_clone.layers[:-1]) Add Final layer => Change to Binary classifier model_B.add(keras.layers.Dense(1, activation=”sigmoid”)) You can prevent copied layers to be affected when training for…

84. Keras Model Hyper-parameter Tuning

One way to tune your keras model is using random search. Here is one example with sklearn. from scipy.stats import reciprocal from sklearn.model_selection import RandomizedSearchCV #Specify range for random initialization param_distribs = { “n_hidden”: [0, 1, 2, 3], “n_neurons”: np.arange(1,…

81. ML Project Workflow

There are 8 main steps: Frame Problem and Look at the Big Picture Get Data Explore data to gain insights Prepare the data to better expose the underlying data patterns to Machine Learning Algorithms Explore many different models and shortlist…

80. Shift in Recommendation Filtering

Over the last several years, there has been a trend in recommendation systems shifting from COLLABORATIVE FILTERING to CONTENT-BASED FILTERING. Each workflow are the following. Let’s say we want to recommend a restaurant to a user. Collaborative Filtering 1. looks…

79. Generate TensorRT Engine with Unet

Here is 1 way to Generate an engine file with Unet Pre-requisites – Deepstream 5.0.1 – TensorRT 7.1.3 – Jetson XAVIER NX – CUDA 10.2 Load Model import torch unet = torch.hub.load(‘milesial/Pytorch-UNet’, ‘unet_carvana’, pretrained=True) unet.eval() Export Model path_to_onnx =”” dummy…

75. MLOps Deployment Example

Let’s say we want to detect whether there are any scratches on a smartphone(Example from MLops Specialization by Andrew NG). In this case, MLops would go something like this. Fig.1 – MLOps Capture Image of Smartphone The Inspection software inside…

74. Visualize Your ONNX model using Netron

Just simply, go to the link and select the onnx model you want to visualize. When converting your model, for example, TENSORFLOW1 ⇒ tensorRT engine You may want to check your input/output dimensions in case something unexpected is happening when…

71. The Drivetrain Approach

To make sure the model you are creating is actually practical, there is method called the Drivetrain Approach introduced by Jeremy Howard. The steps are the following: Defined Approach- What outcome am I trying to achieve? Levers – What inputs…