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

Get Building Computer Vision Applications Using Artificial Neural Networks: With Step-by-Step Examples in OpenCV and TensorFlow with Python 1st Edition Shamshad Ansari free all chapters

Ansari

Uploaded by

yufeiafrid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
30 views

Get Building Computer Vision Applications Using Artificial Neural Networks: With Step-by-Step Examples in OpenCV and TensorFlow with Python 1st Edition Shamshad Ansari free all chapters

Ansari

Uploaded by

yufeiafrid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Get ebook downloads in full at ebookmeta.

com

Building Computer Vision Applications Using


Artificial Neural Networks: With Step-by-Step
Examples in OpenCV and TensorFlow with Python 1st
Edition Shamshad Ansari
https://ebookmeta.com/product/building-computer-vision-
applications-using-artificial-neural-networks-with-step-by-
step-examples-in-opencv-and-tensorflow-with-python-1st-
edition-shamshad-ansari/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Building Computer Vision Applications Using Artificial


Neural Networks, 2nd Edition Shamshad Ansari

https://ebookmeta.com/product/building-computer-vision-applications-
using-artificial-neural-networks-2nd-edition-shamshad-ansari/

ebookmeta.com

Learn OpenCV with Python by Examples Implement Computer


Vision Algorithms Provided by OpenCV with Python for Image
Processing Object Detection and Machine Learning 2nd
Edition James Chen
https://ebookmeta.com/product/learn-opencv-with-python-by-examples-
implement-computer-vision-algorithms-provided-by-opencv-with-python-
for-image-processing-object-detection-and-machine-learning-2nd-
edition-james-chen/
ebookmeta.com

Learn OpenCV with Python by Examples 2nd Edition James


Chen

https://ebookmeta.com/product/learn-opencv-with-python-by-
examples-2nd-edition-james-chen/

ebookmeta.com

Ultimate Star Wars New Edition The Definitive Guide to the


Star Wars Universe Adam Bray

https://ebookmeta.com/product/ultimate-star-wars-new-edition-the-
definitive-guide-to-the-star-wars-universe-adam-bray/

ebookmeta.com
Black Light Disciplined Black Light Series Book 29 1st
Edition Livia Grant

https://ebookmeta.com/product/black-light-disciplined-black-light-
series-book-29-1st-edition-livia-grant-2/

ebookmeta.com

Breaking the Zero Sum Game Transforming Societies Through


Inclusive Leadership 1st Edition Aldo Boitano

https://ebookmeta.com/product/breaking-the-zero-sum-game-transforming-
societies-through-inclusive-leadership-1st-edition-aldo-boitano/

ebookmeta.com

States of Exception: Law, History, Theory 1st Edition


Cosmin Cercel (Editor)

https://ebookmeta.com/product/states-of-exception-law-history-
theory-1st-edition-cosmin-cercel-editor/

ebookmeta.com

Data Management at Scale, Second Edition Piethein


Strengholt

https://ebookmeta.com/product/data-management-at-scale-second-edition-
piethein-strengholt/

ebookmeta.com

Midnight Ice Complete Series Kaitlyn Davis

https://ebookmeta.com/product/midnight-ice-complete-series-kaitlyn-
davis/

ebookmeta.com
Glencoe Short Stories 3 1st Edition Jeffrey D. Wilhelm Et
Al

https://ebookmeta.com/product/glencoe-short-stories-3-1st-edition-
jeffrey-d-wilhelm-et-al/

ebookmeta.com
Building Computer
Vision Applications
Using Artificial Neural
Networks
With Step-by-Step Examples in
OpenCV and TensorFlow with Python

Shamshad Ansari

www.allitebooks.com
Building Computer Vision
Applications Using
Artificial Neural Networks
With Step-by-Step Examples
in OpenCV and TensorFlow
with Python

Shamshad Ansari

www.allitebooks.com
Building Computer Vision Applications Using Artificial Neural Networks: With
Step-by-Step Examples in OpenCV and TensorFlow with Python
Shamshad Ansari
Centreville, VA, USA

ISBN-13 (pbk): 978-1-4842-5886-6 ISBN-13 (electronic): 978-1-4842-5887-3


https://doi.org/10.1007/978-1-4842-5887-3

Copyright © 2020 by Shamshad Ansari


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.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Celestin Suresh John
Development Editor: Matthew Moodie
Coordinating Editor: Aditee Mirashi
Cover designed by eStudioCalamar
Cover image designed by Pixabay
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, 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.
For information on translations, please e-mail [email protected], or visit www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at www.apress.com/bulk-sales.
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-5886-6. For more
detailed information, please visit www.apress.com/source-code.
Printed on acid-free paper

www.allitebooks.com
In God we trust.
To my wonderful parents, Abdul Samad and
Nazhat Parween, who always corrected my mistakes and
raised me to become a good person.
To my lovely wife, Shazia, and our two beautiful daughters,
Dua and Erum. Without their love and support, this book
would not have been possible.

www.allitebooks.com
Table of Contents
About the Author�����������������������������������������������������������������������������������������������������xv

About the Technical Reviewer�������������������������������������������������������������������������������xvii


Acknowledgments��������������������������������������������������������������������������������������������������xix

Introduction������������������������������������������������������������������������������������������������������������xxi

Chapter 1: Prerequisites and Software Installation�������������������������������������������������� 1


Python and PIP������������������������������������������������������������������������������������������������������������������������������ 2
Installing Python and PIP on Ubuntu���������������������������������������������������������������������������������������� 2
Installing Python and PIP on macOS���������������������������������������������������������������������������������������� 2
Installing Python and PIP on CentOS 7������������������������������������������������������������������������������������ 3
Installing Python and PIP on Windows������������������������������������������������������������������������������������� 3
virtualenv�������������������������������������������������������������������������������������������������������������������������������������� 3
Installing and Activating virtualenv����������������������������������������������������������������������������������������� 4
TensorFlow������������������������������������������������������������������������������������������������������������������������������������ 5
Installing TensorFlow��������������������������������������������������������������������������������������������������������������� 5
PyCharm IDE��������������������������������������������������������������������������������������������������������������������������������� 5
Installing PyCharm������������������������������������������������������������������������������������������������������������������ 6
Configuring PyCharm to Use virtualenv����������������������������������������������������������������������������������� 6
OpenCV����������������������������������������������������������������������������������������������������������������������������������������� 7
Working with OpenCV�������������������������������������������������������������������������������������������������������������� 7
Installing OpenCV4 with Python Bindings�������������������������������������������������������������������������������� 8
Additional Libraries����������������������������������������������������������������������������������������������������������������������� 8
Installing SciPy������������������������������������������������������������������������������������������������������������������������ 8
Installing Matplotlib����������������������������������������������������������������������������������������������������������������� 8

www.allitebooks.com
Table of Contents

Chapter 2: Core Concepts of Image and Video Processing��������������������������������������� 9


