{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "---\n",
    "description: 'First things first: let''s start with a good model!'\n",
    "---\n",
    "\n",
    "# Models\n",
    "\n",
    "Welcome to the \"**Models**\" tutorial of the \"_From Zero to Hero_\" series. In this notebook we will talk about the features offered by the `models` _Avalanche_ sub-module.\n",
    "\n",
    "### Models Support\n",
    "\n",
    "Every continual learning experiment needs a model to train incrementally. The `models` sub-module provide ready-to-use **randomly initialized** and **pre-trained** models you can use _off-the-shelf_.\n",
    "\n",
    "At the moment we support only the following architectures:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting git+https://github.com/ContinualAI/avalanche.git\n",
      "  Cloning https://github.com/ContinualAI/avalanche.git to c:\\users\\w-32\\appdata\\local\\temp\\pip-req-build-moztcfbq\n",
      "Requirement already satisfied: typing-extensions in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from avalanche==0.0.1) (3.7.4.3)\n",
      "Requirement already satisfied: psutil in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from avalanche==0.0.1) (5.8.0)\n",
      "Requirement already satisfied: gputil in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from avalanche==0.0.1) (1.4.0)\n",
      "Requirement already satisfied: tensorboard in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from avalanche==0.0.1) (2.4.1)\n",
      "Requirement already satisfied: scikit-learn in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from avalanche==0.0.1) (0.24.1)\n",
      "Requirement already satisfied: matplotlib in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from avalanche==0.0.1) (3.3.3)\n",
      "Requirement already satisfied: numpy in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from avalanche==0.0.1) (1.19.5)\n",
      "Requirement already satisfied: pytorchcv in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from avalanche==0.0.1) (0.0.61)\n",
      "Requirement already satisfied: quadprog in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from avalanche==0.0.1) (0.1.8)\n",
      "Requirement already satisfied: cycler>=0.10 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from matplotlib->avalanche==0.0.1) (0.10.0)\n",
      "Requirement already satisfied: pillow>=6.2.0 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from matplotlib->avalanche==0.0.1) (8.1.2)\n",
      "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from matplotlib->avalanche==0.0.1) (2.4.7)\n",
      "Requirement already satisfied: python-dateutil>=2.1 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from matplotlib->avalanche==0.0.1) (2.8.1)\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from matplotlib->avalanche==0.0.1) (1.3.1)\n",
      "Requirement already satisfied: six in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from cycler>=0.10->matplotlib->avalanche==0.0.1) (1.15.0)\n",
      "Requirement already satisfied: requests in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from pytorchcv->avalanche==0.0.1) (2.25.1)\n",
      "Requirement already satisfied: Cython in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from quadprog->avalanche==0.0.1) (0.29.22)\n",
      "Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from requests->pytorchcv->avalanche==0.0.1) (1.26.3)\n",
      "Requirement already satisfied: idna<3,>=2.5 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from requests->pytorchcv->avalanche==0.0.1) (2.10)\n",
      "Requirement already satisfied: chardet<5,>=3.0.2 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from requests->pytorchcv->avalanche==0.0.1) (3.0.4)\n",
      "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from requests->pytorchcv->avalanche==0.0.1) (2020.12.5)\n",
      "Requirement already satisfied: threadpoolctl>=2.0.0 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from scikit-learn->avalanche==0.0.1) (2.1.0)\n",
      "Requirement already satisfied: scipy>=0.19.1 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from scikit-learn->avalanche==0.0.1) (1.6.1)\n",
      "Requirement already satisfied: joblib>=0.11 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from scikit-learn->avalanche==0.0.1) (1.0.1)\n",
      "Requirement already satisfied: google-auth<2,>=1.6.3 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (1.27.1)\n",
      "Requirement already satisfied: setuptools>=41.0.0 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (52.0.0.post20210125)\n",
      "Requirement already satisfied: tensorboard-plugin-wit>=1.6.0 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (1.6.0)\n",
      "Requirement already satisfied: protobuf>=3.6.0 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (3.14.0)\n",
      "Requirement already satisfied: absl-py>=0.4 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (0.12.0)\n",
      "Requirement already satisfied: werkzeug>=0.11.15 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (1.0.1)\n",
      "Requirement already satisfied: wheel>=0.26 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (0.36.2)\n",
      "Requirement already satisfied: grpcio>=1.24.3 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (1.36.1)\n",
      "Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (0.4.1)\n",
      "Requirement already satisfied: markdown>=2.6.8 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from tensorboard->avalanche==0.0.1) (3.3.4)\n",
      "Requirement already satisfied: cachetools<5.0,>=2.0.0 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from google-auth<2,>=1.6.3->tensorboard->avalanche==0.0.1) (4.2.1)\n",
      "Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from google-auth<2,>=1.6.3->tensorboard->avalanche==0.0.1) (0.2.8)\n",
      "Requirement already satisfied: rsa<5,>=3.1.4 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from google-auth<2,>=1.6.3->tensorboard->avalanche==0.0.1) (4.7.2)\n",
      "Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard->avalanche==0.0.1) (1.3.0)\n",
      "Requirement already satisfied: pyasn1<0.5.0,>=0.4.6 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard->avalanche==0.0.1) (0.4.8)\n",
      "Requirement already satisfied: oauthlib>=3.0.0 in c:\\users\\w-32\\anaconda3\\envs\\avalanche-env\\lib\\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard->avalanche==0.0.1) (3.1.0)\n",
      "Building wheels for collected packages: avalanche\n",
      "  Building wheel for avalanche (setup.py): started\n",
      "  Building wheel for avalanche (setup.py): finished with status 'done'\n",
      "  Created wheel for avalanche: filename=avalanche-0.0.1-py3-none-any.whl size=253178 sha256=dbbd27511906e1178e756c66aa1d8e30bd42b8fbb2733591092d080ee2e3396e\n",
      "  Stored in directory: C:\\Users\\w-32\\AppData\\Local\\Temp\\pip-ephem-wheel-cache-8u60yid7\\wheels\\7c\\60\\00\\f27d86c929665acd1914cf44d9698f802eef0fa365ba3b2ddf\n",
      "Successfully built avalanche\n",
      "Installing collected packages: avalanche\n",
      "Successfully installed avalanche-0.0.1\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  Running command git clone -q https://github.com/ContinualAI/avalanche.git 'C:\\Users\\w-32\\AppData\\Local\\Temp\\pip-req-build-moztcfbq'\n"
     ]
    }
   ],
   "source": [
    "!pip install git+https://github.com/ContinualAI/avalanche.git"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "from avalanche.models import SimpleCNN\n",
    "from avalanche.models import SimpleMLP\n",
    "from avalanche.models import SimpleMLP_TinyImageNet\n",
    "from avalanche.models import MobilenetV1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "However, we plan to support in the near future all the models provided in the [Pytorch](https://pytorch.org/) official ecosystem models as well as the ones provided by [pytorchcv](https://pypi.org/project/pytorchcv/)!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 🤝 Run it on Google Colab\n",
    "\n",
    "You can run _this chapter_ and play with it on Google Colaboratory: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ContinualAI/colab/blob/master/notebooks/avalanche/models.ipynb)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}