Official source code repository for "Deep Learning with Swift for TensorFlow" book.
π @ Amazon (Paperback / Kindle) / ο£Ώ Books / Apress / SpringerLink
Discover more insight about deep learning algorithms with Swift for TensorFlow. The Swift language was designed by Apple for optimized performance and development whereas TensorFlow library was designed by Google for advanced machine learning research. Swift for TensorFlow is a combination of both with support for modern hardware accelerators and more. This book covers the deep learning concepts from fundamentals to advanced research. It also introduces the Swift language for beginners in programming. This book is well suited for newcomers and experts in programming and deep learning alike. After reading this book you should be able to program various state-of-the-art deep learning algorithms yourself.
The book covers foundational concepts of machine learning. It also introduces the mathematics required to understand deep learning. Swift language is introduced such that it allows beginners and researchers to understand programming and easily transit to Swift for TensorFlow, respectively. You will understand the nuts and bolts of building and training neural networks, and build advanced algorithms.
- Understand deep learning concepts
- Program various deep learning algorithms
- Run the algorithms in cloud
- Newcomers to programming and/or deep learning, and experienced developers.
- Experienced deep learning practitioners and researchers who desire to work in user space instead of library space with a same programming language without compromising the speed.
β1.1 Machine Learning
ββ1.1.1 Experience
ββ1.1.2 Task
ββ1.1.3 Performance Measure
β1.2 Machine Learning Paradigms
ββ1.2.1 Supervised Learning
ββ1.2.2 Unsupervised Learning
ββ1.2.3 Semi-supervised Learning
ββ1.2.4 Reinforcement Learning
β1.3 Maximum Likelihood Estimation
β1.4 Elements of a Machine Learning Algorithm
ββ1.4.1 Data
ββ1.4.2 Models
ββ1.4.3 Loss Function
ββ1.4.4 Optimizer
ββ1.4.5 Regularizer
β1.5 Bias and Variance Trade-Off
β1.6 Why Deep Learning?
ββ1.6.1 Curse of Dimensionality
ββ1.6.2 Invalid Smoothness Assumption
ββ1.6.3 Deep Learning Advantages
β1.7 Summary
β2.1 Linear Algebra
ββ2.1.1 Matrices and Vectors
ββ2.1.2 Unary Matrix Operations
ββ2.1.3 Binary Matrix Operations
ββ2.1.4 Norms
β2.2 Probability Theory
ββ2.2.1 Joint Probability
ββ2.2.2 Conditional Probability
ββ2.2.3 Elementary Rules
ββ2.2.4 Chain Rule
ββ2.2.5 Bayes Rule
β2.3 Differential Calculus
ββ2.3.1 Function
ββ2.3.2 Differentiation of Univariate Function
ββ2.3.3 Differentiation of Multivariate Function
ββ2.3.4 Differentiation of Vector Function
ββ2.3.5 Differentiation of Matrix Function
β2.4 Summary
β3.1 Swift is Everywhere
β3.2 Swift for TensorFlow
β3.3 Algorithmic Differentiation
ββ3.3.1 Programming Approaches
ββ3.3.2 Accumulation Modes
ββ3.3.3 Implementation Approaches
β3.4 Swift Language
ββ3.4.1 Values
ββ3.4.2 Collections
ββ3.4.3 Control Flow
ββ3.4.4 Closures and Functions
ββ3.4.5 Custom Types
ββ3.4.6 Modern Features
ββ3.4.7 Error Handling
ββ3.4.8 Advanced Operators
ββ3.4.9 Differentiation
β3.5 Python Interoperability
β3.6 Summary
β4.1 Tensor
β4.2 Dataset Loading
ββ4.2.1 Epochs and Batches
β4.3 Defining Model
ββ4.3.1 Neural Network Protocols
ββ4.3.2 Sequence of Layers
β4.4 Training and Testing
ββ4.4.1 Checkpointing
ββ4.4.2 Model Optimization
ββ4.4.3 TrainingLoop
β4.5 From Scratch for Research
ββ4.5.1 Layer
ββ4.5.2 Activation Function
ββ4.5.3 Loss Function
ββ4.5.4 Optimizer
β4.6 Summary
β5.1 Gradient-Based Optimization
ββ5.1.1 Maxima, Minima, and Saddle Points
ββ5.1.2 Input Optimization
ββ5.1.3 Parameters Optimization
β5.2 Linear Models
ββ5.2.1 Regression
ββ5.2.2 Classification
β5.3 Deep Neural Network
ββ5.3.1 Dense Neural Network
β5.4 Activation Functions
ββ5.4.1 Sigmoid
ββ5.4.2 Softmax
ββ5.4.3 ReLU
ββ5.4.4 ELU
ββ5.4.5 Leaky ReLU
ββ5.4.6 SELU
β5.5 Loss Functions
ββ5.5.1 Sum of Squares
ββ5.5.2 Sigmoid Cross-Entropy
ββ5.5.3 Softmax Cross-Entropy
β5.6 Optimization
ββ5.6.1 Gradient Descent
ββ5.6.2 Momentum
β5.7 Regularization
ββ5.7.1 Dataset
ββ5.7.2 Architecture
ββ5.7.3 Loss Function
ββ5.7.4 Optimization
β5.8 Summary
β6.1 Convolutional Neural Network
ββ6.1.1 Convolution Layer
ββ6.1.2 Dimensions Calculation
ββ6.1.3 Pooling Layer
ββ6.1.4 Upsampling
β6.2 Prominent Features
ββ6.2.1 Local Connectivity
ββ6.2.2 Parameter Sharing
ββ6.2.3 Translation Equivariance
β6.3 Shortcut Connection
β6.4 Image Recognition
β6.5 Conclusion
- First, you should install the latest Swift for TensorFlow toolchain.
- But to run only differentiation-specific code (for instance, the source code of Differentiable Programming chapter) not requiring deep learning features, simply install the latest Swift toolchain snapshot from Swift.org under Trunk Development (main) section. (The future differentiation feature updates will be posted on this website and will go through the standard Swift Evolution process.)
- Then you must select the newly installed toolchain in Xcode from
Preferences (Command + ,) > Components > Toolchains > (Swift for TensorFlow or Swift Development Snapshot)
.
This Swift package offers various executable targets listed in Package.swift.
List of all executable targets:
AdvancedOperators
AlgorithmicDifferentiation
Arrays
Classes
Closures
ConditionalStatements
ControlTransfer
Dictionaries
Differentiation
EarlyExit
Enumerations
ErrorHandling
Extensions
Generics
GlobalFunctions
Loops
NestedFunctions
Protocols
PythonInteroperability
Sets
Structures
Values
EpochAndBatches
FromScratchForResearch
ModelDefinition
TensorExplanation
TrainingAndTesting
TrainingLoopExample
InputOptimization
LinearRegression
ParametersOptimization
PolynomialRegression
ImageRecognition
Select the executable target (for instance, AlgorithmicDifferentiation
) from the scheme drop-down menu and then click the Run button. And result should be presented in the console.
To execute any of them first enter into this package's root directory.
cd deep-learning-with-swift-for-tensorflow-book
Then run the following command in terminal.
swift run AlgorithmicDifferentiation
The following output will be displayed.
expression value: 30.0
expression derivative: 28.0
Just replace AlgorithmicDifferentiation
with any executable target you wish to run.
Note: This Swift package was tested on Xcode 12.5 running on macOS version 11.3. It should also work right out of the box on Linux distributions.