Image Processing������������������������������������������������������������������������������������������������������������������������� 9
Image Basics������������������������������������������������������������������������������������������������������������������������������� 10
Pixels������������������������������������������������������������������������������������������������������������������������������������������ 10
Pixel Color������������������������������������������������������������������������������������������������������������������������������ 10
Coordinate Systems�������������������������������������������������������������������������������������������������������������������� 11
Python and OpenCV Code to Manipulate Images������������������������������������������������������������������������ 14
Program: Loading, Exploring, and Showing an Image����������������������������������������������������������� 15
Program: OpenCV Code to Access and Manipulate Pixels����������������������������������������������������� 17
Drawing��������������������������������������������������������������������������������������������������������������������������������������� 18
Drawing a Line on an Image�������������������������������������������������������������������������������������������������� 18
Drawing a Rectangle on an Image���������������������������������������������������������������������������������������� 21
Drawing a Circle on an Image����������������������������������������������������������������������������������������������� 25
Summary������������������������������������������������������������������������������������������������������������������������������������ 26

Chapter 3: Techniques of Image Processing����������������������������������������������������������� 27


Transformation���������������������������������������������������������������������������������������������������������������������������� 27
Resizing��������������������������������������������������������������������������������������������������������������������������������� 28
Translation����������������������������������������������������������������������������������������������������������������������������� 32
Rotation��������������������������������������������������������������������������������������������������������������������������������� 34
Flipping���������������������������������������������������������������������������������������������������������������������������������� 37
Cropping�������������������������������������������������������������������������������������������������������������������������������� 40
Image Arithmetic and Bitwise Operations����������������������������������������������������������������������������������� 42
Addition��������������������������������������������������������������������������������������������������������������������������������� 43
Subtraction���������������������������������������������������������������������������������������������������������������������������� 46
Bitwise Operations���������������������������������������������������������������������������������������������������������������� 52
Masking�������������������������������������������������������������������������������������������������������������������������������������� 58
Splitting and Merging Channels�������������������������������������������������������������������������������������������������� 61
Noise Reduction Using Smoothing and Blurring������������������������������������������������������������������������� 64
Mean Filtering or Averaging�������������������������������������������������������������������������������������������������� 64
Gaussian Filtering������������������������������������������������������������������������������������������������������������������ 67

vi
Table of Contents

Median Blurring��������������������������������������������������������������������������������������������������������������������� 69
Bilateral Blurring������������������������������������������������������������������������������������������������������������������� 71
Binarization with Thresholding��������������������������������������������������������������������������������������������������� 74
Simple Thresholding�������������������������������������������������������������������������������������������������������������� 74
Adaptive Thresholding����������������������������������������������������������������������������������������������������������� 77
Otsu’s Binarization����������������������������������������������������������������������������������������������������������������� 79
Gradients and Edge Detection����������������������������������������������������������������������������������������������������� 82
Sobel Derivatives (cv2.Sobel() Function)������������������������������������������������������������������������������� 82
Laplacian Derivatives (cv2.Laplacian() Function)������������������������������������������������������������������ 87
Canny Edge Detection����������������������������������������������������������������������������������������������������������� 89
Contours�������������������������������������������������������������������������������������������������������������������������������������� 90
Drawing Contours������������������������������������������������������������������������������������������������������������������ 93
Summary������������������������������������������������������������������������������������������������������������������������������������ 94

Chapter 4: Building a Machine Learning–Based Computer Vision System������������� 95


Image Processing Pipeline���������������������������������������������������������������������������������������������������������� 95
Feature Extraction����������������������������������������������������������������������������������������������������������������������� 97
How to Represent Features��������������������������������������������������������������������������������������������������� 98
Color Histogram��������������������������������������������������������������������������������������������������������������������� 99
Histogram Equalizer������������������������������������������������������������������������������������������������������������ 106
GLCM����������������������������������������������������������������������������������������������������������������������������������� 109
HOGs������������������������������������������������������������������������������������������������������������������������������������ 115
LBP�������������������������������������������������������������������������������������������������������������������������������������� 121
Feature Selection���������������������������������������������������������������������������������������������������������������������� 128
Filter Method����������������������������������������������������������������������������������������������������������������������� 128
Wrapper Method������������������������������������������������������������������������������������������������������������������ 129
Embedded Method�������������������������������������������������������������������������������������������������������������� 130
Model Training��������������������������������������������������������������������������������������������������������������������������� 130
How to Do Machine Learning���������������������������������������������������������������������������������������������� 130
Supervised Learning������������������������������������������������������������������������������������������������������������ 131
Unsupervised Learning�������������������������������������������������������������������������������������������������������� 132

vii
Table of Contents

Model Deployment�������������������������������������������������������������������������������������������������������������������� 133


Summary���������������������������������������������������������������������������������������������������������������������������������� 135

Chapter 5: Deep Learning and Artificial Neural Networks������������������������������������ 137


Introduction to Artificial Neural Networks��������������������������������������������������������������������������������� 137
Perceptron��������������������������������������������������������������������������������������������������������������������������� 140
Multilayer Perceptron���������������������������������������������������������������������������������������������������������� 141
What Is Deep Learning?������������������������������������������������������������������������������������������������������ 143
Deep Learning or Multilayer Perceptron Architecture��������������������������������������������������������� 143
Activation Functions������������������������������������������������������������������������������������������������������������ 146
Feedforward������������������������������������������������������������������������������������������������������������������������ 154
Error Function���������������������������������������������������������������������������������������������������������������������� 154
Optimization Algorithms������������������������������������������������������������������������������������������������������ 158
Backpropagation����������������������������������������������������������������������������������������������������������������� 164
Introduction to TensorFlow�������������������������������������������������������������������������������������������������������� 165
TensorFlow Installation�������������������������������������������������������������������������������������������������������� 166
How to Use TensorFlow������������������������������������������������������������������������������������������������������� 166
Tensor���������������������������������������������������������������������������������������������������������������������������������� 166
Variable�������������������������������������������������������������������������������������������������������������������������������� 167
Constant������������������������������������������������������������������������������������������������������������������������������ 167
Our First Computer Vision Model with Deep Learning: Classification of Handwritten Digits���� 169
Model Evaluation����������������������������������������������������������������������������������������������������������������������� 178
Overfitting���������������������������������������������������������������������������������������������������������������������������� 179
Hyperparameters���������������������������������������������������������������������������������������������������������������������� 184
TensorBoard������������������������������������������������������������������������������������������������������������������������ 185
Experiments for Hyperparameter Tuning����������������������������������������������������������������������������� 185
Saving and Restoring Model����������������������������������������������������������������������������������������������������� 189
Save Model Checkpoints During Training���������������������������������������������������������������������������� 190
Manually Save Weights������������������������������������������������������������������������������������������������������� 193
Load the Saved Weights and Retrain the Model������������������������������������������������������������������ 193
Saving the Entire Model������������������������������������������������������������������������������������������������������ 193

