100% found this document useful (2 votes)
21 views

Applied Neural Networks with TensorFlow 2 API Oriented Deep Learning with Python 1st Edition Orhan Gazi Yalcın Yalçın Orhan instant download

The document is about the book 'Applied Neural Networks with TensorFlow 2 API Oriented Deep Learning with Python' by Orhan Gazi Yalçın, which covers deep learning concepts and case studies. It includes topics such as machine learning, neural networks, and various applications like image recognition and recommender systems. The book also provides supplementary materials available on GitHub and is published by Apress.

Uploaded by

dufaunaehu5y
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
21 views

Applied Neural Networks with TensorFlow 2 API Oriented Deep Learning with Python 1st Edition Orhan Gazi Yalcın Yalçın Orhan instant download

The document is about the book 'Applied Neural Networks with TensorFlow 2 API Oriented Deep Learning with Python' by Orhan Gazi Yalçın, which covers deep learning concepts and case studies. It includes topics such as machine learning, neural networks, and various applications like image recognition and recommender systems. The book also provides supplementary materials available on GitHub and is published by Apress.

Uploaded by

dufaunaehu5y
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

Applied Neural Networks with TensorFlow 2 API

Oriented Deep Learning with Python 1st Edition


Orhan Gazi Yalc■n Yalç■n Orhan pdf download

https://textbookfull.com/product/applied-neural-networks-with-
tensorflow-2-api-oriented-deep-learning-with-python-1st-edition-
orhan-gazi-yalcin-yalcin-orhan/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Applied Neural Networks with TensorFlow 2 API Oriented


Deep Learning with Python 1st Edition Orhan Gazi Yalc■n
Yalç■n Orhan

https://textbookfull.com/product/applied-neural-networks-with-
tensorflow-2-api-oriented-deep-learning-with-python-1st-edition-
orhan-gazi-yalcin-yalcin-orhan/

Deep Learning Projects Using TensorFlow 2: Neural


Network Development with Python and Keras 1st Edition
Vinita Silaparasetty

https://textbookfull.com/product/deep-learning-projects-using-
tensorflow-2-neural-network-development-with-python-and-
keras-1st-edition-vinita-silaparasetty/

Artificial Neural Networks with TensorFlow 2: ANN


Architecture Machine Learning Projects Poornachandra
Sarang

https://textbookfull.com/product/artificial-neural-networks-with-
tensorflow-2-ann-architecture-machine-learning-projects-
poornachandra-sarang/

Deep Learning with JavaScript Neural networks in


TensorFlow js 1st Edition Shanqing Cai Stanley Bileschi
Eric D Nielsen

https://textbookfull.com/product/deep-learning-with-javascript-
neural-networks-in-tensorflow-js-1st-edition-shanqing-cai-
stanley-bileschi-eric-d-nielsen/
Applied Reinforcement Learning with Python: With OpenAI
Gym, Tensorflow, and Keras Beysolow Ii

https://textbookfull.com/product/applied-reinforcement-learning-
with-python-with-openai-gym-tensorflow-and-keras-beysolow-ii/

Deep Learning with Python Develop Deep Learning Models


on Theano and TensorFLow Using Keras Jason Brownlee

https://textbookfull.com/product/deep-learning-with-python-
develop-deep-learning-models-on-theano-and-tensorflow-using-
keras-jason-brownlee/

Deep Learning with JavaScript: Neural networks in


TensorFlow.js 1st Edition Shanqing Cai

https://textbookfull.com/product/deep-learning-with-javascript-
neural-networks-in-tensorflow-js-1st-edition-shanqing-cai/

Learn Keras for Deep Neural Networks: A Fast-Track


Approach to Modern Deep Learning with Python 1st
Edition Jojo John Moolayil

https://textbookfull.com/product/learn-keras-for-deep-neural-
networks-a-fast-track-approach-to-modern-deep-learning-with-
python-1st-edition-jojo-john-moolayil/

MATLAB Deep Learning: With Machine Learning, Neural


Networks and Artificial Intelligence 1st Edition Phil
Kim

https://textbookfull.com/product/matlab-deep-learning-with-
machine-learning-neural-networks-and-artificial-intelligence-1st-
edition-phil-kim/
Orhan Gazi Yalçın

Applied Neural Networks with


TensorFlow 2
API Oriented Deep Learning with Python
1st ed.
Orhan Gazi Yalçın
Istanbul, Turkey

Any source code or other supplementary material referenced by the


author in this book is available to readers on GitHub via the book’s
product page, located at www.​apress.​com/​978-1-4842-6512-3. For
more detailed information, please visit http://​www.​apress.​com/​
source-code.

ISBN 978-1-4842-6512-3 e-ISBN 978-1-4842-6513-0


https://doi.org/10.1007/978-1-4842-6513-0

Apress Standard
© Orhan Gazi Yalçın 2021

This work is subject to copyright. All rights are reserved by the


Publisher, whether the whole or part of the material is concerned,
specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other
physical way, and transmission or information storage and retrieval,
electronic adaptation, computer software, or by similar or dissimilar
methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

Distributed to the book trade worldwide by Springer Science+Business


