Prepare

Due: October 22, 2024

prepare
Modified

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:

Warning

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

{keras} vs. {keras3}

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.

Note

{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.