Transfer learning and fine-tuning

Guide to taking pre-trained models and adpating them to new, similar tasks.

Setup

library(tensorflow)
library(keras)
printf <- function(...) writeLines(sprintf(...))

Introduction

Transfer learning consists of taking features learned on one problem, and leveraging them on a new, similar problem. For instance, features from a model that has learned to identify racoons may be useful to kick-start a model meant to identify skunks.

Transfer learning is usually done for tasks where your dataset has too little data to train a full-scale model from scratch.

The most common incarnation of transfer learning in the context of deep learning is the following workflow:

  1. Take layers from a previously trained model.
  2. Freeze them, so as to avoid destroying any of the information they contain during future training rounds.
  3. Add some new, trainable layers on top of the frozen layers. They will learn to turn the old features into predictions on a new dataset.
  4. Train the new layers on your dataset.

A last, optional step, is fine-tuning, which consists of unfreezing the entire model you obtained above (or part of it), and re-training it on the new data with a very low learning rate. This can potentially achieve meaningful improvements, by incrementally adapting the pretrained features to the new data.

First, we will go over the Keras trainable API in detail, which underlies most transfer learning and fine-tuning workflows.

Then, we’ll demonstrate the typical workflow by taking a model pretrained on the ImageNet dataset, and retraining it on the Kaggle “cats vs dogs” classification dataset.

This is adapted from Deep Learning with R and the 2016 blog post “building powerful image classification models using very little data”.

Freezing layers: understanding the trainable attribute

Layers and models have three weight attributes:

  • weights is the list of all weights variables of the layer.
  • trainable_weights is the list of those that are meant to be updated (via gradient descent) to minimize the loss during training.
  • non_trainable_weights is the list of those that aren’t meant to be trained. Typically they are updated by the model during the forward pass.

Example: the Dense layer has 2 trainable weights (kernel and bias)

layer <- layer_dense(units = 3)
layer$build(shape(NULL, 4))

printf("weights: %s", length(layer$weights))
weights: 2
printf("trainable_weights: %s", length(layer$trainable_weights))
trainable_weights: 2
printf("non_trainable_weights: %s", length(layer$non_trainable_weights))
non_trainable_weights: 0

In general, all weights are trainable weights. The only built-in layer that has non-trainable weights is layer_batch_normalization(). It uses non-trainable weights to keep track of the mean and variance of its inputs during training. To learn how to use non-trainable weights in your own custom layers, see the guide to writing new layers from scratch.

Example: The layer instance returned by layer_batch_normalization() has 2 trainable weights and 2 non-trainable weights

layer <- layer_batch_normalization()
layer$build(shape(NULL, 4))

printf("weights: %s", length(layer$weights))
weights: 4
printf("trainable_weights: %s", length(layer$trainable_weights))
trainable_weights: 2
printf("non_trainable_weights: %s", length(layer$non_trainable_weights))
non_trainable_weights: 2

Layers and models also feature a boolean attribute trainable. Its value can be changed. Setting layer$trainable to FALSE moves all the layer’s weights from trainable to non-trainable. This is called “freezing” the layer: the state of a frozen layer won’t be updated during training (either when training with fit() or when training with any custom loop that relies on trainable_weights to apply gradient updates).

Example: setting trainable to False

layer = layer_dense(units = 3)
layer$build(shape(NULL, 4))  # Create the weights
layer$trainable <- FALSE     # Freeze the layer

printf("weights: %s", length(layer$weights))
weights: 2
printf("trainable_weights: %s", length(layer$trainable_weights))
trainable_weights: 0
printf("non_trainable_weights: %s", length(layer$non_trainable_weights))
non_trainable_weights: 2

When a trainable weight becomes non-trainable, its value is no longer updated during training.

# Make a model with 2 layers
layer1 <- layer_dense(units = 3, activation = "relu")
layer2 <- layer_dense(units = 3, activation = "sigmoid")
model <- keras_model_sequential(input_shape = c(3)) %>%
  layer1() %>%
  layer2()

# Freeze the first layer
layer1$trainable <- FALSE

# Keep a copy of the weights of layer1 for later reference
initial_layer1_weights_values <- get_weights(layer1)