viii
Table of Contents

Retraining the Existing Model���������������������������������������������������������������������������������������������� 194


Using a Trained Model in Applications��������������������������������������������������������������������������������� 194
Convolution Neural Network����������������������������������������������������������������������������������������������������� 194
Architecture of CNN������������������������������������������������������������������������������������������������������������� 195
How Does CNN Work����������������������������������������������������������������������������������������������������������� 196
Summary of CNN Concepts������������������������������������������������������������������������������������������������� 201
Training a CNN Model: Pneumonia Detection from Chest X-rays���������������������������������������� 202
Examples of Popular CNNs�������������������������������������������������������������������������������������������������� 213
Summary����������������������������������������������������������������������������������������������������������������������������� 217

Chapter 6: Deep Learning in Object Detection������������������������������������������������������ 219


Object Detection������������������������������������������������������������������������������������������������������������������������ 219
Intersection Over Union������������������������������������������������������������������������������������������������������������� 220
Region-Based Convolutional Neural Network��������������������������������������������������������������������������� 222
Fast R-CNN������������������������������������������������������������������������������������������������������������������������������� 224
Faster R-CNN���������������������������������������������������������������������������������������������������������������������������� 225
Region Proposal Network���������������������������������������������������������������������������������������������������� 226
Fast R-CNN�������������������������������������������������������������������������������������������������������������������������� 227
Mask R-CNN������������������������������������������������������������������������������������������������������������������������������ 227
Backbone����������������������������������������������������������������������������������������������������������������������������� 228
RPN�������������������������������������������������������������������������������������������������������������������������������������� 229
Output Head������������������������������������������������������������������������������������������������������������������������� 229
What Is the Significance of the Masks?������������������������������������������������������������������������������ 230
Mask R-CNN in Human Pose Estimation����������������������������������������������������������������������������� 230
Single-Shot Multibox Detection������������������������������������������������������������������������������������������������ 231
SSD Network Architecture��������������������������������������������������������������������������������������������������� 232
Training�������������������������������������������������������������������������������������������������������������������������������� 235
SSD Results������������������������������������������������������������������������������������������������������������������������� 238
YOLO������������������������������������������������������������������������������������������������������������������������������������������ 238
YOLO Network Design���������������������������������������������������������������������������������������������������������� 240
Limitations of YOLO������������������������������������������������������������������������������������������������������������������� 241

ix
Table of Contents

YOLO9000 or YOLOv2����������������������������������������������������������������������������������������������������������� 241


YOLOv3�������������������������������������������������������������������������������������������������������������������������������� 244
Comparison of Object Detection Algorithms����������������������������������������������������������������������������� 247
Comparison of Architecture������������������������������������������������������������������������������������������������� 247
Comparison of Performance������������������������������������������������������������������������������������������������ 248
Training Object Detection Model Using TensorFlow������������������������������������������������������������������ 249
TensorFlow on Google Colab with GPU�������������������������������������������������������������������������������� 250
Detecting Objects Using Trained Models����������������������������������������������������������������������������������� 274
Installing TensorFlow’s models Project������������������������������������������������������������������������������� 274
Code for Object Detection���������������������������������������������������������������������������������������������������� 277
Training a YOLOv3 Model for Object Detection�������������������������������������������������������������������������� 290
Installing the Darknet Framework��������������������������������������������������������������������������������������� 291
Downloading Pre-trained Convolutional Weights���������������������������������������������������������������� 292
Downloading an Annotated Oxford-IIIT Pet Dataset������������������������������������������������������������� 292
Preparing the Dataset���������������������������������������������������������������������������������������������������������� 293
Configuring the Training Input��������������������������������������������������������������������������������������������� 297
Configuring the Darknet Neural Network���������������������������������������������������������������������������� 298
Training a YOLOv3 Model����������������������������������������������������������������������������������������������������� 299
How Long the Training Should Run�������������������������������������������������������������������������������������� 301
Final Model�������������������������������������������������������������������������������������������������������������������������� 301
Detecting Objects Using a Trained YOLOv3 Model��������������������������������������������������������������������� 302
Installing Darknet to the Local Computer���������������������������������������������������������������������������� 302
Python Code for Object Detection���������������������������������������������������������������������������������������� 303
Summary���������������������������������������������������������������������������������������������������������������������������������� 307

Chapter 7: Practical Example: Object Tracking in Videos������������������������������������� 309


Preparing the Working Environment����������������������������������������������������������������������������������������� 310
Reading a Video Stream������������������������������������������������������������������������������������������������������������ 312
Loading the Object Detection Model����������������������������������������������������������������������������������������� 314
Detecting Objects in Video Frames������������������������������������������������������������������������������������������� 315
Creating a Unique Identity for Objects Using dHash����������������������������������������������������������������� 317
Using the Hamming Distance to Determine Image Similarity��������������������������������������������������� 319

x
Table of Contents

Object Tracking������������������������������������������������������������������������������������������������������������������������� 319


Displaying a Live Video Stream in a Web Browser�������������������������������������������������������������������� 322
Installing Flask�������������������������������������������������������������������������������������������������������������������� 322
Flask Directory Structure���������������������������������������������������������������������������������������������������� 322
HTML for Displaying a Video Stream����������������������������������������������������������������������������������� 323
Flask to Load the HTML Page���������������������������������������������������������������������������������������������� 324
Flask to Serve the Video Stream����������������������������������������������������������������������������������������� 324
Running the Flask Server���������������������������������������������������������������������������������������������������� 325
Putting It All Together���������������������������������������������������������������������������������������������������������������� 325
Summary���������������������������������������������������������������������������������������������������������������������������������� 336

Chapter 8: Practical Example: Face Recognition�������������������������������������������������� 337


FaceNet������������������������������������������������������������������������������������������������������������������������������������� 338
FaceNet Neural Network Architecture��������������������������������������������������������������������������������� 338
Training a Face Recognition Model������������������������������������������������������������������������������������������� 344
Checking Out FaceNet from GitHub������������������������������������������������������������������������������������� 345
Dataset�������������������������������������������������������������������������������������������������������������������������������� 345
Downloading VGGFace2 Data���������������������������������������������������������������������������������������������� 347
Data Preparation������������������������������������������������������������������������������������������������������������������ 349
Model Training��������������������������������������������������������������������������������������������������������������������� 351
Evaluation���������������������������������������������������������������������������������������������������������������������������� 353
Developing a Real-Time Face Recognition System������������������������������������������������������������������� 354
Face Detection Model���������������������������������������������������������������������������������������������������������� 354
Classifier for Face Recognition�������������������������������������������������������������������������������������������� 355
Summary���������������������������������������������������������������������������������������������������������������������������������� 360

Chapter 9: Industrial Application: Real-Time Defect Detection in Industrial


