{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2020-09-02T22:54:03.624493Z",
     "iopub.status.busy": "2020-09-02T22:54:03.623202Z",
     "iopub.status.idle": "2020-09-02T22:54:03.626775Z",
     "shell.execute_reply": "2020-09-02T22:54:03.627468Z"
    },
    "papermill": {
     "duration": 0.024645,
     "end_time": "2020-09-02T22:54:03.627741",
     "exception": false,
     "start_time": "2020-09-02T22:54:03.603096",
     "status": "completed"
    },
    "pycharm": {
     "name": "#%%\n"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "# Factors of Clusterability Analysis: ImageNet networks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2020-09-02T22:54:03.646623Z",
     "iopub.status.busy": "2020-09-02T22:54:03.645770Z",
     "iopub.status.idle": "2020-09-02T22:54:08.108034Z",
     "shell.execute_reply": "2020-09-02T22:54:08.106594Z"
    },
    "papermill": {
     "duration": 4.472527,
     "end_time": "2020-09-02T22:54:08.108390",
     "exception": false,
     "start_time": "2020-09-02T22:54:03.635863",
     "status": "completed"
    },
    "pycharm": {
     "name": "#%%\n"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "import os\n",
    "# os.environ['CUDA_VISIBLE_DEVICES'] = ''\n",
    "sys.path.append('..')\n",
    "import pandas as pd\n",
    "from tqdm import tqdm\n",
    "from src.spectral_cluster_model import run_clustering_imagenet"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false,
    "execution": {
     "iopub.execute_input": "2020-09-03T06:25:11.943025Z",
     "iopub.status.busy": "2020-09-03T06:25:11.941929Z",
     "iopub.status.idle": "2020-09-04T17:42:14.160887Z",
     "shell.execute_reply": "2020-09-04T17:42:14.161850Z"
    },
    "papermill": {
     "duration": 127022.259768,
     "end_time": "2020-09-04T17:42:14.162216",
     "exception": false,
     "start_time": "2020-09-03T06:25:11.902448",
     "status": "completed"
    },
    "pycharm": {
     "name": "#%%\n"
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      "  0%|          | 0/6 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From /root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/ops/resource_variable_ops.py:1630: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "If using Keras pass *_constraint arguments to layers.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From /root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:4070: The name tf.nn.max_pool is deprecated. Please use tf.nn.max_pool2d instead.\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "--- Logging error ---\n",
      "Traceback (most recent call last):\n",
      "  File \"/usr/lib/python3.7/logging/__init__.py\", line 1028, in emit\n",
      "    stream.write(msg + self.terminator)\n",
      "ValueError: I/O operation on closed file.\n",
      "Call stack:\n",
      "  File \"/usr/lib/python3.7/runpy.py\", line 193, in _run_module_as_main\n",
      "    \"__main__\", mod_spec)\n",
      "  File \"/usr/lib/python3.7/runpy.py\", line 85, in _run_code\n",
      "    exec(code, run_globals)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel_launcher.py\", line 16, in <module>\n",
      "    app.launch_new_instance()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/traitlets/config/application.py\", line 664, in launch_instance\n",
      "    app.start()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelapp.py\", line 612, in start\n",
      "    self.io_loop.start()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/platform/asyncio.py\", line 149, in start\n",
      "    self.asyncio_loop.run_forever()\n",
      "  File \"/usr/lib/python3.7/asyncio/base_events.py\", line 534, in run_forever\n",
      "    self._run_once()\n",
      "  File \"/usr/lib/python3.7/asyncio/base_events.py\", line 1771, in _run_once\n",
      "    handle._run()\n",
      "  File \"/usr/lib/python3.7/asyncio/events.py\", line 88, in _run\n",
      "    self._context.run(self._callback, *self._args)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/ioloop.py\", line 690, in <lambda>\n",
      "    lambda f: self._run_callback(functools.partial(callback, future))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/ioloop.py\", line 743, in _run_callback\n",
      "    ret = callback()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 787, in inner\n",
      "    self.run()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 748, in run\n",
      "    yielded = self.gen.send(value)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelbase.py\", line 365, in process_one\n",
      "    yield gen.maybe_future(dispatch(*args))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 209, in wrapper\n",
      "    yielded = next(result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelbase.py\", line 268, in dispatch_shell\n",
      "    yield gen.maybe_future(handler(stream, idents, msg))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 209, in wrapper\n",
      "    yielded = next(result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelbase.py\", line 545, in execute_request\n",
      "    user_expressions, allow_stdin,\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 209, in wrapper\n",
      "    yielded = next(result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/ipkernel.py\", line 306, in do_execute\n",
      "    res = shell.run_cell(code, store_history=store_history, silent=silent)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/zmqshell.py\", line 536, in run_cell\n",
      "    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 2877, in run_cell\n",
      "    raw_cell, store_history, silent, shell_futures)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 2922, in _run_cell\n",
      "    return runner(coro)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/async_helpers.py\", line 68, in _pseudo_sync_runner\n",
      "    coro.send(None)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 3146, in run_cell_async\n",
      "    interactivity=interactivity, compiler=compiler, result=result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 3337, in run_ast_nodes\n",
      "    if (await self.run_code(code, result,  async_=asy)):\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 3417, in run_code\n",
      "    exec(code_obj, self.user_global_ns, self.user_ns)\n",
      "  File \"<ipython-input-6-5c733f8eae54>\", line 13, in <module>\n",
      "    num_workers=n_workers)\n",
      "  File \"../src/spectral_cluster_model.py\", line 1427, in run_clustering_imagenet\n",
      "    model = net((224, 224, 3), weights='imagenet')\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/classification_models/models_factory.py\", line 78, in wrapper\n",
      "    return func(*args, **new_kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras_applications/vgg16.py\", line 112, in VGG16\n",
      "    name='block1_conv1')(img_input)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/engine/base_layer.py\", line 463, in __call__\n",
      "    self.build(unpack_singleton(input_shapes))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/layers/convolutional.py\", line 141, in build\n",
      "    constraint=self.kernel_constraint)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/engine/base_layer.py\", line 282, in add_weight\n",
      "    constraint=constraint)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py\", line 620, in variable\n",
      "    value, dtype=dtype, name=name, constraint=constraint)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/keras/backend.py\", line 806, in variable\n",
      "    constraint=constraint)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/ops/variables.py\", line 260, in __call__\n",
      "    return cls._variable_v2_call(*args, **kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/ops/variables.py\", line 254, in _variable_v2_call\n",
      "    shape=shape)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/ops/variables.py\", line 235, in <lambda>\n",
      "    previous_getter = lambda **kws: default_variable_creator_v2(None, **kws)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/ops/variable_scope.py\", line 2552, in default_variable_creator_v2\n",
      "    shape=shape)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/ops/variables.py\", line 262, in __call__\n",
      "    return super(VariableMetaclass, cls).__call__(*args, **kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/ops/resource_variable_ops.py\", line 1406, in __init__\n",
      "    distribute_strategy=distribute_strategy)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/ops/resource_variable_ops.py\", line 1630, in _init_from_args\n",
      "    cached_value=cached_value)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/util/deprecation.py\", line 506, in new_func\n",
      "    instructions)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/platform/tf_logging.py\", line 166, in warning\n",
      "    get_logger().warning(msg, *args, **kwargs)\n",
      "Message: 'From %s: calling %s (from %s) with %s is deprecated and will be removed %s.\\nInstructions for updating:\\n%s'\n",
      "Arguments: ('/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/ops/resource_variable_ops.py:1630', 'BaseResourceVariable.__init__', 'tensorflow.python.ops.resource_variable_ops', 'constraint', 'in a future version', 'If using Keras pass *_constraint arguments to layers.')\n",
      "--- Logging error ---\n",
      "Traceback (most recent call last):\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/util/module_wrapper.py\", line 167, in __getattribute__\n",
      "    return attr_map[name]\n",
      "KeyError: 'max_pool'\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"/usr/lib/python3.7/logging/__init__.py\", line 1028, in emit\n",
      "    stream.write(msg + self.terminator)\n",
      "ValueError: I/O operation on closed file.\n",
      "Call stack:\n",
      "  File \"/usr/lib/python3.7/runpy.py\", line 193, in _run_module_as_main\n",
      "    \"__main__\", mod_spec)\n",
      "  File \"/usr/lib/python3.7/runpy.py\", line 85, in _run_code\n",
      "    exec(code, run_globals)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel_launcher.py\", line 16, in <module>\n",
      "    app.launch_new_instance()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/traitlets/config/application.py\", line 664, in launch_instance\n",
      "    app.start()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelapp.py\", line 612, in start\n",
      "    self.io_loop.start()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/platform/asyncio.py\", line 149, in start\n",
      "    self.asyncio_loop.run_forever()\n",
      "  File \"/usr/lib/python3.7/asyncio/base_events.py\", line 534, in run_forever\n",
      "    self._run_once()\n",
      "  File \"/usr/lib/python3.7/asyncio/base_events.py\", line 1771, in _run_once\n",
      "    handle._run()\n",
      "  File \"/usr/lib/python3.7/asyncio/events.py\", line 88, in _run\n",
      "    self._context.run(self._callback, *self._args)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/ioloop.py\", line 690, in <lambda>\n",
      "    lambda f: self._run_callback(functools.partial(callback, future))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/ioloop.py\", line 743, in _run_callback\n",
      "    ret = callback()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 787, in inner\n",
      "    self.run()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 748, in run\n",
      "    yielded = self.gen.send(value)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelbase.py\", line 365, in process_one\n",
      "    yield gen.maybe_future(dispatch(*args))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 209, in wrapper\n",
      "    yielded = next(result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelbase.py\", line 268, in dispatch_shell\n",
      "    yield gen.maybe_future(handler(stream, idents, msg))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 209, in wrapper\n",
      "    yielded = next(result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelbase.py\", line 545, in execute_request\n",
      "    user_expressions, allow_stdin,\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 209, in wrapper\n",
      "    yielded = next(result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/ipkernel.py\", line 306, in do_execute\n",
      "    res = shell.run_cell(code, store_history=store_history, silent=silent)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/zmqshell.py\", line 536, in run_cell\n",
      "    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 2877, in run_cell\n",
      "    raw_cell, store_history, silent, shell_futures)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 2922, in _run_cell\n",
      "    return runner(coro)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/async_helpers.py\", line 68, in _pseudo_sync_runner\n",
      "    coro.send(None)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 3146, in run_cell_async\n",
      "    interactivity=interactivity, compiler=compiler, result=result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 3337, in run_ast_nodes\n",
      "    if (await self.run_code(code, result,  async_=asy)):\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 3417, in run_code\n",
      "    exec(code_obj, self.user_global_ns, self.user_ns)\n",
      "  File \"<ipython-input-6-5c733f8eae54>\", line 13, in <module>\n",
      "    num_workers=n_workers)\n",
      "  File \"../src/spectral_cluster_model.py\", line 1427, in run_clustering_imagenet\n",
      "    model = net((224, 224, 3), weights='imagenet')\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/classification_models/models_factory.py\", line 78, in wrapper\n",
      "    return func(*args, **new_kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras_applications/vgg16.py\", line 117, in VGG16\n",
      "    x = layers.MaxPooling2D((2, 2), strides=(2, 2), name='block1_pool')(x)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/engine/base_layer.py\", line 489, in __call__\n",
      "    output = self.call(inputs, **kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/layers/pooling.py\", line 205, in call\n",
      "    data_format=self.data_format)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/layers/pooling.py\", line 268, in _pooling_function\n",
      "    pool_mode='max')\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py\", line 4070, in pool2d\n",
      "    x = tf.nn.max_pool(x, pool_size, strides,\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/util/module_wrapper.py\", line 187, in __getattribute__\n",
      "    self._tfmw_add_deprecation_warning(name, attr)):\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/util/module_wrapper.py\", line 139, in _tfmw_add_deprecation_warning\n",
      "    _call_location(), full_name, rename)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/platform/tf_logging.py\", line 166, in warning\n",
      "    get_logger().warning(msg, *args, **kwargs)\n",
      "Message: 'From %s: The name %s is deprecated. Please use %s instead.\\n'\n",
      "Arguments: ('/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:4070', 'tf.nn.max_pool', 'tf.nn.max_pool2d')\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      " 17%|█▋        | 1/6 [12:41<1:03:27, 761.52s/it]"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      " 33%|███▎      | 2/6 [30:24<56:48, 852.00s/it]  "
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      " 50%|█████     | 3/6 [47:40<45:21, 907.25s/it]"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      " 67%|██████▋   | 4/6 [1:33:55<48:55, 1467.61s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading data from https://github.com/qubvel/classification_models/releases/download/0.0.1/resnet50_imagenet_1000.h5\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\r",
      "     8192/102793104 [..............................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "    24576/102793104 [..............................] - ETA: 4:12"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "    57344/102793104 [..............................] - ETA: 3:37"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "    90112/102793104 [..............................] - ETA: 3:28"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "   196608/102793104 [..............................] - ETA: 2:07"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "   417792/102793104 [..............................] - ETA: 1:14"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "   770048/102793104 [..............................] - ETA: 48s "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "  1556480/102793104 [..............................] - ETA: 27s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "  2547712/102793104 [..............................] - ETA: 19s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "  4366336/102793104 [>.............................] - ETA: 12s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "  6627328/102793104 [>.............................] - ETA: 8s "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "  9691136/102793104 [=>............................] - ETA: 6s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 12804096/102793104 [==>...........................] - ETA: 5s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 15933440/102793104 [===>..........................] - ETA: 4s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 19062784/102793104 [====>.........................] - ETA: 3s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 22192128/102793104 [=====>........................] - ETA: 3s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 24969216/102793104 [======>.......................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 27238400/102793104 [======>.......................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 29573120/102793104 [=======>......................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 31989760/102793104 [========>.....................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 34643968/102793104 [=========>....................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 37109760/102793104 [=========>....................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 39641088/102793104 [==========>...................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 42475520/102793104 [===========>..................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 44851200/102793104 [============>.................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 47357952/102793104 [============>.................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 49659904/102793104 [=============>................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " 52256768/102793104 [==============>...............] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 55058432/102793104 [===============>..............] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 58089472/102793104 [===============>..............] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 60416000/102793104 [================>.............] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 62775296/102793104 [=================>............] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 64954368/102793104 [=================>............] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 67788800/102793104 [==================>...........] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 70639616/102793104 [===================>..........] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 73375744/102793104 [====================>.........] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 75579392/102793104 [=====================>........] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 77815808/102793104 [=====================>........] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 80379904/102793104 [======================>.......] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\r",
      " 83271680/102793104 [=======================>......] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 85909504/102793104 [========================>.....] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 88236032/102793104 [========================>.....] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 90529792/102793104 [=========================>....] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 92987392/102793104 [==========================>...] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 95903744/102793104 [==========================>...] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 98705408/102793104 [===========================>..] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "101203968/102793104 [============================>.] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "102793216/102793104 [==============================] - 3s 0us/step\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      " 83%|████████▎ | 5/6 [26:04:05<7:38:10, 27490.19s/it]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:From /root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:4074: The name tf.nn.avg_pool is deprecated. Please use tf.nn.avg_pool2d instead.\n",
      "\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "--- Logging error ---\n",
      "Traceback (most recent call last):\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/util/module_wrapper.py\", line 167, in __getattribute__\n",
      "    return attr_map[name]\n",
      "KeyError: 'avg_pool'\n",
      "\n",
      "During handling of the above exception, another exception occurred:\n",
      "\n",
      "Traceback (most recent call last):\n",
      "  File \"/usr/lib/python3.7/logging/__init__.py\", line 1028, in emit\n",
      "    stream.write(msg + self.terminator)\n",
      "ValueError: I/O operation on closed file.\n",
      "Call stack:\n",
      "  File \"/usr/lib/python3.7/runpy.py\", line 193, in _run_module_as_main\n",
      "    \"__main__\", mod_spec)\n",
      "  File \"/usr/lib/python3.7/runpy.py\", line 85, in _run_code\n",
      "    exec(code, run_globals)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel_launcher.py\", line 16, in <module>\n",
      "    app.launch_new_instance()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/traitlets/config/application.py\", line 664, in launch_instance\n",
      "    app.start()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelapp.py\", line 612, in start\n",
      "    self.io_loop.start()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/platform/asyncio.py\", line 149, in start\n",
      "    self.asyncio_loop.run_forever()\n",
      "  File \"/usr/lib/python3.7/asyncio/base_events.py\", line 534, in run_forever\n",
      "    self._run_once()\n",
      "  File \"/usr/lib/python3.7/asyncio/base_events.py\", line 1771, in _run_once\n",
      "    handle._run()\n",
      "  File \"/usr/lib/python3.7/asyncio/events.py\", line 88, in _run\n",
      "    self._context.run(self._callback, *self._args)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/ioloop.py\", line 690, in <lambda>\n",
      "    lambda f: self._run_callback(functools.partial(callback, future))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/ioloop.py\", line 743, in _run_callback\n",
      "    ret = callback()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 787, in inner\n",
      "    self.run()\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 748, in run\n",
      "    yielded = self.gen.send(value)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelbase.py\", line 365, in process_one\n",
      "    yield gen.maybe_future(dispatch(*args))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 209, in wrapper\n",
      "    yielded = next(result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelbase.py\", line 268, in dispatch_shell\n",
      "    yield gen.maybe_future(handler(stream, idents, msg))\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 209, in wrapper\n",
      "    yielded = next(result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/kernelbase.py\", line 545, in execute_request\n",
      "    user_expressions, allow_stdin,\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tornado/gen.py\", line 209, in wrapper\n",
      "    yielded = next(result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/ipkernel.py\", line 306, in do_execute\n",
      "    res = shell.run_cell(code, store_history=store_history, silent=silent)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/ipykernel/zmqshell.py\", line 536, in run_cell\n",
      "    return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 2877, in run_cell\n",
      "    raw_cell, store_history, silent, shell_futures)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 2922, in _run_cell\n",
      "    return runner(coro)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/async_helpers.py\", line 68, in _pseudo_sync_runner\n",
      "    coro.send(None)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 3146, in run_cell_async\n",
      "    interactivity=interactivity, compiler=compiler, result=result)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 3337, in run_ast_nodes\n",
      "    if (await self.run_code(code, result,  async_=asy)):\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/IPython/core/interactiveshell.py\", line 3417, in run_code\n",
      "    exec(code_obj, self.user_global_ns, self.user_ns)\n",
      "  File \"<ipython-input-6-5c733f8eae54>\", line 13, in <module>\n",
      "    num_workers=n_workers)\n",
      "  File \"../src/spectral_cluster_model.py\", line 1427, in run_clustering_imagenet\n",
      "    model = net((224, 224, 3), weights='imagenet')\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/classification_models/models_factory.py\", line 78, in wrapper\n",
      "    return func(*args, **new_kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras_applications/inception_v3.py\", line 190, in InceptionV3\n",
      "    padding='same')(x)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/engine/base_layer.py\", line 489, in __call__\n",
      "    output = self.call(inputs, **kwargs)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/layers/pooling.py\", line 205, in call\n",
      "    data_format=self.data_format)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/layers/pooling.py\", line 322, in _pooling_function\n",
      "    padding, data_format, pool_mode='avg')\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py\", line 4074, in pool2d\n",
      "    x = tf.nn.avg_pool(x, pool_size, strides,\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/util/module_wrapper.py\", line 187, in __getattribute__\n",
      "    self._tfmw_add_deprecation_warning(name, attr)):\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/util/module_wrapper.py\", line 139, in _tfmw_add_deprecation_warning\n",
      "    _call_location(), full_name, rename)\n",
      "  File \"/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/tensorflow_core/python/platform/tf_logging.py\", line 166, in warning\n",
      "    get_logger().warning(msg, *args, **kwargs)\n",
      "Message: 'From %s: The name %s is deprecated. Please use %s instead.\\n'\n",
      "Arguments: ('/root/.local/share/virtualenvs/nn_clustering-Lo7V74L4/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:4074', 'tf.nn.avg_pool', 'tf.nn.avg_pool2d')\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading data from https://github.com/fchollet/deep-learning-models/releases/download/v0.5/inception_v3_weights_tf_dim_ordering_tf_kernels.h5\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\r",
      "    8192/96112376 [..............................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "   24576/96112376 [..............................] - ETA: 4:03"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "   57344/96112376 [..............................] - ETA: 3:27"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "  106496/96112376 [..............................] - ETA: 2:47"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "  229376/96112376 [..............................] - ETA: 1:43"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "  475136/96112376 [..............................] - ETA: 1:02"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "  974848/96112376 [..............................] - ETA: 36s "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 1966080/96112376 [..............................] - ETA: 20s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 3981312/96112376 [>.............................] - ETA: 11s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      " 7110656/96112376 [=>............................] - ETA: 6s "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "10223616/96112376 [==>...........................] - ETA: 5s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "13352960/96112376 [===>..........................] - ETA: 4s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "16482304/96112376 [====>.........................] - ETA: 3s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "19611648/96112376 [=====>........................] - ETA: 3s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "22740992/96112376 [======>.......................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "25870336/96112376 [=======>......................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "29016064/96112376 [========>.....................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "32145408/96112376 [=========>....................] - ETA: 2s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "35274752/96112376 [==========>...................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "38404096/96112376 [==========>...................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "41533440/96112376 [===========>..................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "44662784/96112376 [============>.................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "47792128/96112376 [=============>................] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "50921472/96112376 [==============>...............] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "54050816/96112376 [===============>..............] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "57180160/96112376 [================>.............] - ETA: 1s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "60325888/96112376 [=================>............] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "63438848/96112376 [==================>...........] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "66568192/96112376 [===================>..........] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "69648384/96112376 [====================>.........] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "72777728/96112376 [=====================>........] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "75907072/96112376 [======================>.......] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "79036416/96112376 [=======================>......] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "82149376/96112376 [========================>.....] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "85278720/96112376 [=========================>....] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "88383488/96112376 [==========================>...] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "90980352/96112376 [===========================>..] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "93863936/96112376 [============================>.] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "95698944/96112376 [============================>.] - ETA: 0s"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
      "96116736/96112376 [==============================] - 2s 0us/step\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      "100%|██████████| 6/6 [35:17:00<00:00, 29195.66s/it]  "
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      "100%|██████████| 6/6 [35:17:00<00:00, 21170.09s/it]"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Network</th>\n",
       "      <th>network</th>\n",
       "      <th>ncut</th>\n",
       "      <th>ave_in_out</th>\n",
       "      <th>node_mask</th>\n",
       "      <th>labels</th>\n",
       "      <th>conv_connections</th>\n",
       "      <th>layer_names</th>\n",
       "      <th>n_samples</th>\n",
       "      <th>mean</th>\n",
       "      <th>stdev</th>\n",
       "      <th>z_score</th>\n",
       "      <th>percentile</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>VGG-16</td>\n",
       "      <td>vgg16</td>\n",
       "      <td>8.321250</td>\n",
       "      <td>0.221045</td>\n",
       "      <td>[True, True, True, True, True, True, True, Tru...</td>\n",
       "      <td>[3, 10, 3, 3, 3, 10, 3, 3, 2, 4, 3, 1, 6, 3, 3...</td>\n",
       "      <td>[[{'to_idx': 1, 'weights': [[1.1860629  0.8163...</td>\n",
       "      <td>[block1_conv1, block1_conv2, block2_conv1, blo...</td>\n",
       "      <td>50</td>\n",
       "      <td>8.884954</td>\n",
       "      <td>0.256355</td>\n",
       "      <td>-2.198919</td>\n",
       "      <td>0.019608</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>VGG-19</td>\n",
       "      <td>vgg19</td>\n",
       "      <td>7.585082</td>\n",
       "      <td>0.291026</td>\n",
       "      <td>[True, True, True, True, True, True, True, Tru...</td>\n",
       "      <td>[3, 8, 4, 3, 3, 2, 3, 3, 9, 3, 3, 3, 9, 3, 3, ...</td>\n",
       "      <td>[[{'to_idx': 1, 'weights': [[1.1221213  0.7537...</td>\n",
       "      <td>[block1_conv1, block1_conv2, block2_conv1, blo...</td>\n",
       "      <td>50</td>\n",
       "      <td>8.306801</td>\n",
       "      <td>0.302462</td>\n",
       "      <td>-2.386148</td>\n",
       "      <td>0.019608</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ResNet-18</td>\n",
       "      <td>resnet18</td>\n",
       "      <td>8.507007</td>\n",
       "      <td>0.205301</td>\n",
       "      <td>[True, True, True, True, True, True, True, Tru...</td>\n",
       "      <td>[1, 3, 4, 1, 3, 3, 1, 3, 1, 4, 1, 1, 4, 4, 1, ...</td>\n",
       "      <td>[[{'to_idx': 3, 'weights': [[ 1.0802758e+00  2...</td>\n",
       "      <td>[conv0, stage1_unit1_conv1, stage1_unit1_conv2...</td>\n",
       "      <td>50</td>\n",
       "      <td>8.833403</td>\n",
       "      <td>0.193189</td>\n",
       "      <td>-1.689513</td>\n",
       "      <td>0.078431</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ResNet-34</td>\n",
       "      <td>resnet34</td>\n",
       "      <td>7.909907</td>\n",
       "      <td>0.258542</td>\n",
       "      <td>[True, True, True, True, True, True, True, Tru...</td>\n",
       "      <td>[4, 6, 1, 1, 1, 1, 6, 6, 4, 6, 6, 1, 4, 1, 1, ...</td>\n",
       "      <td>[[{'to_idx': 3, 'weights': [[ 9.7058195e-01  3...</td>\n",
       "      <td>[conv0, stage1_unit1_conv1, stage1_unit1_conv2...</td>\n",
       "      <td>50</td>\n",
       "      <td>8.696794</td>\n",
       "      <td>0.240549</td>\n",
       "      <td>-3.271217</td>\n",
       "      <td>0.019608</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ResNet-50</td>\n",
       "      <td>resnet50</td>\n",
       "      <td>6.769019</td>\n",
       "      <td>0.386391</td>\n",
       "      <td>[True, True, True, True, True, True, True, Tru...</td>\n",
       "      <td>[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...</td>\n",
       "      <td>[[{'to_idx': 4, 'weights': [[ 2.66690516e+00  ...</td>\n",
       "      <td>[conv0, stage1_unit1_conv1, stage1_unit1_conv2...</td>\n",
       "      <td>50</td>\n",
       "      <td>6.768021</td>\n",
       "      <td>0.333764</td>\n",
       "      <td>0.002990</td>\n",
       "      <td>0.372549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>Inception-V3</td>\n",
       "      <td>inceptionv3</td>\n",
       "      <td>3.799556</td>\n",
       "      <td>1.079132</td>\n",
       "      <td>[True, True, True, True, True, True, True, Tru...</td>\n",
       "      <td>[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...</td>\n",
       "      <td>[[{'to_idx': 1, 'weights': [[1.3804991  0.3040...</td>\n",
       "      <td>[conv2d_1, conv2d_2, conv2d_3, conv2d_4, conv2...</td>\n",
       "      <td>50</td>\n",
       "      <td>3.646958</td>\n",
       "      <td>0.173863</td>\n",
       "      <td>0.877693</td>\n",
       "      <td>0.960784</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Network      network      ncut  ave_in_out  \\\n",
       "0        VGG-16        vgg16  8.321250    0.221045   \n",
       "1        VGG-19        vgg19  7.585082    0.291026   \n",
       "2     ResNet-18     resnet18  8.507007    0.205301   \n",
       "3     ResNet-34     resnet34  7.909907    0.258542   \n",
       "4     ResNet-50     resnet50  6.769019    0.386391   \n",
       "5  Inception-V3  inceptionv3  3.799556    1.079132   \n",
       "\n",
       "                                           node_mask  \\\n",
       "0  [True, True, True, True, True, True, True, Tru...   \n",
       "1  [True, True, True, True, True, True, True, Tru...   \n",
       "2  [True, True, True, True, True, True, True, Tru...   \n",
       "3  [True, True, True, True, True, True, True, Tru...   \n",
       "4  [True, True, True, True, True, True, True, Tru...   \n",
       "5  [True, True, True, True, True, True, True, Tru...   \n",
       "\n",
       "                                              labels  \\\n",
       "0  [3, 10, 3, 3, 3, 10, 3, 3, 2, 4, 3, 1, 6, 3, 3...   \n",
       "1  [3, 8, 4, 3, 3, 2, 3, 3, 9, 3, 3, 3, 9, 3, 3, ...   \n",
       "2  [1, 3, 4, 1, 3, 3, 1, 3, 1, 4, 1, 1, 4, 4, 1, ...   \n",
       "3  [4, 6, 1, 1, 1, 1, 6, 6, 4, 6, 6, 1, 4, 1, 1, ...   \n",
       "4  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...   \n",
       "5  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...   \n",
       "\n",
       "                                    conv_connections  \\\n",
       "0  [[{'to_idx': 1, 'weights': [[1.1860629  0.8163...   \n",
       "1  [[{'to_idx': 1, 'weights': [[1.1221213  0.7537...   \n",
       "2  [[{'to_idx': 3, 'weights': [[ 1.0802758e+00  2...   \n",
       "3  [[{'to_idx': 3, 'weights': [[ 9.7058195e-01  3...   \n",
       "4  [[{'to_idx': 4, 'weights': [[ 2.66690516e+00  ...   \n",
       "5  [[{'to_idx': 1, 'weights': [[1.3804991  0.3040...   \n",
       "\n",
       "                                         layer_names  n_samples      mean  \\\n",
       "0  [block1_conv1, block1_conv2, block2_conv1, blo...         50  8.884954   \n",
       "1  [block1_conv1, block1_conv2, block2_conv1, blo...         50  8.306801   \n",
       "2  [conv0, stage1_unit1_conv1, stage1_unit1_conv2...         50  8.833403   \n",
       "3  [conv0, stage1_unit1_conv1, stage1_unit1_conv2...         50  8.696794   \n",
       "4  [conv0, stage1_unit1_conv1, stage1_unit1_conv2...         50  6.768021   \n",
       "5  [conv2d_1, conv2d_2, conv2d_3, conv2d_4, conv2...         50  3.646958   \n",
       "\n",
       "      stdev   z_score  percentile  \n",
       "0  0.256355 -2.198919    0.019608  \n",
       "1  0.302462 -2.386148    0.019608  \n",
       "2  0.193189 -1.689513    0.078431  \n",
       "3  0.240549 -3.271217    0.019608  \n",
       "4  0.333764  0.002990    0.372549  \n",
       "5  0.173863  0.877693    0.960784  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nets = ['vgg16', 'vgg19', 'resnet18', 'resnet34', 'resnet50', 'inceptionv3'] \n",
    "net_name_map = {'vgg16': 'VGG-16', 'vgg19': 'VGG-19', 'resnet18': 'ResNet-18',\n",
    "                'resnet34': 'ResNet-34', 'resnet50': 'ResNet-50', 'inceptionv3': 'Inception-V3'}\n",
    "n_clust = 12\n",
    "n_samples = 100\n",
    "n_workers = 2\n",
    "n_reps = 5\n",
    "\n",
    "imagenet_clustering_results = {}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "for net in tqdm(nets):\n",
    "\n",
    "    imagenet_clustering_results[net] = run_clustering_imagenet(net, num_clusters=n_clust,\n",
    "                                                               num_samples=n_samples,\n",
    "                                                               eigen_solver='arpack',\n",
    "                                                               num_workers=n_workers)\n",
    "imagenet_all_results = []\n",
    "for net in imagenet_clustering_results:\n",
    "\n",
    "    network = net_name_map[net]\n",
    "\n",
    "    imagenet_result = {'Network': network}\n",
    "    imagenet_result.update(imagenet_clustering_results[net])\n",
    "    imagenet_all_results.append(pd.Series(imagenet_result))\n",
    "\n",
    "imagenet_result_df = pd.DataFrame(imagenet_all_results)\n",
    "imagenet_savepath = '../results/clustering_factors_imagenet.csv'\n",
    "imagenet_result_df.to_csv(imagenet_savepath)\n",
    "imagenet_result_df\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "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.7.5"
  },
  "papermill": {
   "duration": 154094.44518,
   "end_time": "2020-09-04T17:42:17.045092",
   "environment_variables": {},
   "exception": null,
   "input_path": "./notebooks/clustering_factors.ipynb",
   "output_path": "./notebooks/clustering_factors.ipynb",
   "parameters": {},
   "start_time": "2020-09-02T22:54:02.599912",
   "version": "1.2.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}