# Train the model
model %>% compile(optimizer = "adam", loss = "mse")
model %>% fit(k_random_normal(c(2, 3)), k_random_normal(c(2, 3)))

# Check that the weights of layer1 have not changed during training
final_layer1_weights_values <- get_weights(layer1)
stopifnot(all.equal(initial_layer1_weights_values, final_layer1_weights_values))

Do not confuse the layer$trainable attribute with the training argument in a layer instance’s call signature layer(training =) (which controls whether the layer should run its forward pass in inference mode or training mode). For more information, see the Keras FAQ.

Recursive setting of the trainable attribute

If you set trainable = FALSE on a model or on any layer that has sublayers, all child layers become non-trainable as well.

Example:

inner_model <- keras_model_sequential(input_shape = c(3)) %>%
  layer_dense(3, activation = "relu") %>%
  layer_dense(3, activation = "relu")

model <- keras_model_sequential(input_shape = c(3)) %>%
  inner_model() %>%
  layer_dense(3, activation = "sigmoid")


model$trainable <- FALSE  # Freeze the outer model

stopifnot(inner_model$trainable == FALSE)             # All layers in `model` are now frozen
stopifnot(inner_model$layers[[1]]$trainable == FALSE)  # `trainable` is propagated recursively

The typical transfer-learning workflow

This leads us to how a typical transfer learning workflow can be implemented in Keras:

  1. Instantiate a base model and load pre-trained weights into it.
  2. Freeze all layers in the base model by setting trainable = FALSE.
  3. Create a new model on top of the output of one (or several) layers from the base model.
  4. Train your new model on your new dataset.

Note that an alternative, more lightweight workflow could also be:

  1. Instantiate a base model and load pre-trained weights into it.
  2. Run your new dataset through it and record the output of one (or several) layers from the base model. This is called feature extraction.
  3. Use that output as input data for a new, smaller model.

A key advantage of that second workflow is that you only run the base model once on your data, rather than once per epoch of training. So it’s a lot faster and cheaper.

An issue with that second workflow, though, is that it doesn’t allow you to dynamically modify the input data of your new model during training, which is required when doing data augmentation, for instance. Transfer learning is typically used for tasks when your new dataset has too little data to train a full-scale model from scratch, and in such scenarios data augmentation is very important. So in what follows, we will focus on the first workflow.

Here’s what the first workflow looks like in Keras:

First, instantiate a base model with pre-trained weights.

base_model <- application_xception(
  weights = 'imagenet', # Load weights pre-trained on ImageNet.
  input_shape = c(150, 150, 3),
  include_top = FALSE # Do not include the ImageNet classifier at the top.
)

Then, freeze the base model.

base_model$trainable <- FALSE

Create a new model on top.

inputs <- layer_input(c(150, 150, 3))

outputs <- inputs %>%
  # We make sure that the base_model is running in inference mode here,
  # by passing `training=FALSE`. This is important for fine-tuning, as you will
  # learn in a few paragraphs.
  base_model(training=FALSE) %>%

  # Convert features of shape `base_model$output_shape[-1]` to vectors
  layer_global_average_pooling_2d() %>%

  # A Dense classifier with a single unit (binary classification)
  layer_dense(1)

model <- keras_model(inputs, outputs)

Train the model on new data.

model %>%
  compile(optimizer = optimizer_adam(),
          loss = loss_binary_crossentropy(from_logits = TRUE),
          metrics = metric_binary_accuracy()) %>%
  fit(new_dataset, epochs = 20, callbacks = ..., validation_data = ...)

Fine-tuning

Once your model has converged on the new data, you can try to unfreeze all or part of the base model and retrain the whole model end-to-end with a very low learning rate.

This is an optional last step that can potentially give you incremental improvements. It could also potentially lead to quick overfitting – keep that in mind.

It is critical to only do this step after the model with frozen layers has been trained to convergence. If you mix randomly-initialized trainable layers with trainable layers that hold pre-trained features, the randomly-initialized layers will cause very large gradient updates during training, which will destroy your pre-trained features.

It’s also critical to use a very low learning rate at this stage, because you are training a much larger model than in the first round of training, on a dataset that is typically very small. As a result, you are at risk of overfitting very quickly if you apply large weight updates. Here, you only want to re-adapt the pretrained weights in an incremental way.

