Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
The Deep Learning Workshop

You're reading from   The Deep Learning Workshop Learn the skills you need to develop your own next-generation deep learning models with TensorFlow and Keras

Arrow left icon
Product type Paperback
Published in Jul 2020
Publisher Packt
ISBN-13 9781839219856
Length 474 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (5):
Arrow left icon
Nipun Sadvilkar Nipun Sadvilkar
Author Profile Icon Nipun Sadvilkar
Nipun Sadvilkar
Thomas Joseph Thomas Joseph
Author Profile Icon Thomas Joseph
Thomas Joseph
Anthony So Anthony So
Author Profile Icon Anthony So
Anthony So
Mohan Kumar Silaparasetty Mohan Kumar Silaparasetty
Author Profile Icon Mohan Kumar Silaparasetty
Mohan Kumar Silaparasetty
Mirza Rahim Baig Mirza Rahim Baig
Author Profile Icon Mirza Rahim Baig
Mirza Rahim Baig
+1 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface
1. Building Blocks of Deep Learning 2. Neural Networks FREE CHAPTER 3. Image Classification with Convolutional Neural Networks (CNNs) 4. Deep Learning for Text – Embeddings 5. Deep Learning for Sequences 6. LSTMs, GRUs, and Advanced RNNs 7. Generative Adversarial Networks Appendix

2. Neural Networks

Activity 2.01: Build a Multilayer Neural Network to Classify Sonar Signals

Solution

Let's see how the solution looks. Remember—this is one solution, but there could be many variations:

  1. Import all the required libraries:
    import tensorflow as tf
    import pandas as pd
    from sklearn.preprocessing import LabelEncoder
    # Import Keras libraries
    from tensorflow.keras.models import Sequential
    from tensorflow.keras.layers import Dense
  2. Load and examine the data:
    df = pd.read_csv('sonar.csv')
    df.head()

    The output is:

    Figure 2.37: Contents of sonar.csv

    Observe that there are 60 features, and the target has two values—Rock and Mine.

    This means that this is a binary classification problem. Let's prepare the data before we build the neural network.

  3. Separate the features and the labels:
    X_input = df.iloc[:, :-1]
    Y_label = df['Class'].values

    In this code, X_input is selecting all the rows of all the columns except the Class...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime