{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Advanced Model Architectures\n", "> It's time to get introduced to more advanced architectures! You will create an autoencoder to reconstruct noisy images, visualize convolutional neural network activations, use deep pre-trained models to classify images and learn more about recurrent neural networks and working with text as you build a network that predicts the next word in a sentence. This is the Summary of lecture \"Introduction to Deep Learning with Keras\", via datacamp.\n", "\n", "- toc: true \n", "- badges: true\n", "- comments: true\n", "- author: Chanseok Kang\n", "- categories: [Python, Datacamp, Tensorflow-Keras, Deep_Learning]\n", "- image: images/dog.png" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import tensorflow as tf\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "\n", "plt.rcParams['figure.figsize'] = (8, 8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Tensors, layers, and autoencoders\n", "- Tensors\n", " - main data structures used in deep learning.\n", " - Inputs/Outputs and transformations in neural networks are all presented using tensors\n", "- Autoencoders\n", "![ae](image/ae.png)\n", " - Use cases\n", " - Dimensionality reduction:\n", " - Smaller dimensional space representation of our inputs\n", " - De-noising data:\n", " - If trained with clean data, irrelevant noise will be filtered out during reconstruction\n", " - Anormaly detection\n", " - A poor reconstruction will result when the model is fed with unseen inputs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### It's a flow of tensors\n", "If you have already built a model, you can use the `model.layers` and the `tf.keras.backend` to build functions that, provided with a valid input tensor, return the corresponding output tensor.\n", "\n", "This is a useful tool when we want to obtain the output of a network at an intermediate layer.\n", "\n", "For instance, if you get the input and output from the first layer of a network, you can build an `inp_to_out` function that returns the result of carrying out forward propagation through only the first layer for a given input tensor.\n", "\n", "So that's what you're going to do right now!" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | variace | \n", "skewness | \n", "curtosis | \n", "entropy | \n", "class | \n", "
---|---|---|---|---|---|
0 | \n", "3.62160 | \n", "8.6661 | \n", "-2.8073 | \n", "-0.44699 | \n", "0 | \n", "
1 | \n", "4.54590 | \n", "8.1674 | \n", "-2.4586 | \n", "-1.46210 | \n", "0 | \n", "
2 | \n", "3.86600 | \n", "-2.6383 | \n", "1.9242 | \n", "0.10645 | \n", "0 | \n", "
3 | \n", "3.45660 | \n", "9.5228 | \n", "-4.0112 | \n", "-3.59440 | \n", "0 | \n", "
4 | \n", "0.32924 | \n", "-4.4552 | \n", "4.5718 | \n", "-0.98880 | \n", "0 | \n", "