Manufacturing������������������������������������������������������������������������������������������������������ 361
Real-Time Surface Defect Detection System���������������������������������������������������������������������������� 362
Dataset�������������������������������������������������������������������������������������������������������������������������������� 362
Google Colab Notebook������������������������������������������������������������������������������������������������������� 364
Data Transformation������������������������������������������������������������������������������������������������������������ 365
Training the SSD Model������������������������������������������������������������������������������������������������������� 374

xi
Table of Contents

Exporting the Model������������������������������������������������������������������������������������������������������������ 377


Model Evaluation����������������������������������������������������������������������������������������������������������������� 378
Prediction���������������������������������������������������������������������������������������������������������������������������� 379
Real-Time Defect Detector�������������������������������������������������������������������������������������������������� 380
Image Annotations�������������������������������������������������������������������������������������������������������������������� 380
Installing VoTT��������������������������������������������������������������������������������������������������������������������� 381
Create Connections������������������������������������������������������������������������������������������������������������� 382
Create a New Project����������������������������������������������������������������������������������������������������������� 383
Create Class Labels������������������������������������������������������������������������������������������������������������� 384
Label the Images����������������������������������������������������������������������������������������������������������������� 385
Export Labels����������������������������������������������������������������������������������������������������������������������� 386
Summary���������������������������������������������������������������������������������������������������������������������������������� 387

Chapter 10: Computer Vision Modeling on the Cloud������������������������������������������� 389


TensorFlow Distributed Training������������������������������������������������������������������������������������������������ 390
What Is Distributed Training?����������������������������������������������������������������������������������������������� 390
TensorFlow Distribution Strategy���������������������������������������������������������������������������������������� 393
TF_CONFIG: TensorFlow Cluster Configuration�������������������������������������������������������������������� 398
Example Code of Distributed Training with a Parameter Server����������������������������������������������� 400
Steps for Running Distributed Training on the Cloud���������������������������������������������������������������� 404
Distributed Training on Google Cloud���������������������������������������������������������������������������������������� 406
Signing Up for GCP Access�������������������������������������������������������������������������������������������������� 406
Creating a Google Cloud Storage Bucket����������������������������������������������������������������������������� 407
Creating the GCS Bucket from the Web UI��������������������������������������������������������������������������� 407
Creating the GCS Bucket from the Cloud Shell�������������������������������������������������������������������� 409
Launching GCP Virtual Machines����������������������������������������������������������������������������������������� 410
SSH to Log In to Each VMs�������������������������������������������������������������������������������������������������� 414
Uploading the Code for Distributed Training or Cloning the GitHub Repository������������������� 415
Installing Prerequisites and TensorFlow������������������������������������������������������������������������������ 415
Running Distributed Training����������������������������������������������������������������������������������������������� 416
Distributed Training on Azure���������������������������������������������������������������������������������������������������� 417

xii
Table of Contents

Creating a VM with Multiple GPUs on Azure������������������������������������������������������������������������ 418


Installing GPU Drivers and Libraries������������������������������������������������������������������������������������ 422
Creating virtualenv and Installing TensorFlow��������������������������������������������������������������������� 424
Implementing MirroredStrategy������������������������������������������������������������������������������������������ 424
Running Distributed Training����������������������������������������������������������������������������������������������� 425
Distributed Training on AWS������������������������������������������������������������������������������������������������������ 428
Horovod������������������������������������������������������������������������������������������������������������������������������� 428
How to Use Horovod������������������������������������������������������������������������������������������������������������ 429
Creating a Horovod Cluster on AWS������������������������������������������������������������������������������������� 433
Installing Horovod���������������������������������������������������������������������������������������������������������������� 440
Running Horovod to Execute Distributed Training��������������������������������������������������������������� 441
Summary���������������������������������������������������������������������������������������������������������������������������������� 442

Index��������������������������������������������������������������������������������������������������������������������� 443

xiii
About the Author
Shamshad (Sam) Ansari is president and CEO of Accure
Inc., an artificial intelligence automation company that he
founded. He has raised Accure from startup to a sustainable
business by building a winning team and acquiring customers
from across the globe. He has technical expertise in the areas
of computer vision, machine learning, AI, cognitive science,
NLP, and big data. He architected, designed, and developed
the Momentum platform that automates AI solution
development. He is an inventor and has four US patents in the
areas of AI and cognitive computing.
Shamshad previously worked as a senior software engineer with IBM, as VP of
engineering with Orbit Solutions, and as principal architect and director of engineering
with Apixio.

xv
About the Technical Reviewer
James Baldo is an associate professor at George Mason
University in the Volgenau School of Engineering and the
director of the Data Analytics Engineering (DAEN) Program.
His 38 years as a practicing engineer has provided him
with a broad foundation of knowledge and experience
in data analytics and engineering systems. His data
analytics interests span the areas of data engineering, data
science, and data architecture with a focus on data-centric
applications. His software engineering expertise has been
in support of deploying applications to cloud-based environments and microservice
architectures. As director of the DAEN Program, he has been responsible for developing
and coordinating its new online program offering. He holds a BS in chemistry, MS in
chemistry, MS in computer engineering, and PhD in information technology/software
engineering. He enjoys canoeing, hiking, and golf, and he lives in Manassas, Virginia,
with his wife.

xvii
Other documents randomly have
different content
CHAPTER XLVIII.

I n the market-place, which is in shape very like a brick, is a temple


