How to design an ANN with the help of keras?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

How to design an ANN with the help of keras?

How to design an ANN with the help of keras?

This recipe helps you design an ANN with the help of keras

0

Recipe Objective

How to design an ANN with the help of keras?

ANN stands for *Artificial neural networks*. In this we create models that are inspired by the human brains and process the information similarly to it.

Step 1- Importing Libraries

import numpy as np from tensorflow import keras from tensorflow.keras import layers from keras.models import Sequential from keras.layers import Dense

Step 2- Load the dataset.

# the data, split between train and test sets (x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()

Step 3- preprocess the dataset.

num_classes = 10 input_shape = (28, 28, 1) X_train = x_train.astype("float32") / 255 X_test = x_test.astype("float32") / 255 X_train = np.expand_dims(X_train, -1) X_test = np.expand_dims(X_test, -1) y_train = keras.utils.to_categorical(y_train, num_classes) y_test = keras.utils.to_categorical(y_test, num_classes)

Step 4- Create the model

model = keras.Sequential( [ keras.Input(shape=input_shape), layers.Conv2D(32, kernel_size=(2, 2), activation="relu"), layers.Conv2D(64, kernel_size=(2, 2), activation="sigmoid"), layers.Flatten(), layers.Dropout(0.1), layers.Dense(num_classes, activation="softmax"), ] ) model.summary()

Step 5- Fit the DataSet.

batch_size = 128 epochs = 5 model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"]) model.fit(x_train, y_train, batch_size=batch_size, epochs=epochs, validation_split=0.1)

Relevant Projects

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
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.

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

Choosing the right Time Series Forecasting Methods
There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Solving Multiple Classification use cases Using H2O
In this project, we are going to talk about H2O and functionality in terms of building Machine Learning models.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.