{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Increase the speed and reduce the memory consumption by pruning layers of models.\n", "\n", "In this tutorial, we will show you how you can prune and train a model using AutoNLU on a custom dataset. More precisely, we at first prune 50% of the layers of a model and train it afterwards to to predict reviews of the Google Play store similar to tutorial 02.\n", "\n", "Note: We recommend using a machine with an Nvidia GPU for this tutorial." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "!pip install pandas -q" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import autonlu\n", "from autonlu import Model\n", "import pandas as pd\n", "import numpy as np\n", "import gdown\n", "from autonlu.utils import split_dataset" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "autonlu.login()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Download and prepare dataset\n", "At first, we automatically download and prepare the google play app reviews dataset. Note that this installs gdown in your pip environment." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "Downloading...\n", "From: https://drive.google.com/uc?id=1S6qMioqPJjyBLpLVz4gmRTnJHnjitnuV\n", "To: /home/david/Dev/deepopinion/autonlu/tutorials/.cache/data/googleplay/apps.csv\n", "100%|██████████| 134k/134k [00:00<00:00, 1.99MB/s]\n", "Downloading...\n", "From: https://drive.google.com/uc?id=1zdmewp7ayS4js4VtrJEHzAheSW-5NBZv\n", "To: /home/david/Dev/deepopinion/autonlu/tutorials/.cache/data/googleplay/reviews.csv\n", "7.17MB [00:00, 8.34MB/s]\n" ] }, { "output_type": "execute_result", "data": { "text/plain": [ " content score\n", "0 Update: After getting a response from the deve... 1\n", "1 Used it for a fair amount of time without any ... 1\n", "2 Your app sucks now!!!!! Used to be good but no... 1\n", "3 It seems OK, but very basic. Recurring tasks n... 1\n", "4 Absolutely worthless. This app runs a prohibit... 1" ], "text/html": "
\n | content | \nscore | \n
---|---|---|
0 | \nUpdate: After getting a response from the deve... | \n1 | \n
1 | \nUsed it for a fair amount of time without any ... | \n1 | \n
2 | \nYour app sucks now!!!!! Used to be good but no... | \n1 | \n
3 | \nIt seems OK, but very basic. Recurring tasks n... | \n1 | \n
4 | \nAbsolutely worthless. This app runs a prohibit... | \n1 | \n