{ "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 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": [ { "name": "stderr", "output_type": "stream", "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" ] }, { "data": { "text/html": [ "
\n", " | content | \n", "score | \n", "
---|---|---|
0 | \n", "Update: After getting a response from the deve... | \n", "1 | \n", "
1 | \n", "Used it for a fair amount of time without any ... | \n", "1 | \n", "
2 | \n", "Your app sucks now!!!!! Used to be good but no... | \n", "1 | \n", "
3 | \n", "It seems OK, but very basic. Recurring tasks n... | \n", "1 | \n", "
4 | \n", "Absolutely worthless. This app runs a prohibit... | \n", "1 | \n", "