{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys \n",
    "sys.path.append('..')\n",
    "from other_methods.naive_methods import NaiveUB\n",
    "from other_methods.fast_lip import FastLip\n",
    "from other_methods.lip_sdp import LipSDPCustom\n",
    "from relu_nets import ReLUNet\n",
    "import torch\n",
    "import utilities as utils\n",
    "import numpy as np\n",
    "import math\n",
    "from hyperbox import Hyperbox"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_net = ReLUNet(layer_sizes=[4, 8, 2])\n",
    "c_vector = torch.Tensor([1.0, -1.0])\n",
    "unit_box = Hyperbox.build_unit_hypercube(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OrderedDict([('net.1.weight', tensor([[ 0.0212, -0.0917, -0.0906, -0.4288],\n",
       "                      [-0.4812,  0.1337, -0.2397, -0.4050],\n",
       "                      [ 0.3524,  0.3337, -0.4407, -0.4151],\n",
       "                      [ 0.3953,  0.0675,  0.2073, -0.4014],\n",
       "                      [ 0.2890, -0.2250, -0.3594, -0.0486],\n",
       "                      [ 0.3335,  0.2712, -0.3172, -0.4008],\n",
       "                      [ 0.4938, -0.2738,  0.4043,  0.1801],\n",
       "                      [ 0.1890, -0.2067, -0.2551,  0.0694]])),\n",
       "             ('net.1.bias',\n",
       "              tensor([-0.3068,  0.2009, -0.0279,  0.3875, -0.3636, -0.4715, -0.0987, -0.3619])),\n",
       "             ('net.3.weight',\n",
       "              tensor([[-0.2325, -0.0566, -0.1652, -0.2985, -0.0982,  0.1358,  0.2578,  0.2221],\n",
       "                      [ 0.1448, -0.1361,  0.0125,  0.0910,  0.1834, -0.2188, -0.1910, -0.3182]])),\n",
       "             ('net.3.bias', tensor([ 0.1638, -0.3486]))])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_net.state_dict()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fast_lip = FastLip(test_net, c_vector, unit_box, 'linf')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fast_lip.compute()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_net.random_max_grad(unit_box, c_vector, 1000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
