How to do Fine tuning in TF learn

This recipe helps you do Fine tuning in TF learn

Recipe Objective

This recipe explains how to do fine tuning in TFLayer.

Importing Libraries

We'll import necessary libraries.

import tflearn
from tflearn.layers.estimator import regression
from tflearn.layers.conv import conv_2d, max_pool_2d
from __future__ import division, print_function, absolute_import
from tflearn.layers.core import input_data, dropout, fully_connected

Fine-tuning

By fine-tuning, a pre-trained model can be useful to us. While building a model in TFLearn, we can specify the weight of the layer we want to restore. This can be done with the 'restore' argument of layer functions.

Access Face Recognition Project Code using Facenet in Python

x, y = your_dataset()
num = 10

net = input_data(shape=[None, 32, 32, 3])
net = conv_2d(network, 32, 3, activation='relu6')
net = max_pool_2d(network, 2)
net = dropout(network, 0.75)
net = conv_2d(network, 64, 3, activation='relu6')
net = conv_2d(network, 64, 3, activation='relu6')
net = max_pool_2d(network, 2)
net = dropout(network, 0.5)
net = fully_connected(network, 512, activation='relu6')
net = dropout(network, 0.5)

softplus = fully_connected(net, num_classes, activation='softplus', restore=False)
regression = regression(softpls, optimizer='adam', loss='categorical_crossentropy', learning_rate=0.001)

m = tflearn.DNN(regression, checkpoint_path='model_finetuning', max_checkpoints=3, tensorboard_verbose=0)

m.load('cifar10_cnn')

m.fit(x, y, n_epoch=10, validation_set=0.1, shuffle=True, show_metric=True, batch_size=64, snapshot_step=200, snapshot_epoch=False, run_id='model_finetuning')

m.save('model_finetuning')

What Users are saying..

profile image

Ray han

Tech Leader | Stanford / Yale University
linkedin profile url

I think that they are fantastic. I attended Yale and Stanford and have worked at Honeywell,Oracle, and Arthur Andersen(Accenture) in the US. I have taken Big Data and Hadoop,NoSQL, Spark, Hadoop... Read More

Relevant Projects

AWS Project to Build and Deploy LSTM Model with Sagemaker
In this AWS Sagemaker Project, you will learn to build a LSTM model on Sagemaker for sales forecasting while analyzing the impact of weather conditions on Sales.

Ola Bike Rides Request Demand Forecast
Given big data at taxi service (ride-hailing) i.e. OLA, you will learn multi-step time series forecasting and clustering with Mini-Batch K-means Algorithm on geospatial data to predict future ride requests for a particular region at a given time.

Multilabel Classification Project for Predicting Shipment Modes
Multilabel Classification Project to build a machine learning model that predicts the appropriate mode of transport for each shipment, using a transport dataset with 2000 unique products. The project explores and compares four different approaches to multilabel classification, including naive independent models, classifier chains, natively multilabel models, and multilabel to multiclass approaches.

Hands-On Approach to Regression Discontinuity Design Python
In this machine learning project, you will learn to implement Regression Discontinuity Design Example in Python to determine the effect of age on Mortality Rate in Python.

Time Series Forecasting Project-Building ARIMA Model in Python
Build a time series ARIMA model in Python to forecast the use of arrival rate density to support staffing decisions at call centres.

Build a Hybrid Recommender System in Python using LightFM
In this Recommender System project, you will build a hybrid recommender system in Python using LightFM .

Time Series Forecasting with LSTM Neural Network Python
Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

Build an optimal End-to-End MLOps Pipeline and Deploy on GCP
Learn how to build and deploy an end-to-end optimal MLOps Pipeline for Loan Eligibility Prediction Model in Python on GCP

Llama2 Project for MetaData Generation using FAISS and RAGs
In this LLM Llama2 Project, you will automate metadata generation using Llama2, RAGs, and AWS to reduce manual efforts.

MLOps Project to Deploy Resume Parser Model on Paperspace
In this MLOps project, you will learn how to deploy a Resume Parser Streamlit Application on Paperspace Private Cloud.