This is how to implement fine-tuning of the whole base model:

# Unfreeze the base model
base_model$trainable <- TRUE

# It's important to recompile your model after you make any changes
# to the `trainable` attribute of any inner layer, so that your changes
# are taken into account
model %>% compile(
  optimizer = optimizer_adam(1e-5), # Very low learning rate
  loss = loss_binary_crossentropy(from_logits = TRUE),
  metrics = metric_binary_accuracy()
)

# Train end-to-end. Be careful to stop before you overfit!
model %>% fit(new_dataset, epochs=10, callbacks=..., validation_data=...)

Important note about compile() and trainable

Calling compile() on a model is meant to “freeze” the behavior of that model. This implies that the trainable attribute values at the time the model is compiled should be preserved throughout the lifetime of that model, until compile is called again. Hence, if you change any trainable value, make sure to call compile() again on your model for your changes to be taken into account.

Important notes about layer_batch_normalization()

Many image models contain BatchNormalization layers. That layer is a special case on every imaginable count. Here are a few things to keep in mind.

  • BatchNormalization contains 2 non-trainable weights that get updated during training. These are the variables tracking the mean and variance of the inputs.
  • When you set bn_layer$trainable = FALSE, the BatchNormalization layer will run in inference mode, and will not update its mean and variance statistics. This is not the case for other layers in general, as weight trainability and inference/training modes are two orthogonal concepts. But the two are tied in the case of the BatchNormalization layer.
  • When you unfreeze a model that contains BatchNormalization layers in order to do fine-tuning, you should keep the BatchNormalization layers in inference mode by passing training = FALSE when calling the base model. Otherwise the updates applied to the non-trainable weights will suddenly destroy what the model has learned.

You’ll see this pattern in action in the end-to-end example at the end of this guide.

Transfer learning and fine-tuning with a custom training loop

If instead of fit(), you are using your own low-level training loop, the workflow stays essentially the same. You should be careful to only take into account the list model$trainable_weights when applying gradient updates:

# Create base model
base_model = application_xception(
  weights = 'imagenet',
  input_shape = c(150, 150, 3),
  include_top = FALSE
)

# Freeze base model
base_model$trainable = FALSE

# Create new model on top.
inputs <- layer_input(shape = c(150, 150, 3))
outputs <- inputs %>%
  base_model(training = FALSE) %>%
  layer_global_average_pooling_2d() %>%
  layer_dense(1)
model <- keras_model(inputs, outputs)

loss_fn <- loss_binary_crossentropy(from_logits = TRUE)
optimizer <- optimizer_adam()

# helper to zip gradients with weights
xyz <- function(...) .mapply(c, list(...), NULL)

# Iterate over the batches of a dataset.
library(tfdatasets)
new_dataset <- ...

while(!is.null(batch <- iter_next(new_dataset))) {
  c(inputs, targets) %<-% batch
  # Open a GradientTape.
  with(tf$GradientTape() %as% tape, {
    # Forward pass.
    predictions = model(inputs)
    # Compute the loss value for this batch.
    loss_value = loss_fn(targets, predictions)
  })
  # Get gradients of loss w.r.t. the *trainable* weights.
  gradients <- tape$gradient(loss_value, model$trainable_weights)
  # Update the weights of the model.
  optimizer$apply_gradients(xyz(gradients, model$trainable_weights))
}

Likewise for fine-tuning.

An end-to-end example: fine-tuning an image classification model on a cats vs. dogs dataset

To solidify these concepts, let’s walk you through a concrete end-to-end transfer learning and fine-tuning example. We will load the Xception model, pre-trained on ImageNet, and use it on the Kaggle “cats vs. dogs” classification dataset.

Getting the data

First, let’s fetch the cats vs. dogs dataset using TFDS. If you have your own dataset, you’ll probably want to use the utility image_dataset_from_directory() to generate similar labeled dataset objects from a set of images on disk filed into class-specific folders.

Transfer learning is most useful when working with very small datasets. To keep our dataset small, we will use 40% of the original training data (25,000 images) for training, 10% for validation, and 10% for testing.

# reticulate::py_install("tensorflow_datasets", pip = TRUE)
tfds <- reticulate::import("tensorflow_datasets")