of Aphrodite called the Brick Aphrodite, and a stone statue of the
goddess. And there are two pillars, on one of which are effigies of
Antiphanes and Crisus and Tyronidas and Pyrrhias, who are held in
honour to this day as legislators for Tegea, and on the other pillar
Iasius, with his left hand on a horse and in his right hand a branch of
palm. He won they say the horserace at Olympia, when Hercules the
Theban established the Olympian games. Why a crown of wild olive
was given to the victor at Olympia I have shown in my account of
Elis, and why of laurel at Delphi I shall show hereafter. And at the
Isthmian games pine, at the Nemean games parsley, were wont to
be the prize, as we know from the cases of Palæmon and
Archemorus. But most games have a crown of palm as the prize,
and everywhere the palm is put into the right hand of the victor. The
beginning of this custom was as follows. When Theseus was
returning from Crete he instituted games they say to Apollo at Delos,
and himself crowned the victors with palm. This was they say the
origin of the custom, and Homer has mentioned the palm in Delos in
that part of the Odyssey where Odysseus makes his supplication to
the daughter of Alcinous.[45]
There is also a statue of Ares called Gynæcothœnas in the market-
place at Tegea, graven on a pillar. For in the Laconian war, at the
first invasion of Charillus the king of the Lacedæmonians, the women
took up arms, and lay in ambush under the hill called in our day
Phylactris. And when the armies engaged, and the men on both
sides exhibited splendid bravery, then they say the women appeared
on the scene, and caused the rout of the Lacedæmonians, and
Marpessa, called the Widow, excelled all the other women in daring,
and among other Spartans Charillus was taken prisoner, and was
released without ransom, upon swearing to the people of Tegea that
he would never again lead a Lacedæmonian army to Tegea, which
oath he afterwards violated. And the women privately sacrificed to
Ares independently of the men for the victory, and gave no share of
the flesh of the victim to the men. That is why Ares was called
Gynæcothœnas (i.e. Women’s Feast). There is also an altar and
square statue of Adult Zeus. Square statues the Arcadians seem
greatly to delight in. There are also here the tombs of Tegeates the
son of Lycaon, and Mæra the wife of Tegeates, who they say was
the daughter of Atlas, and is mentioned by Homer[46] in Odysseus’
account to Alcinous of his journey to Hades and the souls he saw
there. And in the market-place at Tegea there is a temple of Ilithyia,
and a statue called Auge on her knees, and the tradition is that Aleus
ordered Nauplius to take his daughter Auge and drown her in the
sea, and as she was being led there she fell on her knees, and gave
birth to a son on the spot where is now the temple of Ilithyia. This
tradition differs from another one, which states that Auge gave birth
to Telephus unbeknown to her father, and that he was exposed on
Mount Parthenium and suckled by a doe, though this last part of the
tradition is also recorded by the people of Tegea. And near the
temple of Ilithyia is an altar to Earth, and close to the altar is a pillar
in white stone, on which is a statue of Polybius the son of Lycortas,
and on another pillar is Elatus one of the sons of Arcas.
[45] Odyssey, vi. 162 sq.
[46] Odyssey, xi. 326.
CHAPTER XLIX.

A nd not far from the market-place is a theatre, and near it are the
bases of some brazen statues, the statues themselves are no
longer there. And an elegiac couplet on one of the bases says that
that was the statue of Philopœmen. This Philopœmen the Greeks
hold in the highest honour, both for his sagacity and exploits. As to
the lustre of his race his father Craugis was second to none of the
Arcadians of Megalopolis, but he dying when Philopœmen was quite
a boy his guardian was Cleander an exile from Mantinea, who had
come to live at Megalopolis after the troubles in his native place, and
had been on a footing of old friendship with the family of Craugis.
And Philopœmen had they say among other tutors Megalophanes
and Ecdelus: the sons of Arcesilaus were pupils they say of
Pitanæus. In size and strength he was inferior to none of the
Peloponnesians, but he was far from good-looking. He didn’t care
about contending in the games, but he cultivated his own piece of
ground, and was fond of hunting wild beasts. He read also they say
frequently the works of the most famous Greek sophists, and books
on the art of war, especially such as touched on strategy. He wished
in all things to make Epaminondas his model in his frame of mind
and exploits, but was not able in all points to come up to this. For
Epaminondas was especially mild and had his temper completely
under control, whereas Philopœmen was hot-tempered. But when
Cleomenes captured Megalopolis, Philopœmen was not dismayed at
this unexpected misfortune, but conveyed off safely two-thirds of the
adults and all the women and children to Messene, as the
Messenians were at that time their allies and well-disposed to them.
And when Cleomenes sent a message to these exiles that he was
sorry for what he had done, and that the people of Megalopolis might
return if they signed a treaty, Philopœmen persuaded all the citizens
to return only with arms in their hands, and not upon any conditions
or treaty. And in the battle which took place at Sellasia against
Cleomenes and the Lacedæmonians, in which the Achæans and
Arcadians from all the cities took part, and also Antigonus with an
army from Macedonia, Philopœmen took his place with the cavalry
at first, but when he saw that the issue of the battle turned on the
behaviour of the infantry he willingly became a footsoldier, and, as
he was displaying valour worthy of record, one of the enemy pierced
through both his thighs, and being so impeded he dropt on his knees
and was constrained to fall forwards, so that by the motion of his feet
the spear snapped off. And when Cleomenes and the
Lacedæmonians were defeated, and Philopœmen returned to the
camp, then the doctors cut out of his thighs the spearpoint and the
spear itself. And Antigonus, hearing and seeing his courage, was
anxious to invite him over to Macedonia. But he paid little heed to
Antigonus, and crossed over by ship to Crete, where a civil war was
raging, and became a captain of mercenaries. And on his return to
Megalopolis he was at once chosen by the Achæans commander of
their cavalry, and he made them the best cavalry in Greece. And
when the Achæans and all their allies fought at the river Larisus
against the men of Elis and the Ætolian force that aided the people
of Elis from kinsmanship, Philopœmen first slew with his own hands
Demophantus the commander of the enemy’s cavalry, and then put
to flight all the cavalry of the Ætolians and men of Elis.
CHAPTER L.

A nd as the Achæans left everything to him and made him


everybody, he changed the arms of the infantry, for, whereas
before they bore short spears and oblong shields like those in use
among the Celts and Persians (called thyrei and gerrha), he
persuaded them to wear breastplates and greaves, and also to use
the shields in use in Argolis and long spears. And when Machanidas
rose to power in Lacedæmon, and war again broke out between the
Achæans and the Lacedæmonians under him, Philopœmen was
commander in chief of the Achæan force, and in the battle of
Mantinea the light-armed Lacedæmonians beat the light-armed
troops of the Achæans, and Machanidas pressed upon them in their
flight, but Philopœmen forming his infantry into a square routed the
Lacedæmonian hoplites, and fell in with Machanidas as he was
returning from the pursuit and slew him. Thus the Lacedæmonians,
though they lost the battle, were more fortunate from their reverse
than one would have anticipated, for they were freed from their
tyrant. And not long after, when the Argives were celebrating the
Nemean games, Philopœmen happened to be present at the contest
of the harpers: and Pylades a native of Megalopolis (one of the most
noted harpers of the day who had carried off the victory at the
Pythian games), at that moment striking up the tune of the Milesian
Timotheus called Persæ, and commencing at the words

“Winning for Hellas the noble grace of freedom,”

all the Greeks gazed earnestly on Philopœmen, and signified by