Media New York,1 NY Plazar, New York, NY 10014. Phone 1-800-
SPRINGER, fax (201) 348-4505, e-mail [email protected],
or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media
Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware
corporation.
I dedicate this book to my overcurious dad, Lutfi – who kept sneaking into
the study room to see how far I was into the book – and to my mom, Ayşe,
for always supporting and encouraging me.
I would also like to thank my friend, Enes, for encouraging me to write
this book in the first place.
Finally, I would like to thank my sister and brother, Merve and Kürşat,
and all my friends who supported me throughout the whole process – all
the way – till the last word.
Acknowledgments
This book was written during a global lockdown due to the Covid-19
pandemic, which created a new normal that I have never experienced
before. Writing a book in the middle of a global crisis was a very intense
experience, and I was uncertain about taking this responsibility for a
long time. Thanks to my family and friends, I was able to complete the
book even earlier than scheduled. Now I am glad that I accepted
Aaron’s invitation, who guided me throughout the whole process.
Thank you very much for reaching out to me in the first place and
making it possible to have this book written.
I would like to thank Jessica Vakili for coordinating the entire
project and for being there whenever I needed. I would also like to
thank Vishwesh Ravi Shrimali for reviewing every single line of the
book and providing me with all the valuable comments, which helped
to improve the quality of the book tremendously.
Being surrounded with people who all have a positive attitude made
this experience very fruitful, and I am looking forward to working with
them in the future. Thank you all very much!
Table of Contents
Chapter 1:​Introduction
Python as Programming Language
Timeline of Python
Python 2 vs.​Python 3
Why Python?​
TensorFlow As Deep Learning Framework
Timeline of TensorFlow
Why TensorFlow?​
What’s New in TensorFlow 2.​x
TensorFlow Competitors
Installation and Environment Setup
Interactive Programming Environments:​IPython, Jupyter
Notebook, and Google Colab
IPython
Jupyter Notebook
Google Colab
Hardware Options and Requirements
Chapter 2:​Introduction to Machine Learning
What Is Machine Learning?​
Scope of Machine Learning and Its Relation to Adjacent Fields
Artificial Intelligence
Deep Learning
Data Science
Big Data
The Taxonomy Diagram
Machine Learning Approaches and Models
Supervised Learning
Unsupervised Learning
Semi-supervised Learning
Reinforcement Learning
Evaluation of Different Approaches
Steps of Machine Learning
Gathering Data
Preparing Data
Model Selection
Training
Evaluation
Hyperparameter Tuning
Prediction
Final Evaluations
Chapter 3:​Deep Learning and Neural Networks Overview
Timeline of Neural Networks and Deep Learning Studies
Structure of Artificial Neural Networks
McCulloch-Pitts Neuron
Linear Threshold Unit (LTU)
Perceptron
A Modern Deep Neural Network
Activation Functions
Loss (Cost or Error) Functions
Optimization in Deep Learning
Backpropagation
Optimization Algorithms
Optimization Challenges
Overfitting and Regularization
Overfitting
Regularization
Feature Scaling
Final Evaluations
Chapter 4:​Complementary Libraries to TensorFlow 2.​x
Installation with Pip
NumPy – Array Processing
SciPy – Scientific Computing
Pandas – Array Processing and Data Analysis
Matplotlib and Seaborn – Data Visualization
Scikit-learn – Machine Learning
Flask – Deployment
Final Evaluations
Chapter 5:​A Guide to TensorFlow 2.​0 and Deep Learning Pipeline
TensorFlow Basics
Eager Execution
Tensor
Variable
TensorFlow Deep Learning Pipeline
Data Loading and Preparation
Dataset Object (tf.​data.​Dataset)
TensorFlow Datasets Catalog
NumPy Array
Pandas DataFrame
Other Objects
Model Building
Keras API
Estimator API
Compiling, Training, and Evaluating the Model and Making
Predictions
The Standard Method
Custom Training
Saving and Loading the Model
Saving the Model
Loading the Model
Conclusion
Chapter 6:​Feedforward Neural Networks
Deep and Shallow Feedforward Neural Networks
Shallow Feedforward Neural Network
Deep Feedforward Neural Network
Feedforward Neural Network Architecture
Layers in a Feedforward Neural Network
Input Layer
Output Layer
Hidden Layer
Case Study | Fuel Economics with Auto MPG
Initial Installs and Imports
Downloading the Auto MPG Data
Data Preparation
Model Building and Training
Evaluating the Results
Making Predictions with a New Observation
Conclusion
Chapter 7:​Convolutional Neural Networks
Why Convolutional Neural Networks?​
CNN Architecture
Layers in a CNN
A Full CNN Model
Case Study | Image Classification with MNIST
Downloading the MNIST Data
Reshaping and Normalizing the Images
Building the Convolutional Neural Network
Compiling and Fitting the Model
Evaluating the Model
Saving the Trained Model
Conclusion
Chapter 8:​Recurrent Neural Networks
Sequence Data and Time-Series Data
RNNs and Sequential Data
The Basics of RNNs
The History of RNNs
Applications of RNNs
Mechanism of RNNs
RNN Types
Simple RNNs
Long Short-Term Memory (LSTM)
Gated Recurrent Units (GRUs)
Case Study | Sentiment Analysis with IMDB Reviews
Preparing Our Colab for GPU Accelerated Training
IMDB Reviews
Preparing the Dataset
Building the Recurrent Neural Network
Compiling and Fitting the Model
Evaluating the Model
Making New Predictions
Saving and Loading the Model
Conclusion
Chapter 9:​Natural Language Processing
History of NLP
Early Ideas
Rule-Based NLP
Statistical NLP and Supervised Learning
Unsupervised and Semi-supervised NLP
Real-World Applications of NLP
Major Evaluations, Techniques, Methods, and Tasks
Morphosyntax
Semantics
Discourse
Speech
Dialogue
Cognition
Natural Language Toolkit (NLTK)
Case Study | Text Generation with Deep NLP
The Goal of the Case Study
Shakespeare Corpus
Initial Imports
Loading the Corpus
Vectorize the Text
Creating the Dataset
Building the Model
Compiling and Training the Model
Generating Text with the Trained Model
Conclusion
Chapter 10:​Recommender Systems
Popular Approaches
Collaborative Filtering
Data Collection
Content-Based Filtering (Personality-Based Approach)
Other Recommender System Approaches
Case Study | Deep Collaborative Filtering with MovieLens
Dataset
MovieLens Dataset
Initial Imports
Loading the Data
Processing the Data
Splitting the Dataset
Building the Model
Compile and Train the Model
Make Recommendations
Conclusion
Chapter 11:​Autoencoders
Advantages and Disadvantages of Autoencoders
Autoencoder Architecture
Layers Used in an Autoencoder
Advantages of Depth
Variations of Autoencoders
Undercomplete Autoencoders
Regularized Autoencoders
Variational Autoencoder (VAE)
Use Cases of Autoencoders
Case Study | Image Denoising with Fashion MNIST
Fashion MNIST Dataset
Initial Imports
Loading and Processing the Data
Adding Noise to Images
Building the Model
Denoising Noisy Images
Conclusion
Chapter 12:​Generative Adversarial Network
Method
Architecture
GAN Components
A Known Issue:​Mode Collapse
Final Notes on Architecture
Applications of GANs
Art and Fashion
Manufacturing, Research, and R&​D
Video Games
Malicious Applications and Deep Fake
Miscellaneous Applications
Case Study | Digit Generation with MNIST
Initial Imports
Load and Process the MNIST Dataset
Build the GAN Model
Train the GAN Model
Animate Generated Digits During the Training
Conclusion
Index
About the Author
Orhan Gazi Yalçın
is a joint PhD candidate at the University
of Bologna and the Polytechnic
University of Madrid. After completing
his double major in business and law, he
began his career in Istanbul, working for
a city law firm, Allen & Overy, and a
global entrepreneurship network,
Endeavor. During his academic and
professional career, he taught himself
programming and excelled in machine
learning. He currently conducts research
on hotly debated law and AI topics such
as explainable artificial intelligence and
the right to explanation by combining his
technical and legal skills. In his spare
time, he enjoys free diving, swimming,
exercising, as well as discovering new countries, cultures, and cuisines.
You can visit Orhan’s personal web page at
www.orhangaziyalcin.com
Also feel free to connect with Orhan on Linkedin at
www.linkedin.com/in/orhangaziyalcin
About the Technical Reviewer
Vishwesh Ravi Shrimali
graduated from BITS Pilani in 2018, where he studied mechanical
engineering. Since then, he has worked with BigVision LLC on deep
learning and computer vision and was involved in creating official
OpenCV AI courses. Currently, he is working at Mercedes Benz Research
and Development India Pvt. Ltd. He has a keen interest in programming
and AI and has applied that interest in mechanical engineering projects.
He has also written multiple blogs on OpenCV and deep learning on
LearnOpenCV, a leading blog on computer vision. He has also
coauthored Machine Learning for OpenCV4 (second edition) by Packt.
When he is not writing blogs or working on projects, he likes to go on
long walks or play his acoustic guitar.
© Orhan Gazi Yalçın 2021
O. G. Yalçın, Applied Neural Networks with TensorFlow 2
https://doi.org/10.1007/978-1-4842-6513-0_1

1. Introduction
Orhan Gazi Yalçın1
(1) Istanbul, Turkey

In this book, we dive into the realms of deep learning (DL) and cover
several deep learning concepts along with several case studies. These
case studies range from image recognition to recommender systems,
from art generation to object clustering. Deep learning is part of a
broader family of machine learning (ML) methods based on artificial
neural networks (ANNs) with representation learning. These neural
networks mimic the human brain cells, or neurons, for algorithmic
learning, and their learning speed is much faster than human learning
speed. Several deep learning methods offer solutions to different types
of machine learning problems: (i) supervised learning, (ii)
unsupervised learning, (iii) semi-supervised learning, and (iv)
reinforcement learning.
This book is structured in a way to also include an introduction to
the discipline of machine learning so that the reader may be acquainted
with the general rules and concepts of machine learning. Then, a
detailed introduction to deep learning is provided to familiarize the
reader with the sub-discipline of deep learning.
After covering the fundamentals of deep learning, the book covers
different types of artificial neural networks with their potential real-life
applications (i.e., case studies). Therefore, at each chapter, this book (i)
introduces the concept of a particular neural network architecture with
details on its components and then (ii) provides a tutorial on how to
apply this network structure to solve a particular artificial intelligence
(AI) problem.
Since the goal of this book is to provide case studies for deep
learning applications, the competency in several technologies and
libraries is sought for a satisfactory learning experience.
Before diving into machine learning and deep learning, we start
with the introduction to the technologies used in this book. This
introduction includes the latest developments and the reasoning as to
why these technologies are selected. Finally, this chapter also covers
how to install these technologies and prepare your environment with a
minimum amount of hassle. The technologies that are in the center of
this book are as follows:
Our Selected Programming Language: Python 3.x
Our Selected Deep Learning Framework: TensorFlow 2.x
Our Development Environment: Google Colab (with Jupyter
Notebook alternative)

Note A TensorFlow Pipeline Guide showing how to use


TensorFlow can be found in Chapter 5, whereas the relevant libraries
used with TensorFlow are covered in Chapter 4.

Please note that this book assumes that you use Google Colab, which
requires almost no environment setup. The chapter also includes a local
Jupyter Notebook installation guide if you prefer a local environment.
You may skip the Jupyter Notebook installation section if you decide to
use Google Colab.

Note When learning a new programming discipline or technology,


one of the most demoralizing tasks is the environment setup
process. Therefore, it is important to simplify this process as much
as possible. Therefore, this chapter is designed with this principle in
mind.

Python as Programming Language


Python is a programming language created by Guido van Rossum as a
side project and was initially released in 1991. Python supports object-
oriented programming (OOP) , a paradigm based on the concept of
objects, which can contain data, in the form of fields. Python prioritizes
the programmer’s experience. Therefore, programmers can write clear
and logical code for both small and large projects. It also contains
support for functional programming. Python is dynamically typed and
garbage collected.
Python is also considered as an interpreted language because it
goes through an interpreter, which turns code you write into the
language understood by your computer’s processor. An interpreter
executes the statements of code “one by one.” On the other hand, in
compiled languages, a compiler executes the code entirely and lists all
possible errors at a time. The compiled code is more efficient than the
interpreted code in terms of speed and performance. However, scripted
languages such as Python show only one error message even though
your code has multiple errors. This feature helps the programmer to
clear errors quickly, and it increases the development speed.