c(train_ds, validation_ds, test_ds) %<-% tfds$load(
    "cats_vs_dogs",
    # Reserve 10% for validation and 10% for test
    split = c("train[:40%]", "train[40%:50%]", "train[50%:60%]"),
    as_supervised=TRUE  # Include labels
)

printf("Number of training samples: %d", length(train_ds))
Number of training samples: 9305
printf("Number of validation samples: %d", length(validation_ds) )
Number of validation samples: 2326
printf("Number of test samples: %d", length(test_ds))
Number of test samples: 2326

These are the first 9 images in the training dataset – as you can see, they’re all different sizes.

library(tfdatasets)

par(mfrow = c(3, 3), mar = c(1,0,1.5,0))
train_ds %>%
  dataset_take(9) %>%
  as_array_iterator() %>%
  iterate(function(batch) {
    c(image, label) %<-% batch
    plot(as.raster(image, max = 255))
    title(sprintf("label: %s   size: %s",
                  label, paste(dim(image), collapse = " x ")))
  })

We can also see that label 1 is “dog” and label 0 is “cat”.

Standardizing the data

Our raw images have a variety of sizes. In addition, each pixel consists of 3 integer values between 0 and 255 (RGB level values). This isn’t a great fit for feeding a neural network. We need to do 2 things:

  • Standardize to a fixed image size. We pick 150x150.
  • Normalize pixel values between -1 and 1. We’ll do this using a layer_normalization() as part of the model itself.

In general, it’s a good practice to develop models that take raw data as input, as opposed to models that take already-preprocessed data. The reason being that, if your model expects preprocessed data, any time you export your model to use it elsewhere (in a web browser, in a mobile app), you’ll need to reimplement the exact same preprocessing pipeline. This gets very tricky very quickly. So we should do the least possible amount of preprocessing before hitting the model.

Here, we’ll do image resizing in the data pipeline (because a deep neural network can only process contiguous batches of data), and we’ll do the input value scaling as part of the model, when we create it.

Let’s resize images to 150x150:

library(magrittr, include.only = "%<>%")
size <- as.integer(c(150, 150))
train_ds      %<>% dataset_map(function(x, y) list(tf$image$resize(x, size), y))
validation_ds %<>% dataset_map(function(x, y) list(tf$image$resize(x, size), y))
test_ds       %<>% dataset_map(function(x, y) list(tf$image$resize(x, size), y))

Besides, let’s batch the data and use caching and prefetching to optimize loading speed.

dataset_cache_batch_prefetch <- function(dataset, batch_size = 32, buffer_size = 10) {
  dataset %>%
    dataset_cache() %>%
    dataset_batch(batch_size) %>%
    dataset_prefetch(buffer_size)
}

train_ds      %<>% dataset_cache_batch_prefetch()
validation_ds %<>% dataset_cache_batch_prefetch()
test_ds       %<>% dataset_cache_batch_prefetch()

Using random data augmentation

When you don’t have a large image dataset, it’s a good practice to artificially introduce sample diversity by applying random yet realistic transformations to the training images, such as random horizontal flipping or small random rotations. This helps expose the model to different aspects of the training data while slowing down overfitting.

data_augmentation <- keras_model_sequential() %>%
  layer_random_flip("horizontal") %>%
  layer_random_rotation(.1)

Let’s visualize what the first image of the first batch looks like after various random transformations:

batch <- train_ds %>%
  dataset_take(1) %>%
  as_iterator() %>% iter_next()

c(images, labels) %<-% batch
first_image <- images[1, all_dims(), drop = FALSE]
augmented_image <- data_augmentation(first_image, training = TRUE)

plot_image <- function(image, main = deparse1(substitute(image))) {
  image %>%
    k_squeeze(1) %>% # drop batch dim
    as.array() %>%   # convert from tensor to R array
    as.raster(max = 255) %>%
    plot()

  if(!is.null(main))
    title(main)
}

par(mfrow = c(2, 2), mar = c(1, 1, 1.5, 1))
plot_image(first_image)
plot_image(augmented_image)
plot_image(data_augmentation(first_image, training = TRUE), "augmented 2")
plot_image(data_augmentation(first_image, training = TRUE), "augmented 3")

Build a model