clapping that they referred to him the words of the Ode. A similar
tribute of respect was I understand paid to Themistocles at Olympia,
where the whole theatre rose up on his entrance. Philip indeed, the
son of Demetrius, the king of the Macedonians, who also poisoned
Aratus of Sicyon, sent men to Megalopolis with orders to kill
Philopœmen, and though unsuccessful in this he was execrated by
all Greece. And the Thebans who had beaten the Megarians in
battle, and had already got inside the walls at Megara, through
treachery on the part of the Megarians, were so alarmed at the
arrival of Philopœmen to the rescue, that they went home again
without effecting their object. And again there rose up at Lacedæmon
a tyrant called Nabis, who attacked the Messenians first of the
Peloponnesians, and as he made his attack by night, when they had
no expectation of it, he took all Messene but the citadel, but upon
Philopœmen’s coming up the next day with an army he departed
from it on conditions of war.
And Philopœmen, when the time of his command expired, and other
Achæans were chosen as commanders, went a second time to
Crete and helped the Gortynians who were pressed hard in war. But
as the Arcadians were vexed with him for going abroad he returned
from Crete, and found the Romans at war with Nabis. And as the
Romans had equipped a fleet against Nabis, Philopœmen in his zeal
wished to take part in the contest, but being altogether without
experience of the sea, he unwittingly embarked on an unseaworthy
trireme, so that the Romans and their allies remembered the lines of
Homer, in his Catalogue of the ships, about the ignorance of the
Arcadians in maritime affairs.[47] And not many days after this naval
engagement Philopœmen and his regiment, taking advantage of a
dark night, set the camp of the Lacedæmonians at Gythium on fire.
Thereupon Nabis intercepted Philopœmen and all the Arcadians with
him on difficult ground, they were very brave but there were very few
of them. But Philopœmen changed the position of his troops, so that
the advantage of the ground rested with him and not with the enemy,
and, defeating Nabis and slaying many of the Lacedæmonians in
this night attack, raised his fame still higher among the Greeks. And
after this Nabis obtained from the Romans a truce for a certain
definite period, but before the time expired he was assassinated by a
man from Calydon, who had come ostensibly to negotiate an
alliance, but was really hostile, and had been suborned by the
Ætolians for this very purpose.
[47] Iliad, ii. 614.
CHAPTER LI.

A nd Philopœmen about this time made an incursion into Sparta,


and compelled the Lacedæmonians to join the Achæan League.
And not very long after Titus Flaminius, the commander in chief of
the Romans in Greece, and Diophanes the son of Diæus of
Megalopolis, who had been chosen at this time general of the
Achæans, marched against Lacedæmon, alleging that the
Lacedæmonians were plotting against the Romans: but
Philopœmen, although at present he was only a private individual,
shut the gates as they were coming in. And the Lacedæmonians, in
return for this service and for his success against both their tyrants,
offered him the house of Nabis, which was worth more than 100
talents; but he had a soul above money, and bade the
Lacedæmonians conciliate by their gifts instead of him those who
had persuasive powers with the people in the Achæan League. In
these words he referred they say to Timolaus. And he was chosen a
second time general of the Achæans. And as the Lacedæmonians at
that time were on the eve of a civil war, he exiled from the
Peloponnese about 300 of the ringleaders, and sold for slaves about
3000 of the Helots, and demolished the walls of Sparta, and ordered
the lads no longer to train according to the regulations of Lycurgus
but in the Achæan fashion. But the Romans afterwards restored to
them their national training. And when Antiochus (the descendant of
Seleucus Nicator) and the army of Syrians with him were defeated
by Manius and the Romans at Thermopylæ, and Aristænus of
Megalopolis urged the Achæans to do all that was pleasing to the
Romans and not to resist them at all, Philopœmen looked angrily at
him, and told him that he was hastening the fate of Greece. And
when Manius was willing to receive the Lacedæmonian fugitives, he
resisted this proposal before the Council. But on Manius’ departure,
he permitted the fugitives to return to Sparta.
But vengeance was about to fall on Philopœmen for his haughtiness.
For when he was appointed general of the Achæans for the 8th time,
he twitted a man not without some renown for having allowed the
enemy to capture him alive: and not long after, as there was a
dispute between the Messenians and Achæans, he sent Lycortas
with an army to ravage Messenia: and himself the third day
afterwards, though he was suffering from a fever and was more than
70, hurried on to share in the action of Lycortas, at the head of about
60 cavalry and targeteers. And Lycortas and his army returned home
without having done or received any great harm. But Philopœmen,
who had been wounded in the head in the action and had fallen off
his horse, was taken alive to Messene. And in a meeting which the
Messenians immediately held there were many different opinions as
to what they should do with him. Dinocrates and the wealthy
Messenians were urgent to put him to death: but the popular party
were most anxious to save him alive, calling him even the father of
all Greece. But Dinocrates in spite of the popular party took
Philopœmen off by poison. And Lycortas not long after collected a
force from Arcadia and from Achaia and marched against Messene,
and the popular party in Messene at once fraternized with them, and
all except Dinocrates who were privy to the murder of Philopœmen
were put to death. And he committed suicide. And the Arcadians
brought the remains of Philopœmen to Megalopolis.
CHAPTER LII.

A nd now Greece ceased to produce a stock of distinguished men.


Miltiades the son of Cimon, who defeated the barbarians that
landed at Marathon, and checked the Persian host, was the first
public benefactor of Greece, and Philopœmen the son of Craugis the
last. For those who before Miltiades had displayed conspicuous
valour, (as Codrus the son of Melanthus, and the Spartan Polydorus,
and the Messenian Aristomenes), had all clearly fought for their own
nation and not for all Greece. And after Miltiades Leonidas (the son
of Anaxandrides) and Themistocles (the son of Neocles) expelled
Xerxes from Greece, the latter by his two sea-fights, the former by
the action at Thermopylæ. And Aristides the son of Lysimachus, and
Pausanias the son of Cleombrotus, who commanded at Platæa,
were prevented from being called benefactors of Greece, the latter
by his subsequent crimes, the former by his laying tribute on the
Greek islanders, for before Aristides all the Greek dominions were
exempt from taxation. And Xanthippus the son of Ariphron, in
conjunction with Leotychides king of Sparta, destroyed the Persian
fleet off Mycale, and Cimon did many deeds to excite the emulation
of the Greeks. As for those who won the greatest renown in the
Peloponnesian war, one might say that they with their own hands
almost ruined Greece. And when Greece was already in pitiful plight,
Conon the son of Timotheus and Epaminondas the son of Polymnis
recovered it somewhat, the former in the islands and maritime parts,
the latter by ejecting the Lacedæmonian garrisons and governors
inland, and by putting down the decemvirates. Epaminondas also
made Greece more considerable by the addition of the well-known
towns of Messene and the Arcadian Megalopolis. I consider also
Leosthenes and Aratus the benefactors of all Greece, for
Leosthenes against the wishes of Alexander brought back safe to
Greece in ships 50,000 Greeks who had served under the pay of
Persia: as for Aratus I have already touched upon him in my account
of Sicyon.
And the following is the inscription on Philopœmen at Tegea.
“Spread all over Greece is the fame and glory of the Arcadian warrior
Philopœmen, as wise in the council-chamber as brave in the field,
who attained such eminence in war as cavalry leader. Two trophies
won he over two Spartan tyrants, and when slavery was growing he
abolished it. And therefore Tegea has erected this statue to the high
souled son of Craugis, the blameless winner of his country’s
freedom.”
CHAPTER LIII.

T hat is the inscription at Tegea. And the statues erected to Apollo


