MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# What is use of clone_model functions in keras why is it used?

# What is use of clone_model functions in keras why is it used?

This recipe explains what is use of clone_model functions in keras why is it used

What is the 'clone_model' function in Keras? Why is it used?

A clone mode is a model that reproduces the behavior of the original model, where we can input new tensors, with new weights to the layers. The cloned models behave differently if we customize the cloned model or we use the custom clone_function.

```
import numpy as np
import keras
from keras.models import Sequential
from keras.layers import UpSampling2D
```

We will make a model to clone.

```
# define input data
X = np.array([10, 6, 3, 20])
# show input data for context
print(X)
# reshape input data into one sample a sample with a channel
X = X.reshape((1, 2, 2, 1))
# define model
model = Sequential()
model.add(UpSampling2D(input_shape=(2, 2, 1)))
model.summary()
```

[10 6 3 20] Model: "sequential" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= up_sampling2d (UpSampling2D) (None, 4, 4, 1) 0 ================================================================= Total params: 0 Trainable params: 0 Non-trainable params: 0 _________________________________________________________________

```
#cloning of model
model_copy= keras.models.clone_model(model)
model_copy.build((None, 5)) # replace 10 with number of variables in input layer
model_copy.compile(optimizer='adam', loss='categorical_crossentropy')
model_copy.summary()
```

Model: "sequential" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= up_sampling2d (UpSampling2D) (None, 4, 4, 1) 0 ================================================================= Total params: 0 Trainable params: 0 Non-trainable params: 0 _________________________________________________________________

The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Datasetâ€‹ using Keras in Python.

Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.