Now let’s build a model that follows the blueprint we’ve explained earlier.

Note that:

  • We add layer_rescaling() to scale input values (initially in the [0, 255] range) to the [-1, 1] range.
  • We add a layer_dropout() before the classification layer, for regularization.
  • We make sure to pass training = FALSE when calling the base model, so that it runs in inference mode, so that batchnorm statistics don’t get updated even after we unfreeze the base model for fine-tuning.
base_model = application_xception(
  weights = "imagenet", # Load weights pre-trained on ImageNet.
  input_shape = c(150, 150, 3),
  include_top = FALSE # Do not include the ImageNet classifier at the top.
)

# Freeze the base_model
base_model$trainable <- FALSE

# Create new model on top
inputs <- layer_input(shape = c(150, 150, 3))

outputs <- inputs %>%
  data_augmentation() %>%   # Apply random data augmentation

  # Pre-trained Xception weights requires that input be scaled
  # from (0, 255) to a range of (-1., +1.), the rescaling layer
  # outputs: `(inputs * scale) + offset`
  layer_rescaling(scale = 1 / 127.5, offset = -1) %>%

  # The base model contains batchnorm layers. We want to keep them in inference mode
  # when we unfreeze the base model for fine-tuning, so we make sure that the
  # base_model is running in inference mode here.
  base_model(training = FALSE) %>%
  layer_global_average_pooling_2d() %>%
  layer_dropout(.2) %>%
  layer_dense(1)

model <- keras_model(inputs, outputs)
model
Model: "model_1"
____________________________________________________________________________
 Layer (type)                Output Shape              Param #   Trainable  
============================================================================
 input_7 (InputLayer)        [(None, 150, 150, 3)]     0         Y          
 sequential_3 (Sequential)   (None, 150, 150, 3)       0         Y          
 rescaling (Rescaling)       (None, 150, 150, 3)       0         Y          
 xception (Functional)       (None, 5, 5, 2048)        20861480  N          
 global_average_pooling2d_1   (None, 2048)             0         Y          
 (GlobalAveragePooling2D)                                                   
 dropout (Dropout)           (None, 2048)              0         Y          
 dense_8 (Dense)             (None, 1)                 2049      Y          
============================================================================
Total params: 20,863,529
Trainable params: 2,049
Non-trainable params: 20,861,480
____________________________________________________________________________

Train the top layer

model %>% compile(
  optimizer = optimizer_adam(),
  loss = loss_binary_crossentropy(from_logits = TRUE),
  metrics = metric_binary_accuracy()
)

epochs <- 2
model %>% fit(train_ds, epochs = epochs, validation_data = validation_ds)

Do a round of fine-tuning of the entire model

Finally, let’s unfreeze the base model and train the entire model end-to-end with a low learning rate.

Importantly, although the base model becomes trainable, it is still running in inference mode since we passed training = FALSE when calling it when we built the model. This means that the batch normalization layers inside won’t update their batch statistics. If they did, they would wreck havoc on the representations learned by the model so far.

# Unfreeze the base_model. Note that it keeps running in inference mode
# since we passed `training = FALSE` when calling it. This means that
# the batchnorm layers will not update their batch statistics.
# This prevents the batchnorm layers from undoing all the training
# we've done so far.
base_model$trainable <- TRUE
model
Model: "model_1"
____________________________________________________________________________
 Layer (type)                Output Shape              Param #   Trainable  
============================================================================
 input_7 (InputLayer)        [(None, 150, 150, 3)]     0         Y          
 sequential_3 (Sequential)   (None, 150, 150, 3)       0         Y          
 rescaling (Rescaling)       (None, 150, 150, 3)       0         Y          
 xception (Functional)       (None, 5, 5, 2048)        20861480  Y          
 global_average_pooling2d_1   (None, 2048)             0         Y          
 (GlobalAveragePooling2D)                                                   
 dropout (Dropout)           (None, 2048)              0         Y          
 dense_8 (Dense)             (None, 1)                 2049      Y          
============================================================================
Total params: 20,863,529
Trainable params: 20,809,001
Non-trainable params: 54,528
____________________________________________________________________________
model %>% compile(
  optimizer = optimizer_adam(1e-5),
  loss = loss_binary_crossentropy(from_logits = TRUE),
  metrics = metric_binary_accuracy()
)