Aguieus by the people of Tegea were dedicated they say for the
following reason. Apollo and Artemis punished they say in every
place all persons who, when Leto was pregnant and wandering
about Arcadia, neglected and took no account of her. And when
Apollo and Artemis came into the district of Tegea, then they say
Scephrus, the son of Tegeates, went up to Apollo and had a private
conversation with him. And Limon his brother, thinking Scephrus was
making some charge against him, ran at his brother and slew him.
But swift vengeance came upon Limon, for Artemis at once
transfixed him with an arrow. And Tegeates and Mera forthwith
sacrificed to Apollo and Artemis, and afterwards when a mighty
famine came upon the land the oracle at Delphi told them to mourn
for Scephrus. Accordingly they pay honours to him at the festival of
Apollo Aguieus, and the priestess of Artemis pursues some one,
pretending that she is Artemis pursuing Limon. And the remaining
sons of Tegeates, Cydon and Archedius and Gortys, migrated they
say of their own accord to Crete, and gave their names to the towns
Cydonia and Gortys and Catreus. But the Cretans do not accept the
tradition of the people of Tegea, they say that Cydon was the son of
Acacallis the daughter of Minos and Hermes, and that Catreus was
the son of Minos, and Gortys the son of Rhadamanthus. About
Rhadamanthus Homer says, in the conversation between Proteus
and Menelaus, that Menelaus went to the Elysian fields, and before
him Rhadamanthus: and Cinæthon in his verses represents
Rhadamanthus as the son of Hephæstus, and Hephæstus as the
son of Talos, and Talos as the son of Cres. The traditions of the
Greeks are mostly different and especially in genealogies. And the
people of Tegea have 4 statues of Apollo Aguieus, one erected by
each tribe. And the names of the tribes are Clareotis, Hippothœtis,
Apolloniatis, and Atheneatis, the two former so called from the lots
which Arcas made his sons cast for the land, and from Hippothous
the son of Cercyon.
There is also at Tegea a temple to Demeter and Proserpine, the
goddesses whom they call Fruit-giving, and one near to Paphian
Aphrodite, which was erected by Laodice, who was, as I have stated
before, a daughter of that Agapenor who led the Arcadians to Troy,
and dwelt at Paphos. And not far from it are two temples to
Dionysus, and an altar to Proserpine, and a temple and gilt statue of
Apollo, the statue by Chirisophus, a Cretan by race, whose age and
master we do not know. But the stay of Dædalus at Minos’ court in
Crete, and the statues which he made, has brought much greater
fame to Crete. And near Apollo is a stone statue of Chirisophus
himself.
And the people of Tegea have an altar which they call common to all
Arcadians, where there is a statue of Hercules. He is represented as
wounded in the thigh with the wound he received in the first fight
which he had with the sons of Hippocoon. And the lofty place
dedicated to Zeus Clarius, where most of the altars at Tegea are, is
no doubt so called from the lots which the sons of Arcas cast. And
the people of Tegea have an annual festival there, and they say the
Lacedæmonians once invaded their territory at the time of the
festival, and the god sent snow, and they were cold, and weary from
the weight of their armour, and the people of Tegea unbeknown to
the enemy lit a fire, (and so they were not incommoded with the
cold), and put on their armour, and went out against them, and
overcame them in the action. I have also seen at Tegea the following
sights, the house of Aleus, and the tomb of Echemus, and a
representation on a pillar of the fight between Echemus and Hyllus.
As you go from Tegea towards Laconia, there is an altar of Pan on
the left of the road, and another of Lycæan Zeus, and there are ruins
of temples. Their altars are about 2 stades from the walls, and about
seven stades further is a temple of Artemis called Limnatis, and a
statue of the goddess in ebony. The workmanship is called
Æginætan by the Greeks. And about 10 stades further are ruins of
the temple of Artemis Cnaceatis.
CHAPTER LIV.

T he boundary between the districts of the Lacedæmonians and


Tegea is the river Alpheus, which rises at Phylace, and not far
from its source another river flows into it formed from several
unimportant streams, and that is why the place is called the Meeting
of the Waters. And the Alpheus seems in the following particular to
be contrary in its nature to all other rivers, it is frequently lost in the
ground and comes up again. For starting from Phylace and the
Meeting of the Waters it is lost in the plain of Tegea, and reappears
again at Asea, and after mixing its stream with the Eurotas is a
second time lost in the ground: and emerging again at what the
Arcadians call the Wells, and flowing by the districts of Pisa and
Olympia, it falls into the sea beyond Cyllene, the arsenal of the
people of Elis. Nor can the Adriatic, though a big and stormy sea, bar
its onward passage, for it reappears at Ortygia in Syracuse, and
mixes its waters with the Arethusa.
The straight road, leading to Thyrea and the villages in the Thyreatic
district, is memorable for containing the tomb of Orestes the son of
Agamemnon, the people of Tegea say that a Spartan removed his
remains from thence, but in our day there is no tomb within the walls.
The river Garates also flows by the road, when you have crossed it
and gone on ten stades you come to a temple of Pan, and near it an
oak also sacred to Pan.
The road from Tegea to Argos is very well adapted for carriages and
is in fact quite a high road. The first thing you come to on it is a
temple and statue of Æsculapius, and after turning to the left for
about a stade you come to a temple of Pythian Apollo quite fallen to
decay and in ruins. And on the high road are many oaks and a
temple of Demeter, called Demeter of Corythes, in a grove of oaks,
and near it is a temple to Mystic Dionysus. And next comes Mount
Parthenium, on which is shown an enclosure sacred to Telephus,
where they say he was exposed as a boy and brought up by a doe.
And at a little distance is the temple of Pan, where both the
Athenians and people of Tegea say that Pan appeared to Philippides
and had an interview with him. Mount Parthenium also has tortoises
admirably adapted for making lyres of, which the men who live on
the mountain fear to take and will not allow strangers to take, for they
consider them sacred to Pan. When you have crossed over the
mountain top you come in what is now arable land to the boundary
between the districts of Tegea and Argos, viz. Hysiæ in Argolis.
These are the divisions of the Peloponnese, and the towns in the
divisions, and the most notable things in each town.
BOOK IX.—BŒOTIA.
CHAPTER I.

B œotia is contiguous to Attica, and Platæa to Eleutheræ. The


