⚡ Neural Networks with TensorFlow and Keras

In the previous notebook we wrote a neural network by hand, derivatives included: what Emma calls level 0 in her notes (section 6.8). This notebook climbs the other levels of her "building": automatic differentiation with TensorFlow, standard layers with Keras and ready-made models with scikit-learn. With Keras it builds the convolutional network that Emma designs for the Minermont dermatology project (section 6.4), layer by layer and parameter by parameter, on synthetic images of skin lesions.

The interactive notebook includes:

  • Level 1, automatic differentiation: TensorFlow computes the gradients of Martha's example, and they match the ones computed by hand.
  • Level 2, the Keras API: a small network that solves XOR.
  • Synthetic 28 × 28 images of benign, suspicious and malignant lesions.
  • The book's convolutional network, with its parameters counted layer by layer, trained with early stopping.
  • Evaluation on the test images: accuracy, the confusion matrix and per-class precision and recall.
  • What the network sees: the filters of the first convolution and their feature maps.
  • Level 3: a scikit-learn network on the same images, and why it does much worse than the convolutional network.

Want to modify the code and experiment on your own?
Open the notebook in Google Colab

Bibliography