Timeline of Python
Let’s take a look at the timeline of Python:
In the late 1980s, Python was conceived as a successor to the ABC
language.
In December 1989, Guido van Rossum started Python’s
implementation.
In January 1994, Python version 1.0 was released. The major new
features included were the functional programming tools lambda,
map, filter, and reduce.
October 2000, Python 2.0 was released with major new features,
including a cycle-detecting garbage collector and support for
Unicode.
Python 3.0 was released on December 3, 2008. It was a major
revision of the language that is only partially backward compatible.
Many of its major features were backported to Python 2.6.x and 2.7.x
version series. Releases of Python 3 include the 2 to 3 utility, which
automates (at least partially) the translation of Python 2 code to
Python 3.
As of January 1, 2020, no new bug reports, fixes, or changes are made
to Python 2, and Python 2 is no longer supported.
Python 2 vs. Python 3
One of the common questions a new deep learning programmer might
have is whether to use Python 2.x or Python 3.x since there are many
outdated blog posts and web articles comparing two major versions. As
of 2020, it is safe to claim that these comparisons are not relevant. As
you may see in the preceding timeline, the delayed deprecation of
Python 2.x finally took place as of January 1, 2020. Therefore,
programmers may not find official support for Python 2.x versions
anymore.
One of the essential skills for a programmer is to be up to date with
the latest technology, and therefore, this book only utilizes the use of
Python 3.x versions. For the readers who are only familiar with Python
2.x versions, this preference should not pose a problem since the
differences between the syntax used in this book for Python 2.x and
Python 3.x are not significant. Therefore, Python 2.x programmers may
immediately familiarize themselves with the source code in this book.

Why Python?
Compared to other programming languages, there are several reasons
for Python’s popularity among data scientists and machine learning
engineers. 2019 Kaggle Machine Learning and Data Science Survey
revealed that Python is by far the most popular programming language
for data science and machine learning; see Figure 1-1.
Figure 1-1 2019 Kaggle Machine Learning and Data Science Survey
There are several reasons for Python’s popularity compared to
other languages. A non-exhaustive list of benefits of Python may be the
following.

Ease of Learning
One of the main reasons for newcomers to choose Python as their
primary programming language is its ease of learning. When compared
to other programming languages, Python offers a shorter learning
curve so that programmers can achieve a good level of competency in a
short amount of time. Python’s syntax is easier to learn, and the code is
more readable compared to other popular programming languages. A
common example to show this is the amount of code required by
different programming languages to print out “Hello, World!”. For
instance, to be able to print out Hello, World! in Java, you need the
following code:
Hello, World! In Java