Bœotians got that name for all the race from Bœotus, who they
say was the son of Itonus the son of Amphictyon and the Nymph
Melanippe. Their towns are called sometimes after men but more
frequently after women. The Platæans were I think the original
inhabitants of the land, and they got their name from Platæa the
daughter of the river-god Asopus. That they were originally ruled
over by kings is I think clear: for in old times kingdoms were all over
Greece, there were no democratic governments. But the Platæans
know of no other kings but Asopus and still earlier Cithæron, one of
whom gave his name to the mountain and the other to the river. And
I cannot but think that Platæa, who gave her name to the town, was
the daughter of the king Asopus and not of the river-god.
The Platæans did nothing memorable before the battle which the
Athenians fought at Marathon, but they took part in that struggle after
the landing of Xerxes, and ventured to embark on ships with the
Athenians, and repelled on their own soil Mardonius, the son of
Gobryas, the General of Xerxes. And it twice happened to them to
be driven from their country and again restored to it. For in the
Peloponnesian war the Lacedæmonians besieged and took Platæa:
and when, after the peace which Antalcidas the Spartan negotiated
between the Greeks and the king of the Persians, it was reinhabited
by the Platæans who returned from Athens, a second misfortune
was it seems destined to come upon them. For war was not openly
declared against the Thebans, but the Platæans said that they were
still at peace with them, because when the Lacedæmonians
occupied Cadmea, they had no share either in suggesting it or in
bringing it about. The Thebans on the other hand said that it was the
Lacedæmonians who had brought about the peace, and who
afterwards when they had violated it thought that all had broken
truce. The Platæans therefore, thinking the conduct of the Thebans
rather suspicious, occupied their town with a strong garrison, and the
farmers did not even go into the fields which were at some distance
from the town at every period of the day, but watched for the times
when the Thebans held their general meetings, and at such times
tilled their farms in quiet. But Neocles, who was at that time
Bœotarch at Thebes, and had noticed this cunning on the part of the
Platæans, told all the Thebans to go armed to the assembly, and led
them from Thebes not straight across the plain but in the direction of
Hysiæ and Eleutheræ and Attica, where no outposts had been
placed by the Platæans, and got to the walls about mid-day. For the
Platæans, thinking the Thebans were at their meeting, had shut the
gates and gone out to the fields. And the Thebans made conditions
with those who were in the town that they should leave the place
before sunset, the men with one dress and the women with two. At
this time the fortune of the Platæans was rather different from the
former occasion when the town was taken by the Lacedæmonians
and Archidamus. For then the Lacedæmonians blockaded them and
shut them in by a double wall so that they could not get out, whereas
now the Thebans prevented their getting into the town at all. This
second capture of Platæa was the third year after Leuctra, when
Asteus was Archon at Athens. And the town was rased to the ground
by the Thebans entirely except the temples, but there was no sack,
and the Athenians took in the Platæans a second time. But when
Philip was victorious at Chæronea, he introduced a garrison into
Thebes, and among other things to destroy the Theban power,
restored the Platæans.
CHAPTER II.

I f you turn off a little to the right from the high road in the Platæan
district near Mount Cithæron, you come to the ruins of Hysiæ and
Erythræ. They were formerly cities, and among the ruins of Hysiæ
there is still a temple of Apollo half-finished, and a Holy Well, of
which whoever drank in former days prophesied, if we may believe
the tradition of the Bœotians. And on your return to the high road on
the right is what is said to be the tomb of Mardonius. It is admitted
that the dead body of Mardonius was missing after the battle, but as
to who buried him there are different traditions. What is certain is that
Artontes the son of Mardonius gave many gifts to the Ephesian
Dionysophanes, and also to several Ionians, for not having
neglected his father’s burial. And this road leads from Eleutheræ to
Platæa.
As you go from Megara there is a spring on the right hand, and a
little further a rock called the bed of Actæon, because they say he
used to sleep on that rock when tired with hunting, and in that spring
they say he saw Artemis bathing. And Stesichorus of Himera has
represented the goddess as dressing Actæon in a deerskin, so that
his dogs should devour him, that he should not be married to
Semele. But I think that madness came upon the dogs of Actæon
without the intervention of the goddess, and if they were mad and did
not distinguish him they would rend in pieces whoever they met. In
what part of Mount Cithæron Pentheus the son of Echion met with
his fate, or where they exposed Œdipus after his birth, no one
knows, as we do know the cross-roads on the way to Phocis where
Œdipus slew his father. Mount Cithæron is sacred to Zeus of
Cithæron, but I shall enter into all that more fully when I come to that
part of my subject.
Near the entrance to Platæa is the tomb of those who fell fighting
against the Medes. The other Greeks have one common tomb. But
the Lacedæmonians and Athenians who fell have separate burial-
grounds, and some elegiac lines of Simonides as their epitaph. And
not far from the common tomb of the Greeks is the altar of Zeus
Eleutherius. The tombs are of brass, but the altar and statue of Zeus
are of white stone. And they celebrate still every fifth year the festival
called Eleutheria, in which the chief prizes are for running: they run
in heavy armour in front of the altar. And the Greeks set up a trophy
about 15 stades from the town for the battle at Platæa.
In the town of Platæa, as you go on from the altar and statue erected
to Zeus Eleutherius, is a hero-chapel to Platæa, I have already
stated the traditions about her and my own views. There is also a
temple of Hera, well worth seeing for its size and the beauty of the
statues. As you enter it Rhea is before you carrying to Cronos the
stone wrapt up in swaddling-clothes, pretending it was the child she
had just given birth to. And the Hera here they call Full-Grown, her
statue is a large one in a standing position. Both these statues are in
Pentelican marble by Praxiteles. There is also another statue of Hera
in a sitting position by Callimachus, they call this statue The Bride for
the following reason.
CHAPTER III.

T hey say Hera for some reason or other was displeased with
Zeus and went to Eubœa, and Zeus when he could not appease
her went to Cithæron (who ruled at Platæa), who was inferior to no
one in ingenuity. He recommended Zeus to make a wooden statue
and dress it up and draw it in a waggon with a yoke of oxen, and
give out that he intended to marry Platæa the daughter of Asopus.
And he did as Cithæron instructed him. And directly Hera heard of it
she returned at once, and approached the waggon and tore the
clothes of the statue, and was delighted with the trick when she
found a wooden image instead of a young bride, and was reconciled
to Zeus. In memory of this reconciliation they have a festival called
Dædala, because statues were of old called dædala. And they called
them so I think before the times of Dædalus the Athenian, the son of
Palamaon, for he was called Dædalus I take it from his statues, and
not from his birth up. This festival is celebrated by the Platæans
every seventh year, according to what my Antiquarian guide
informed me, but really at less interval: the exact time however
between one festival and the next though I wished I could not
ascertain. The festival is celebrated as follows. There is an oak-
coppice not far from Alalcomenæ. Of all the oaks in Bœotia the roots
of these are the finest. When the Platæans come to this oak-
coppice, they place there portions of boiled meat. And they do not
much trouble themselves about other birds, but they watch crows
very carefully, for they frequent the place, and if one of them seizes a
piece of meat they watch what tree it sits upon. And on whatever tree
it perches, they carve their wooden image, called dædalum, from the
wood of this tree. This is the way the Platæans privately celebrate
their little festival Dædala: but the great festival of Dædala is a
festival for all Bœotia and celebrated every sixth year; for that was
the interval during which the festival was discontinued when the
Platæans were in exile. And 14 wooden statues are provided by
them every year for the little festival Dædala, which the following
draw lots for, the Platæans, the Coronæans, the Thespians, the

You might also like