epochs <- 1
model %>% fit(train_ds, epochs = epochs, validation_data = validation_ds)

After 10 epochs, fine-tuning gains us a nice improvement here.

Environment Details

tensorflow::tf_config()
TensorFlow v2.11.0 (~/.virtualenvs/r-tensorflow-website/lib/python3.10/site-packages/tensorflow)
Python v3.10 (~/.virtualenvs/r-tensorflow-website/bin/python)
sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.5 LTS

Matrix products: default
BLAS:   /home/tomasz/opt/R-4.2.1/lib/R/lib/libRblas.so
LAPACK: /usr/lib/x86_64-linux-gnu/libmkl_intel_lp64.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] magrittr_2.0.3        tfdatasets_2.9.0.9000 keras_2.9.0.9000     
[4] tensorflow_2.9.0.9000

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9           pillar_1.8.1         compiler_4.2.1      
 [4] base64enc_0.1-3      tools_4.2.1          zeallot_0.1.0       
 [7] digest_0.6.31        jsonlite_1.8.4       evaluate_0.18       
[10] lifecycle_1.0.3      tibble_3.1.8         lattice_0.20-45     
[13] pkgconfig_2.0.3      png_0.1-8            rlang_1.0.6         
[16] Matrix_1.5-3         cli_3.4.1            yaml_2.3.6          
[19] xfun_0.35            fastmap_1.1.0        stringr_1.5.0       
[22] knitr_1.41           generics_0.1.3       vctrs_0.5.1         
[25] htmlwidgets_1.5.4    tidyselect_1.2.0     rprojroot_2.0.3     
[28] grid_4.2.1           reticulate_1.26-9000 glue_1.6.2          
[31] here_1.0.1           R6_2.5.1             fansi_1.0.3         
[34] rmarkdown_2.18       whisker_0.4.1        htmltools_0.5.4     
[37] tfruns_1.5.1         utf8_1.2.2           stringi_1.7.8       
system2(reticulate::py_exe(), c("-m pip freeze"), stdout = TRUE) |> writeLines()
absl-py==1.3.0
asttokens==2.2.1
astunparse==1.6.3
backcall==0.2.0
cachetools==5.2.0
certifi==2022.12.7
charset-normalizer==2.1.1
decorator==5.1.1
dill==0.3.6
etils==0.9.0
executing==1.2.0
flatbuffers==22.12.6
gast==0.4.0
google-auth==2.15.0
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
googleapis-common-protos==1.57.0
grpcio==1.51.1
h5py==3.7.0
idna==3.4
importlib-resources==5.10.1
ipython==8.7.0
jedi==0.18.2
kaggle==1.5.12
keras==2.11.0
keras-tuner==1.1.3
kt-legacy==1.0.4
libclang==14.0.6
Markdown==3.4.1
MarkupSafe==2.1.1
matplotlib-inline==0.1.6
numpy==1.23.5
oauthlib==3.2.2
opt-einsum==3.3.0
packaging==22.0
pandas==1.5.2
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.3.0
promise==2.3
prompt-toolkit==3.0.36
protobuf==3.19.6
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pydot==1.4.2
Pygments==2.13.0
pyparsing==3.0.9
python-dateutil==2.8.2
python-slugify==7.0.0
pytz==2022.6
PyYAML==6.0
requests==2.28.1
requests-oauthlib==1.3.1
rsa==4.9
scipy==1.9.3
six==1.16.0
stack-data==0.6.2
tensorboard==2.11.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow==2.11.0
tensorflow-datasets==4.7.0
tensorflow-estimator==2.11.0
tensorflow-hub==0.12.0
tensorflow-io-gcs-filesystem==0.28.0
tensorflow-metadata==1.12.0
termcolor==2.1.1
text-unidecode==1.3
toml==0.10.2
tqdm==4.64.1
traitlets==5.7.1
typing_extensions==4.4.0
urllib3==1.26.13
wcwidth==0.2.5
Werkzeug==2.2.2
wrapt==1.14.1
zipp==3.11.0
TF Devices:
-  PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU') 
-  PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU') 
CPU cores: 12 
Date rendered: 2022-12-16 
Page render time: 1 minutes and 48 seconds