public class Main {


public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

The same result may be achieved with a single line of code in


Python:

Hello, World! in Python


print("Hello, World!")

A Variety of Available Data Science Libraries


Another powerful characteristic of Python compared to other
programming languages is its wide variety of data science libraries .
The data science libraries such as Pandas, NumPy, SciPy, and scikit-
learn reduce the time to prepare the data for model training with their
standardized functions and modules for logical and mathematical
operations. Furthermore, thanks to the vibrant community of Python
developers, as soon as the developers detect a common problem, a new
library is immediately designed and released to address this problem .

Community Support
The powerful community support is another advantage of Python over
other programming languages. More and more volunteers are releasing
Python libraries, and this practice made Python the language with
modern and powerful libraries. Besides, a high number of seasoned
Python programmers are always ready to help other programmers with
their problems on online community channels such as Stack Overflow.

Visualization Options
Data visualization is an important discipline to extract insights from
raw data, and Python offers several useful visualization options. The
good old Matplotlib is always there with the most customizable options.
In addition, Seaborn and Pandas Plot API are powerful libraries that
streamline the most common visualization tasks used by data
scientists. Additionally, libraries like Plotly and Dash allow users to
create interactive plots and sophisticated dashboards to be served on
the Web. With these libraries, data scientists may easily create charts,
draw graphical plots, and facilitate feature extraction.
Now that we covered why favorite language of data scientists is
Python, we can move on to why we use TensorFlow as our machine
learning framework.

TensorFlow As Deep Learning Framework


TensorFlow is an open source machine
learning platform with a particular focus on neural networks,
developed by the Google Brain team. Despite initially being used for
internal purposes, Google released the library under the Apache
License 2.0 in November 2015, which made it an open source library.1
Although the use cases of TensorFlow are not limited to machine
learning applications, machine learning is the field where we see
TensorFlow’s strength.
The two programming languages with stable and official
TensorFlow APIs are Python and C. Also, C++, Java, JavaScript, Go, and
Swift are other programming languages where developers may find
limited-to-extensive TensorFlow compatibility. Finally, there are third-
party TensorFlow APIs for C#, Haskell, Julia, MATLAB, R, Scala, Rust,
OCaml, and Crystal.

Timeline of TensorFlow
Although this book focuses on TensorFlow 2.x with Python API, there
are several complementary TensorFlow libraries released by Google.
Understanding the development of the TensorFlow platform is essential
to see the full picture. The timeline of the milestones achieved by
Google as part of the TensorFlow project may be summarized as
follows:
In 2011, Google Brain built a machine learning system called
DistBelief using deep learning neural networks.
November 2015, Google released the TensorFlow library under the
Apache License 2.0 and made it open source to accelerate the
advancements in artificial intelligence.
In May 2016, Google announced an application-specific integrated
circuit (an ASIC) built for machine learning and tailored for
TensorFlow, called Tensor Processing Unit (TPU) .
In February 2017, Google released TensorFlow 1.0.0 .
In May 2017, Google announced TensorFlow Lite , a library for
machine learning development in mobile devices.
In December 2017, Google introduced Kubeflow , which allows
operation and deployment of TensorFlow on Kubernetes.
In March 2018, Google announced TensorFlow.js version 1.0 for
machine learning with JavaScript.
In July 2018, Google announced the Edge TPU . Edge TPU is Google’s
purpose-built ASIC chip designed to run TensorFlow Lite machine
learning (ML) models on smartphones.
In January 2019, Google announced TensorFlow 2.0 to be officially
available in September 2019.
In May 2019, Google announced TensorFlow Graphics for deep
learning in computer graphics.
In September 2019, TensorFlow Team released TensorFlow 2.0, a
new major version of the library.
This timeline shows that the TensorFlow platform is maturing.
Especially with the release of TensorFlow 2.0, Google has improved the
user-friendliness of TensorFlow APIs significantly. Besides, the
TensorFlow team announced that they don’t intend to introduce any
other significant changes. Therefore, it is safe to assume that the
methods and syntax included in this book are to keep their relevance
for a long time.

Why TensorFlow?
There are more than two dozens of deep learning libraries developed
by tech giants, tech foundations, and academic institutions that are
available to the public. While each framework has its advantage in a
particular sub-discipline of deep learning, this book focuses on
TensorFlow with Keras API. The main reason for choosing TensorFlow
over other deep learning frameworks is its popularity. On the other
hand, this statement does not indicate that the other frameworks are
better – yet, less popular – than TensorFlow. Especially with the
introduction of version 2.0, TensorFlow strengthened its power by
addressing the issues raised by the deep learning community. Today,
TensorFlow may be seen as the most popular deep learning framework,
which is very powerful and easy to use and has excellent community
support.

What’s New in TensorFlow 2.x


Since its introduction in 2015, TensorFlow has grown into one of the
most advanced machine learning platforms in the market. Researchers,
developers, and companies widely adopted the technologies introduced
by the TensorFlow team. Around its 4th birthday, TensorFlow 2.0 was
released in September 2019. The TensorFlow team put a lot of effort
into simplifying the APIs by cleaning up deprecated APIs and reducing
duplication. The TensorFlow team introduced several updates to
achieve simplicity and ease of use in TensorFlow 2.0. These updates
may be listed as follows:
1. Easy model building with Keras and eager execution

2. Robust model deployment in production level on any platform

3. Robust experimentation for research

4. Simplified API thanks to cleanups and duplication reduction

Easy Model Building with Keras and Eager Execution


The TensorFlow team further streamlined the model building
experience to respond to expectations with the new or improved
modules such as tf.data, tf.keras, and tf.estimators and the
Distribution Strategy API.

Load Your Data Using tf.data


In TensorFlow 2.0, training data is read using input pipelines created
with the tf.data module . tf.feature_column module is used to
define feature characteristics. What is useful for newcomers is the new
DataSets module. TensorFlow 2.0 offers a separate DataSets module
which offers a range of popular datasets and allows developers to
experiment with these datasets.
Build, Train, and Validate Your Model with tf.keras, or Use Premade
Estimators
In TensorFlow 1.x, developers could use the previous versions of
tf.contrib, tf.layers, tf.keras, and tf.estimators to
build models. Offering four different options to the same problem
confused the newcomers and drove some of them away, especially to
PyTorch. TensorFlow 2.0 simplified the model building by limiting the
options to two improved modules: tf.keras (TensorFlow Keras API)
and tf.estimators (Estimator API) . TensorFlow Keras API offers a
high-level interface that makes model building easy, which is especially
useful for proof of concepts (POC) . On the other hand, Estimator API is
better suited for production-level models that require scaled serving
and increased customization capability.
Run and Debug with Eager Execution, Then Use AutoGraph API for
the Benefits of Graphs
TensorFlow 1.x versions were prioritizing TensorFlow graphs, which is
not friendly to newcomers. Even though this complicated methodology
was kept in TensorFlow 2.0, eager execution – the contrast concept –
was made default. Google explained the initial reasoning for this change
with the following statement:

Eager execution is an imperative, define-by-run interface where


operations are executed immediately as they are called from
Python. This makes it easier to get started with TensorFlow, and
can make research and development more intuitive.2
Eager execution makes the model building easier. It offers fast
debugging capability with immediate runtime errors and integration
with Python tools, which makes TensorFlow more beginner friendly. On
the other hand, graph execution has advantages for distributed training,
performance optimizations, and production deployment. To fill this gap,
TensorFlow introduced AutoGraph API called via tf.function
decorator . This book prioritizes eager execution over graph execution
to achieve a steep learning curve for the reader.
Use Distribution Strategies for Distributed Training
Model training with large datasets necessitates distributed training
with multiple processors such as CPU, GPU, or TPU. Even though
TensorFlow 1.x has support for distributed training, Distribution
Strategy API optimizes and streamlines the distributed training across
multiple GPUs, multiple machines, or TPUs. TensorFlow also provides
templates to deploy training on Kubernetes clusters in on-prem or
cloud environments, which makes the training more cost-effective.
Export to SavedModel
After training a model, developers may export to SavedModel .
tf.saved_model API may be used to build a complete TensorFlow
program with weights and computations. This standardized
SavedModel can be used interchangeably across different TensorFlow
deployment libraries such as (i) TensorFlow Serving, (ii) TensorFlow
Lite, (iii) TensorFlow.js, and (iv) TensorFlow Hub.

Robust Model Deployment in Production on Any


Platform
TensorFlow has always made efforts to provide a direct path to
production on different devices. There are already several libraries
which may be used to serve the trained models on dedicated
environments.
TensorFlow Serving
TensorFlow Serving is a flexible and high-performance TensorFlow
library that allows models to be served over HTTP/REST or
gRPC/Protocol Buffers. This platform is platform and language-neutral
as you may make an HTTP call using any programming language.
TensorFlow Lite
TensorFlow Lite is a lightweight deep learning framework to deploy
models to mobile devices (iOS and Android) or embedded devices
(Raspberry Pi or Edge TPUs). Developers may pick a trained model,
convert the model into a compressed fat buffer, and deploy to a mobile
or embedded device with TensorFlow Lite.
TensorFlow.js
TensorFlow.js enables developers to deploy their models to web
browsers or Node.js environments. Developers can also build and train
models in JavaScript in the browser using a Keras-like API.
With TensorFlow 2.0, the capability and parity across platforms and
components are greatly improved with standardized exchange formats
and aligning APIs. The new simplified architecture of TensorFlow 2.0 is
shown by the TensorFlow team in Figure 1-2 .

Figure 1-2 A Simplified Diagram for the TensorFlow 2.0 Architecture3


Another Random Document on
Scribd Without Any Related Topics
the sea inclined to dry up, and the wind and the waterspout came to
an end. I looked at the sea, attentively observing—and the whole of
humanity had returned to mud; like unto sea-weeds the corpses
floated. I opened the window, and the light smote on my face. I was
seized with sadness; I sat down and I wept;—and my tears came
over my face.
I looked at the regions bounding the sea; towards the twelve points
of the horizon; not any continent.—The vessel was borne above the
land of Nizir,—the mountain of Nizir arrested the vessel, and did not
permit it to pass over.—A day and a second day the mountain of
Nizir arrested the vessel, and did not permit it to pass over;—the
third and fourth day the mountain of Nizir arrested the vessel, and
did not permit it to pass over;—the fifth and sixth day the mountain
of Nizir arrested the vessel, and did not permit it to pass over.—At
the approach of the seventh day, I sent out and loosed a dove. The
dove went, turned, and—found no place to light on, and it came
back. I sent out and loosed a swallow; the swallow went, turned,
and—found no place to light on, and it came back. I sent out and
loosed a raven; the raven went, and saw the corpses on the waters;
it ate, rested, turned, and came not back.
I then sent out (what was in the vessel) towards the four winds, and
I offered a sacrifice. I raised the pile of my burnt-offering on the
peak of the mountain; seven by seven I disposed the measured
vases,[107]—and beneath I spread rushes, cedar, and juniper wood.
The gods were seized with the desire of it,—the gods were seized
with a benevolent desire of it;—and the gods assembled like flies
above the master of the sacrifice. From afar, in approaching, the
great goddess raised the great zones that Anu has made for their
glory (the gods’).[108] These gods, luminous crystal before me, I will
never leave them; in that day I prayed that I might never leave
them. “Let the gods come to my sacrificial pile!—but never may Bel
come to my sacrificial pile! for he did not master himself, and he has
made the waterspout for the Deluge, and he has numbered my men
for the pit.”
From far, in drawing near, Bel—saw the vessel, and Bel stopped;—he
was filled with anger against the gods and the celestial archangels:
—“No one shall come out alive! No man shall be preserved from the
abyss!”—Adar opened his mouth and said; he said to the warrior Bel:
—“What other than Ea should have formed this resolution?—for Ea
possesses knowledge and [he foresees] all.”—Ea opened his mouth
and spake; he said to the warrior Bel:—“O thou, herald of the gods,
warrior,—as thou didst not master thyself, thou hast made the
waterspout of the deluge.—Let the sinner carry the weight of his
sins, the blasphemer the weight of his blasphemy.—Please thyself
with this good pleasure, and it shall never be infringed; faith in it
never [shall be violated].—Instead of thy making a new deluge, let
hyænas appear and reduce the number of men; instead of thy
making a new deluge, let there be famine, and let the earth be
[devastated];—instead of thy making a new deluge, let Dibbara[109]
appear, and let men be [mown down].—I have not revealed the
decision of the great gods;—it is Khasisatra who interpreted a dream
and comprehended what the gods had decided.”
Then, when his resolve was arrested, Bel entered into the vessel.—
He took my hand and made me rise.—He made my wife rise, and
made her place herself at my side.—He turned around us and
stopped short; he approached our group.—“Until now Khasisatra has
made part of perishable humanity;—but lo, now, Khasisatra and his
wife are going to be carried away to live like the gods,—and
Khasisatra will reside afar at the mouth of the rivers.”—They carried
me away and established me in a remote place at the mouth of the
streams.
This narrative agrees with the Biblical one in ascribing the inundation
to a deluge of rain; but adds further details which connect it with
intense atmospheric disturbance, similar to that which would be
produced by a series of cyclones, or typhoons, of unusual severity
and duration.
The intense gloom, the deluge of rain, terrific violence of wind, and
the havoc both on sea and land, which accompany the normal
cyclones occurring annually on the eastern coast of China, and
elsewhere, and lasting but a few hours in any one locality, can hardly
be credited, except by those who have experienced them. They are,
however, sufficient to render explicable the general devastation and
loss of life which would result from the duration of typhoons, or
analogous tempests, of abnormal intensity, for even the limited
period of six days and nights allotted in the text above, and much
more so for that of one hundred and fifty days assigned to it in the
Biblical account.
As illustrating this I may refer to a few calamities of recent date,
which, though of trivial importance in comparison with the
stupendous event under our consideration, bring home to us the
terribly devastating power latent in the elements.
In Bengal, a cyclone on October 31, 1876, laid under water three
thousand and ninety-three square miles, and destroyed two hundred
and fifteen thousand lives.
A typhoon which raged in Canton, Hongkong, and Macao on
September 22, 1874, besides much other destruction, destroyed
several thousand people in Macao and the adjacent villages, the
number of corpses in the town being so numerous that they had to
be gathered in heaps and burnt with kerosene, the population,
without the Chinese who refused to lend assistance, being
insufficient to bury them.
A tornado in Canton, on April 11, 1878, destroyed, in the course of a
few minutes, two thousand houses and ten thousand lives.
In view of these few historical facts, which might be greatly
supplemented, there appears to my mind to be no difficulty in
believing that the continuance, during even only six days and six
nights, of extraordinarily violent circular storms over a given area,
would, especially if accompanied by so-called tidal or earthquake
waves, be sufficient to wreck all sea-going and coasting craft, all
river boats, inundate every country embraced within it to a very
great extent, submerge each metropolis, city, or village, situate
either in the deltas of rivers, or higher up their course, sap, unroof,
batter down, and destroy all dwellings on the highlands, level
forests, destroy all domestic animals, sweep away all cultivated soil,
or bury it beneath an enormous thickness of débris, tear away the
soil from the declivities of hills and mountains, destroy all shelter,
and hence, by exposure, most of those wretched human beings who
might have escaped drowning on the lower levels. The few survivors
would with difficulty escape starvation, or death from subsequent
exposure to the deadly malaria which would be liberated by the
rooting up of the accumulated débris of centuries. This latter
supposition appears to me to be directly indicated by the passage
towards the end of the extract referring to famine, and to the
devastation of the earth by Dibbara (the god of epidemics).
It is noticeable that in this account there is no suggestion of
complete immersion, Khasisatra simply says there is not any
continent (i.e. all the hill ranges within sight would stand out from
the inundation like islands), while he speaks of his vessel being
arrested by the mountain of Nizir, which must consequently have
been above the surface of the water.
Neither is there any such close limitation of the number of persons
preserved, as in the Biblical story, for Khasisatra took with him his
men-servants, maid-servants, and his young people, while the
version transmitted by Berosus (see Appendix to this Chapter),
states that Xisuthros embarked his wife, children, and his intimate
friends, and that these latter subsequently founded numerous cities,
built temples, and restored Babylon.
We have thus a fair nucleus for starting a fresh population in the
Euphrates valley, which may have received accessions from the
gradual concentration of scattered survivors, and from the enterprise
of maritime adventurers from the African coast and elsewhere,
possibly also nomads from the north, east, and west may have
swelled the numbers, and a polyglot community have been
established, which subsequently, through race distinctions,
jealousies, and incompatibility of language, became again
dismembered, as recorded in the history of the attempted erection
of the Tower of Babel.
Confining our attention for the moment to this one locality, we may
imagine that the young population would not be deterred by any
apprehension of physical danger from reinhabiting such of the old
cities as remained recognizable; since we see that men do not
hesitate to recommence the building of cities overthrown by
earthquake shocks almost before the last tremblings are over; or, as
in the case of Herculaneum and Pompeii, within the range of
volcanoes which may have already repeatedly vomited destroying
floods of lava. Yet, in this instance, they would probably invest the
calamity with a supernatural horror, and regard it, as the text
expresses it, as a chastisement from the gods for their impiety. If
this were so, the very memory of such cities would soon be lost, and
with it all the treasures of art and literature which they contained.
[110]

The Hindu account is taken from the S’atapatha-Brâhmana, a work


of considerable antiquity, being one of a series which Professor Max
Müller believes to have been written eight hundred years before
Christ. A literal translation of the legend, as given in this venerable
work, is as follows:—
“To Manu in the morning they brought water for washing, just as
they bring it for washing the hands. As he was using the water, a
fish came into his hand. This (fish) said to him, ‘Preserve me, and I
will save thee.’ (Manu said), ‘From what wilt thou preserve me?’ (The
fish replied), ‘A flood will carry away all these creatures; from that I
will preserve thee.’ (Manu said), ‘How is thy preservation (to be
effected)?’ (The fish replied), ‘As long as we are small, there is great
danger of our destruction; fish even devours fish: at first preserve
me in a jar. When I grow too big for that, cut a trench, and preserve
me in that. When I outgrow that, carry me to the sea; then I shall
be beyond (the reach of) danger.’ Soon it became a great fish; it
increased greatly. (The fish said), ‘In so many years the flood will
come; make a ship and worship me. On the rising of the flood enter
the ship, then I will preserve thee.’ Having preserved the fish he
brought it to the sea. In the same year indicated by the fish (Manu)
made a ship and worshipped the fish. When the flood rose he
entered the ship; the fish swam near him: he attached the cable of
the ship to his (the fish’s) horn. By this means the fish carried him
over the northern mountain (Himalayas). (The fish said), ‘I have
preserved thee: fasten the ship to a tree. But lest the water cut thee
off whilst thou art on the mountain, as fast as the water subsides
thou wilt descend with it.’ Accordingly he descended (with the
water); hence this became ‘Manu’s Descent’ from the northern
mountain. The flood had carried away all those creatures, Manu
alone was left. He being desirous of offspring performed a sacred
rite; there also he offered a pâka-sacrifice. With clarified butter,
coagulated milk, whey, and curds, he made an offering to the
waters. In a year a female was produced; and she arose unctuous
from the moisture, with clarified butter under her feet. Mitra and
Varuna came to her; and said to her, ‘Who art thou?’ (She said), ‘The
daughter of Manu.’ (They said), ‘Say (thou art) our (daughter).’ ‘No,’
she replied, ‘I am verily (the daughter) of him who begot me.’ They
desired a share in her; she agreed and did not agree. She went on
and came to Manu. Manu said to her, ‘Who art thou?’ ‘Thy daughter,’
she replied. ‘How, revered one, art thou my daughter?’ (She replied),
‘The offerings which thou hast cast upon the waters,—clarified
butter, coagulated milk, whey, and curds,—from them thou hast
generated me. I am a blessing. Do thou introduce me into the
sacrifice. If thou wilt introduce me into the sacrifice, thou wilt be
(blessed) with abundance of offspring and cattle. Whatever blessing
thou shalt ask through me, will all be given to thee.’ Thus he
introduced her in the middle of the sacrifice; for the middle of the
sacrifice is that which comes between the final and the introductory
prayers. He, desirous of offspring, meditating and toiling, went with
her. By her he begot this (offspring), which is (called) ‘The offspring
of Manu.’”
The correspondence of this legend with the Biblical and the other
accounts is remarkable. We have the announcement of the Deluge,
the construction of a ship, the preservation therein of a
representative man, the settlement of the vessel on a mountain, the
gradual subsidence of the water, and the subsequent re-peopling of
the world by the man thus preserved. The very scene of the
cataclysm is in singular agreement with the other accounts; for the
flood is said to carry Manu “over the northern mountain.” This places
the scene of the Deluge in Central Asia, beyond the Himalaya
mountains, and it proves that the legend embodies a genuine
tradition brought by the progenitors of the Hindus from their
primæval home, whence also radiated the Semitic and Sinitic
branches of mankind.

There has been much discussion as to whether the great inundation


which occurred in China during the reign of Yao is identical with that
of Genesis or not. The close proximity of date lends a strong support
to the assumption, and the supposition that the scene of the Biblical
Deluge was local in its origin, but possibly widespread in its results,
further favours the view.
As the rise of the Nile at Cairo is the only intimation which the
inhabitants of Lower Egypt have of the tropical rains of Central
Africa, so the inundation of the countries adjacent to the head
waters of the great rivers of China may alone have informed the
inhabitants of that country of serious elemental disturbances, only
reaching, and in a modified form, their western frontier; and it may
well have been that the deluge which caused a national annihilation
in Western Asia was only a national calamity in the eastern portion
of it.
This view is strengthened if we consider that Chinese history has no
record of any deluge prior to this, which could hardly have been the
case had the Chinese migrated from their parent stock subsequent
to an event of such importance; assuming that it had occurred, as
there seems valid reason to suppose, within the limits of written
history. The anachronism between the two dates assigned by
Chinese authors (2297 b.c.) and the Jewish historian’s calculation
(2104 b.c.) is only one hundred and ninety-three years, and this is
not so great but that we may anticipate its being explained at some
future date. Strauchius’ computation of 2293 b.c. for the date of the
Biblical deluge is within four years, and Ussher’s (2349-2348) within
fifty-one of the Chinese one. The reason for supposing the deluge of
Yao to be historically true, will be inferred from the arguments
borrowed from Mr. Legge on the subject of the Shu-king, in another
portion of this volume. It is detailed in the great Chinese work on
history, the T‘ung-këen-kang-muh, by Choo He, of which De Mailla’s
History of China professes to be a translation.
This states that the inundation happened in the sixty-first year of the
reign of Yao (2297 b.c.), and that the waters of the Yellow River
mingled with those of the Ho-hi-ho and the Yangtsze, ruining all the
agricultural country, which was converted into one vast sea.
But neither in the Bamboo Books nor in the Shu-king do we find that
any local phenomena of importance occurred, with the exception of
the inundation. In fact, the first work is singularly silent on the
subject, and simply says that in his sixty-first year Yao ordered
K‘wan of Ts‘ung to regulate the Ho, and degraded him in his sixty-
ninth for being unable to effect it, as we learn elsewhere.
The Shu is more explicit. The Emperor, consulting one of his chief
officials on the calamity, says: “O chief of the four mountains,
destructive in their overflow are the waters of the inundation. In
their vast extent they embrace the mountains and overtop the hills,
threatening the heavens with their floods, so that the inferior people
groan and murmur.”
According to De Mailla’s translation, K‘wan laboured uselessly for
nine years, the whole country was overrun with briars and
brushwood, the people had almost forgotten the art of cultivating
the ground—they were without the necessary seeds—and wild
animals and birds destroyed all their attempts at agriculture.
In this extremity Yao consulted Shun, his subsequent successor, who
recommended the appointment of Yu, the son of K‘wan, in his
father’s place.
Yu was more successful, and describes his labours as follows:—
“The inundating waters seemed to assail the heavens, and in their
vast extent embraced the mountains and over-topped the hills, so
that people were bewildered and overwhelmed. I mounted my four
conveyances,[111] and all along the hills hewed down the woods, at
the same time, along with Yih, showing the multitudes how to get
flesh to eat.
“I also opened passages for the streams throughout the nine
provinces, and conducted them to the sea. I deepened, moreover,
the channels and canals, and conducted them to the streams, at the
same time, along with Tseih, sowing grain, and showing the
multitudes how to procure the food of toil in addition to flesh meat.”
Yu’s success is simply chronicled in the Bamboo Books as, “In his
seventy-fifth year Yu, the Superintendent of Works, regulated the
Ho.”
There was a legend extant in China in the times of Pinto, which he
gives in his book, of the original Chinese having migrated from a
region in the West, and, following the course of the Ho in boats,
finally settling in the country adjacent to Pekin. That some such
event took place is not unlikely. Its acceptance would explain much
that is difficult.
The pioneers, pushing through a country infested with hostile
aborigines, who would immediately after their passage close up the
road of communication behind them—pioneers who may have been
fugitives from their kindred through political commotions, or expelled
by successful enemies—would have a further barrier against return,
even were they disposed to attempt it, in the strong opposing
current which had borne them safely to their new homes.
It is probable that such a journey would form an entirely new
departure for their history, and that a few generations later it would
resemble a nebulous chronological zone, on the far side of which
could be dimly seen myths of persons and events representing in
reality the history of the not very remote ancestors from whom they
had become separated. The early arrivals would have been too much
occupied with establishing themselves in their new dominions to be
able to give much attention to keeping records or preserving other
than the most utilitarian branches of knowledge which they had
brought with them. The volumes of their ancestors were probably,
like the clay tablets of the royal library of Babylon, not of a portable
nature, at all events to fugitives, whose knowledge would, therefore,
be rather of a practical than of a cultivated nature, and this would
soon become limited for a while to their chiefs and religious
instructors, the exigencies of a colony menaced with danger
prohibiting any general acquisition or extension of learning.
In this way we can account for the community of the fables relating
to the remote antiquity of the Chinese with those of Chaldean and
Indian mythology, and with the highly civilized administration and
astrological knowledge possessed by Yao and Shun as herediton of
Fuh Hi, &c.
We can account for their possession of accurate delineations of the
dragon, which would form an important decoration of the standards
and robes of ceremony which were companions of their flight, while
their descriptions of the animal and its qualities would have already
entered into the realms of fanciful exaggeration and myth.
The dragon of Yao and Shun’s time, and of Yu’s time was, in my
opinion, an aquatic creature, an alligator; but the dragon of their
ancestors was a land lizard, which may even have existed down to
the time of the great cataclysm which we call the Deluge, and the
memory of which is best preserved in the Chinese drawings which
have been handed down from remote antiquity, and have travelled
from the great Central Asian centre, which was once alike its habitat
and that of their ancestors. Its history may perhaps become evolved
when the great store of book knowledge contained in the cuneiform
tablets, representing the culture of the other branch of their great
ethnological family, has been more extensively explored.
Geologists of the present day have a great objection to the bringing
in of cataclysms to account for any considerable natural changes,
but this one I conceive to have been of so stupendous a nature as to
have been quite capable of both extinguishing a species and
confusing the recollection of it. The mere fact of the story of the
dragon having survived such a period argues greatly, in my mind, for
the reality of its previous existence.
Extending our consideration, we are brought face to face with
another very important fact, namely, that a large proportion of the
human race content themselves with ephemeral structures. Thus, for
example, the Chinese neither have now, nor at any time have had,
any great architectural works. “The finest building in China is a
reproduction, on a large scale, of the tent; and the wooden
construction is always imitated where the materials are stone or
marble. The supports, often magnificent logs, brought, at great
expense, specially from the Straits, represent tent-poles; and the
roof has always the peaked ends and the curves that recall the
drooping canvas of the marquee. Architecture evidently died early; it
never had life enough to assimilate the new material which it found
when it migrated into China Proper. The yamen is a slightly glorified
cottage; the temple is an improved yamen. Sculpture is equally
neglected in this (æsthetically) benighted country. The human form
is as dignified and sightly, to Chinese eyes at least, in China as in the
West; but it never seems to have occurred, throughout so many
hundreds of years, to any Chinaman to perpetuate it in marble or
bronze, or to beautify a city with statues of its deities or great
men.”[112]
What holds good of the Chinese now, probably holds good of their
ancestors and the race from which they parted company in Central
Asia five thousand years ago, when they pierced their way eastwards
through the savage aborigines of Thibet and Mongolia, pushing aside
tribes which closed in again behind them, so as to intercept their
return or communication with their mother country—a country which
may have been equally careless of elaborating stupendous and
permanent works of architecture such as other nations glory in
possessing, and which, like the pyramids of Egypt and of Central
America, stand forth for thousands of years as landmarks of the
past.
We must, therefore, not be surprised if we do not immediately
discover the vestiges of the people of ten, fifteen, or twenty
thousand years ago. With an ephemeral architecture (which, as we
have seen, is all that a highly populous and long civilized race
actually possess), the sites of vast cities may have become entirely
lost to recollection in a few thousands of years from natural decay,
and how much more so would this be the case if, as we may
reasonably argue, minor cataclysms have intervened, such as local
inundations, earthquakes, deposition of volcanic ashes from even
distant sources, the spread of sandy deserts, destruction of life by
exceptionally deadly pestilence, by miasma, or by the outpour of
sulphurous fumes.
We have shown in another chapter how the process of extinction of
species continues to the present day, and from the nature of this
process we may deduce that the number of species which became
extinct during the four or five thousand years preceding the era of
exact history must have been considerable.
The less remarkable of these would expire unnoticed; and only those
distinguished by their size, ferocity, and dangerous qualities, or by
some striking peculiarity, would leave their impress on the mythology
of their habitat. Their exact history would be lost as the cities of
their epoch crumbled away, and during the passage through dark
ages of the people of their period and their descendants, and by
conquest or catastrophes such as we have referred to elsewhere;
while the slow dispersion which appears to have obtained among all
nations would render the record of their qualities the more confused
as the myth which embalmed it spread in circling waves farther and
farther from its original centre.
Amongst the most fell destroyer both of species and of their history
must have been the widespread, although not universal, inundation
known as the Biblical Deluge; a deluge which we think the evidence
given in the foregoing pages, and gathered from divers nations,
justifies us in believing to have really taken place, and not to be, as
mythologists claim, a mere ether myth. As to its date, allowance
being made for trifling errors, there is no reason for disputing the
computation of Jewish chronology, especially as that is closely
confirmed by the entirely independent testimony of Chinese history.
This interposes a vast barrier between us and the knowledge of the
past, a barrier round which we pass for a short distance at either
end when we study the history of the two great streams of nations
which have diverged from a common centre, the Chinese towards
the East, the Accadian Chaldæans and Semites towards the West; a
barrier which we may hope to surmount when we are able to
discover and explore the lost cities of that common centre, with the
treasures of art and literature which they must undoubtedly possess.
CHAPTER V.

ON THE TRANSLATION OF MYTHS


BETWEEN THE OLD AND THE NEW
WORLD.
Intercourse between various parts of the old world and the new was
probably much more intimate even three or four thousand years ago
than we, or at all events our immediate ancestors, have credited.
The Deluge Tablets referred to in another chapter contain items from
which we gather that sea-going vessels, well equipped and with
skilled pilots, were in vogue in the time of Noah, and there is
wanting no better proof of their seaworthiness than the fact that his
particular craft was able to weather a long-continued tempest which
would probably have sunk the greater part of those which keep the
seas at the present time. The older Chinese classics make constant
allusions to maritime adventure, and the discovery by Schliemann in
ancient Troy[113] of vases with Chinese inscriptions confirms the
notion that, at that date at least, commercial exchange was effected
between these two widely-distant countries, either directly or by
transfer through different entrepôts.
A more striking example, and one which carries us back to a still
earlier epoch, will be afforded if the reported discovery of Chinese
vestigia in Egyptian tombs is confirmed by further investigation.
The fleets of King Solomon penetrated at least to India, and
detached squadrons[114] probably coasted from island to island along
the Malay archipelago; while to descend by gradation to modern
times, we may quote the circumnavigation of Africa by Hanno the
Carthaginian,[115] the discovery of America prior to Columbus by the
Chinese in the fifth century, from the Asiatic side, and by the
Norsemen under Leif Ericsson in the year 1001, from the European;
and the anticipation of the so-called discoveries of Van Diemen and
Tasman by the voyages of Arab and other navigators, from whose
records El Edrisi,[116] in the twelfth century, was enabled to indicate
the existence of New Guinea, and, I think, of the northern coast of
Australia. For although the identity with Mexico of the country called
Fu-sang, visited prior to a.d. 499 by the Buddhist priest Hoei-shiu,
has been disputed, yet the arguments in favour of it seem to
preponderate. These were adduced primarily by Deguignes, and
subsequently by C. F. Neumann, Leland and others, and are based
on the facts stated in the short narrative in regard to distance,
description of the Maguey plant, or great aloe,[117] the absence of
iron, and abundance of copper, gold, and silver.
While there can be little question that the islands and land of Wák
Wák are respectively some of the Sunda islands, New Guinea, and
the adjacent portion of Australia, it does not appear to have struck
any of the commentators on this question that the name “islands of
Wák Wák” may be assumed to signify simply “Bird of Paradise
islands.” Wallace, in his Malay Archipelago, emphatically remarks
that in the interior of the forests of New Guinea the most striking
sound is the cry “Wok Wok” of the great Bird of Paradise, and we
may therefore reasonably speculate on the bird having been known
as the Wok Wok, and the islands as the Wok Wok islands, just as we
ourselves use the imitative names of Cuckoo, Morepork, or Hoopoe
for birds, or Snake islands, Ape Hill, &c. for places.
This view is to an extent strengthened by Wák Wák being the home
of the lovely maiden captured by Hasan (in the charming story of
Hasan of El Basrah in the Arabian Nights), after she had divested
herself of her bird skin, and to which he had to make so weary a
pilgrimage from island to island, and sea to sea, in search of her
after her escape from him. It is evident that among the wonders
related by navigators of islands so remote and unfrequented, not the
least would be the superavian loveliness of the Birds of Paradise, and
from the exaggerated narratives of travellers may have arisen the
beautiful fable incorporated in the Arabian Nights, as well as that
other recorded by Eesa or Moosa the son of El Mubarak Es Serafee.
[118] “Here, too, is a tree that bears fruit like women with bodies,
eyes, limbs, &c. like those of women; they have beautiful faces, and
are suspended by the hair; they come forth from integuments like
large leathern bags; and when they feel the air and the sun they cry
out ‘Wák Wák’ until their hair is cut, and when it is cut they die; and
the people of these islands understand their cry, and augur ill from
it.” This, after all, is not more absurd than the story of the origin of
the barnacle duck, extant and believed in Europe until within the last
century or so.
El Edrisi, who, in common with the geographers of the period,
believed in a great antarctic continent, after describing Sofala with
its mines of gold, abundance of iron, &c., jumps at once to the
mainland of Wák Wák, which he describes as possessing two towns
situated on a great gulf (Carpentaria?), and a savage population.[119]
The two small towns may very well have been encampments of the
aborigines, or trading stations of Malay merchants.
It may be noted that this identification of Wák Wák is in opposition
to the view entertained by some commentators; for example,
Professor de Goeje of Leyden has recently identified the Silâ islands
(which had previously been considered as being Japan) with Corea,
and Wák Wák with Japan; but this does not agree with El Edrisi’s
account of the people being black, unclothed, and living on fish,
shell, and tortoises (turtles), without gold, commerce, ships, or
beasts of burden. Elsewhere El Edrisi says the women are entirely
naked, and only wear combs of ivory ornamented with mother of
pearl.
Lane thinks the Arabs applied the name of Wák Wák to all the
islands with which they were acquainted on the east and south-east
of Borneo. Es Serafee, beside the details given in a previous note,
also says, “From one of these islands of Wák Wák there issueth a
great torrent like pitch, which floweth into the sea, and the fish are
burnt thereby, and float upon the water.” And Hasan, in the story
quoted above, has, in order to reach the last of the seven islands of
Wák Wák, to pass over the third island, the land of the Jinn, “where
by reason of the vehemence of the cries of the Jánn, and the rising
of the flames about, of the sparks and the smoke from their mouths,
and the harsh sounds from their throats, and their insolence, they
will obstruct the way before us,” &c. &c. I think that in each of these
latter instances, the volcanic islands of Java, and other of the Sunda
islands are indicated.
The information in our possession is as yet too meagre to permit of
our indulging in any profitable consideration of the sources from
which originated those nations which peopled America during the
very early pre-traditional ages, of which geological evidence is
accumulating daily. In fact, the theories on this point have advanced
so little beyond the limits of speculation that I feel it unnecessary to
do more than quote one of them, as summarized in the ensuing
extract. “Professor Flowers, in remarking upon recent
palæontological investigations, which prove that an immense
number of forms of terrestrial animals that were formerly supposed
to be peculiar to the Old World are abundant in the New; and that
many, such as the horse, rhinoceros, and the camel, are more
numerous in species and varieties in the latter, infers that the means
of land communication must have been very different to what it is
now, and that it is quite as likely that Asiatic man may have been
derived from America as the reverse, or both may have had their
source in a common centre, in some region of the earth now
covered with sea.”[120]
The most commonly accepted theory with regard to the origin of
those who have peopled the American continent, within the limits of
tradition, is that they are of Asiatic descent, and that the migration
has been effected in comparatively recent times by way of Behring
Straits, and supplemented by chance passages from Southern Asia
by way of the Polynesian islands, or from the north of Africa, across
the Atlantic. There are, however, some who elaborate Professor
Flowers’ suggestion, and contend, in opposition to the more
generally received opinion, that the peopling of the present countries
of the Old World has in fact been effected from the New.
For instance, a proficient Aztec scholar, Senor Altamirano[121] of
Mexico, argues that the Aztecs were a race, originating in the
unsubmerged parts of America, as old as the Asiatics themselves,
and that Asia may in fact have been peopled from Mexico; while Mr.
E. J. Elliott, in quoting him, says: “From the ruins recently found, the
most northern of any yet discovered, the indications of improved
architecture, the work of different ages, can be traced in a continual
chain to Mexico, when they culminate in massive and imposing
structures, thus giving some proof by circumstantial evidence to
Altamirano’s reasoning.”
Again, “Dr. Rudolf Falb[122] discovers that the language spoken by
the Indians in Peru and Bolivia, especially in Quichua and Aymara,
exhibits the most astounding affinities with the Semitic languages,
and particularly with the Arabic—in which tongue Dr. Falb himself
has been skilled from his boyhood. Following up the links of this
discovery, he has first found a connecting link with the Aryan roots,
and, secondly, has arrived face to face with the surprising revelation
that the Semitic roots are universally Aryan. The common stems of
all the variants are found in their purest condition in Quichua and
Aymara, from which fact Dr. Falb derives the conclusion that the high
plains of Peru and Bolivia must be regarded as the point of exit of
the present human race.”
On the other hand, Mr. E. B. Tylor, in the course of an article upon
Backgammon among the Aztecs,[123] which he argues must have
reached them from Asia, and very likely through Mexico, points out
that the myths and religion of the North American tribes contain
many fancies well known to Asia, which they were hardly likely to
have hit upon independently, and which they had not learned from
white men: “Such as the quaint belief that the world is a monstrous
tortoise floating on the waters; and an idea which the Sioux have in
common with the Tartars, that it is sinful to chop or poke with a
sharp instrument the burning log on the fire.” He quotes Alexander
von Humboldt as having “argued years ago that the Mexicans did
and believed things which were at once so fanciful and so like the
fancies of the Asiatics that there must have been communication.
Would two nations,” he asks, “have taken independently to forming
calendars of days and years by repeating and combining cycles of
animals, such as tiger, dog, ape, hare, &c.? Would they have
developed independently similar astrological fancies about these
signs governing the periods they began, and being influential each
over a particular limb or organ of men’s bodies? Would they, again,
have evolved separately out of this consciousness the myths of the
world and its inhabitants having, at the end of several successive
periods, been destroyed by elemental catastrophes?”
He adds, “It may very well have been the same agency which
transported to Mexico the art of bronze-making, the computation of
time by periods of dogs and apes, the casting of nativity, and the
playing of backgammon.”
Then, again, we have the theory of those, now indeed few in
number, who hold that the present Indian inhabitants of America
were a distinctly indigenous race. Lord Kaimes, in his Sketches of the
History of Man, says, “I venture still further, which is to conjecture
that America has not been peopled from any part of the Old World.”
Voltaire had preceded him in this line of argument, relying on
ridicule rather than on reason. “The same persons that readily admit
that the beavers of Canada are of Canadian origin, assert that the
men must have come there in boats, and that Mexico must have
been peopled by some of the descendants of Magog.”[124]
Missionaries of various sects have endeavoured to identify the Red
man with the lost ten tribes. Adair conceived the language of the
Southern Indians to be a corruption of Hebrew, and the Jesuit
Lafitan, in his history of the savages of America, maintained that the
Caribee language was radically Hebrew.
Mr. John Josselyn,[125] in an account of the Mohawks, states that
their language is a dialect of the Tartars, and Dr. Williamson, in his
history of North Carolina, considers it can hardly be questioned that
the Indians of South America are descended from a class of the
Hindoos in the southern part of Asia.
Amongst others, Captain Don Antonio del Rio, who described the
ruins of an ancient city in Guatemala, believed that they were the
relics of a civilization founded by Phœnician colonists who had
crossed the Atlantic ocean; and yet another theory is propounded by
Mr. Knox,[126] who considers the extinct Guanches, formerly
inhabiting the Canary and Cape de Verde islands, to have closely
resembled the Egyptians in certain particulars. He goes on to
observe, “Now cross the Atlantic, and in a nearly parallel zone of the
earth, or at least in one not far removed, we stumble all at once
upon the ruined cities of Copan and Central America. To our
astonishment, notwithstanding the breadth of the Atlantic, vestiges,
of a nature not to be doubted, of a thoroughly Egyptian character
reappear—hieroglyphics, monolithic temples, pyramids; who erected
these monuments on the American continent? Perhaps at some
remote period the continents were not so far apart, they might have
been united, thus forming a zone or circle of the earth occupied by a
pyramid-building people.”
It is not impossible that all of these theories may be correct, and
that numerous migrations may have been made at various periods
by different nations, the most facile would of course be that from
North-Eastern Asia by way of the Aleutian islands, for, as the author
of Fu-sang well remarks, a sailor in an open boat might cross from
Asia to America by that route in summer time, and hardly ever be
out of sight of land; and this in a part of the sea generally
abounding in fish, as is proved by the fishermen who inhabit many
of these islands, on which fresh water is always to be found. But it is
more than likely that the direct route, from the islands of Japan to
the coast of California or Mexico, was also occasionally followed,
voluntarily or involuntarily, by mariners impelled by enterprise,
religious motives, or stress of weather.
Colonel B. Kennon, as an evidence of the possibility of junks
performing long ocean voyages, adduces the instance of a Japanese
junk picked up by an American whaler two thousand three hundred
miles south-east of Japan, and of others which had drifted among
the Aleutian islands nearly half-way over to San Francisco; and in
noting the resemblance and probable co-origin of the Sandwich
Islanders with the Japanese, he adverts to the “ancient and
confirmed habit of both Japanese and Chinese of taking women to
sea with them, or of traders keeping their families on board, which
would fully account for the population of those islands,” or, to extend
the argument, of points on the American continent. The Jewish
element might easily be introduced through this channel, for the
occasional admixture of Jewish blood both among the Chinese and
Japanese is so strongly marked, as to have induced some authors to
contend for the absolute descent of the latter people at least from
Jewish parentage.
It must also be remembered that the waters of both the North and
South Pacific are peculiarly favourable to the navigation of small
craft, and that Captain Bligh, after the mutiny on board the Bounty,
was able to safely perform a journey of two thousand miles in an
open boat; while all the islands both in North and South Polynesia
must necessarily have been gradually peopled by the drifting over
the ocean of stray canoes.
Again, as the tradition of the existence of a large continent west of
the African coast was extant amongst the Egyptian priests long
before the days of Solon, and, as I shall show hereafter, among the
Carthaginians and Tyrrhenians, it is, I think, more than probable that
both Phœnician and Egyptian mariners, either acting under a Royal
Commission, or influenced by mercantile considerations, would
endeavour to discover it, and, as in the case of Columbus, would
have no difficulty in stretching across the Atlantic before a fair trade
wind, though they might be less successful than him on their return.
The possibility of the existence of a large island or continent,
midway between the Old and New World, within the traditional
period, is included in the important question, which is still sub judice
amongst geologists, whether the general disposition of land and
water has or has not been variable during past ages. Sir Charles
Lyell held the first view, and was of opinion[127] that complete
alternations of the positions of continent and ocean had repeatedly
occurred in geological time.
The opposite idea has been suggested at various dates by eminent
authorities, suggested rather than sustained by elaborate
arguments, until recently, when the question has been re-examined
by Mr. Wallace and Dr. Carpenter.
The former, in that chapter of island life devoted to the permanence
of continents, dwells forcibly upon Dr. Darwin’s inference from the
paucity of oceanic islands affording fragments of either Palæozoic or
Secondary formations “that perhaps during the Palæozoic and
Secondary periods neither continents nor continental islands existed
where our oceans now extend; for, had they existed, Palæozoic and
Secondary formations would in all probability have been
accumulated from sediment derived from their wear and tear; and
these would have been at least partially upheaved by the oscillations
of level which must have intervened during these enormously long
periods. If, then, we may infer anything from these facts, we may
infer that, where our oceans now extend, oceans have extended
from the remotest period of which we have any record; and, on the
other hand, that where continents now exist, large tracts of land
have existed, subjected no doubt to great oscillations of level, since
the Cambrian period.”
I am not aware whether Dr. Darwin has expressed himself more
authoritatively on this point in later works, or whether the whole
question has been discussed in detail otherwise than by Mr. Wallace
in the chapter referred to, in which he quotes what must, I think,
after all, only be taken in the light of a suggestion as an auxiliary to
the powerful arguments which he himself has enunciated in favour
of a similar conclusion. There is no doubt that the paucity of any but
volcanic or coralline islands throughout the greatest extent of
existing oceans has a certain but not absolute significance, so far as
recent geological epochs are concerned.
There is another line of reasoning, debated by Mr. Wallace, based on
the formation of the Palæozoic and Secondary strata from the waste
of broken continents and islands occupying generally the site of the
existing continents, and separated by insignificant distances of
inland sea or extensions from the adjacent oceans. It is soundly
based on their lithological structure, as generally indicative of a
littoral and shallow water origin, but it seems to me to be only
positive so far as it shows that, throughout geological time, some
land has existed somewhere within the limits of the present
upheaval, and simply negative as to what may or may not have been
the condition of what are now the great ocean spaces of the world.
Indeed, it would at first sight seem only reasonable to infer, that the
very depressions which caused the inundations of Europe and Asia,
during the deposition of any important formation, would imply a
corresponding elevation elsewhere, in order that the same relative
areas of land and water might be maintained.
This view has, however, been reduced in its proportions by Dr.
Carpenter, who has levelled the results of the recent researches by
the Challenger expedition against the advocates of the
intermutations of land and ocean, and, in pursuing another line of
reasoning from Mr. Wallace, has estimated the solid contents of
ocean and land above the sea-level respectively, as bearing the
proportion of thirty-six to one. So that, supposing all the existing
land of the globe to sink down to the sea-level, this subsidence
would be balanced by the elevation of only one thirty-sixth part of
the existing ocean floor from its present depth to the same level.
It must be admitted that the balance of argument was until lately
considerably against the former existence of the country of Atlantis,
whose ghostly outlines, however, we could almost imagine to be
sketched out by faint contours in the chart illustrative of the North
Atlantic portion of the Challenger investigations. But it was not so
overwhelming as to entitle us to ignore the story entirely as a fable.
I do not conceive it impossible that some centrally situated and
perhaps volcanic island may once have existed, sufficiently important
to have served as the basis of simple legends, which, under the
enchantment of distance and time became metamorphosed and
enriched.
Mr. A. R. Grote suggests that it is simply a myth founded on the
observation of low-lying clouds in a sun-flushed sky, which gave the
appearance like islands on a golden sea.
Mr. Donelly, on the other hand, in a very exhaustive and able
volume, contends first, that Atlantis actually existed, and secondly,
that it was the origin of our present civilization, that its kings are
represented by the gods of Greek mythology, and that its destruction
originated our Deluge story.
The well-known story is contained in an epic of Plato, of which two
fragments only remain, found in two dialogues (the Timæus and the
Critias). Critias is represented as telling an old-world story, handed
down in his family from his great-grandfather Dropidas, who had
heard it from Solon, who had it from the Egyptian priests of Sais.
[129]

Ælian, again, contains an extract from Theophrastus, who wrote in


the time of Alexander the Great, which can hardly imply anything
else than an acquaintance with America. It is in the form of a
dialogue between Midas the Phrygian and Silenus.
The latter informs Midas that Europe, Asia, and Africa were but
islands surrounded on all sides by sea, but that there was a
continent situated beyond these which was of immense dimensions,
even without limits, and that it was so luxuriant as to produce
animals of prodigious magnitude. That there men grew to double
the size of themselves, and that they lived to a far greater age, that
they had many cities, and their usages and laws were different from
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like