Prepare
Due: October 22, 2024
Learning objectives
- Distinguish the major workflow differences between shallow and deep learning.
- Understand the basic architecture of a dense neural network.
- Implement deep learning models using Keras and the {keras3} package.
- Estimate a series of dense neural networks for text classification.
- Incorporate GLoVE word embeddings into a deep learning model.
Preparations
📖 Read
⌨️ Do
Run the following R script from your console to install the necessary packages and Python dependencies for deep learning:
Do not rely on any preexisting Python/Anaconda/pyenv installations on your system. The following script will install a base version of Python and create a virtual environment with all required Python libraries for deep learning. This will ensure that the Python environment is isolated from the rest of your system and will not interfere with any other Python installations you may have.1
1 BTW, I loathe managing Python environments.
# install a base version of Python
install.packages("reticulate")
library(reticulate)
install_python()
# install the keras3 package and create a virtual environment with all required Python libraries
install.packages("keras3")
library(keras3)
install_keras()
📚 Additional resources
- Deep learning with R (Second edition), by Sigrid Keydana, Francois Chollet, Tomasz Kalinowski, J.J. Allaire - excellent resource covering the fundamentals of deep learning (including mathematical background without being overly theoretical), along with many practical examples of deep learning models for classification, computer vision, text generation, etc., all implemented in R with the {keras} package.
The book uses the {keras} package, which is a wrapper around the Python library Keras. Since the book was published, the Python implementation of Keras was upgraded to version 3.0 which significantly changed the API to specify and fit deep learning models. The {keras} package has been superceded by the {keras3} package, which is a wrapper around the newer Keras 3.0 library. The {keras3} package is more up-to-date and has more features than the {keras} package. Many of the functions and examples from the book will require minimal-to-no change to work with the {keras3} package.
- Deep learning with Python (Second edition), by Francois Chollet - same as above, but with all code examples in Python using Keras. If you wish to use Python directly to fit deep learning models.
- Deep Learning and Scientific Computing with R torch, by Sigrid Keydana - a free online book that covers deep learning with R using the {torch} package, which is native R implementation of the Torch library. Unlike {keras3}, {torch} is completely implemented in R and has zero Python dependencies.
{keras3} can use Torch as a backend engine to fit a deep learning model while still using the same API to specify and fit the model (albeit through PyTorch instead of a native R implementation). The {torch} API is extremely different from {keras3} and requires a much stronger understanding of the fundamentals of neural networks and deep learning.