Ver Fonte

Updated NextConvGen example.

Kristian Schultz há 3 anos atrás
pai
commit
5abb1d1438
1 ficheiros alterados com 102 adições e 141 exclusões
  1. 102 141
      NextConvGeN-Example.ipynb

+ 102 - 141
NextConvGeN-Example.ipynb

@@ -10,15 +10,19 @@
      "name": "stderr",
      "output_type": "stream",
      "text": [
-      "2022-10-24 13:21:55.361983: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory\n",
-      "2022-10-24 13:21:55.362017: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.\n"
+      "2022-11-10 15:52:36.048983: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory\n",
+      "2022-11-10 15:52:36.049008: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.\n"
      ]
     }
    ],
    "source": [
     "from library.analysis import loadDataset, testSets\n",
     "from library.generators.NextConvGeN import NextConvGeN\n",
-    "from fdc.fdc import FDC"
+    "#from library.timing import timing\n",
+    "from fdc.fdc import FDC\n",
+    "#from matplotlib import pyplot as plt\n",
+    "#import numpy as np\n",
+    "#import tensorflow as tf"
    ]
   },
   {
@@ -31,15 +35,14 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Load 'folding_flare-F'\n",
+      "Load 'folding_abalone_17_vs_7_8_9_10'\n",
       "from pickle file\n",
-      "non empty cut in folding_flare-F! (70 points)\n",
       "Data loaded.\n"
      ]
     }
    ],
    "source": [
-    "data = loadDataset(testSets[4])"
+    "data = loadDataset(testSets[0])"
    ]
   },
   {
@@ -52,7 +55,7 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "(1066, 1023, 43)\n"
+      "(2338, 2280, 58)\n"
      ]
     }
    ],
@@ -68,7 +71,8 @@
    "outputs": [],
    "source": [
     "fdc = FDC()\n",
-    "fdc.nom_list = list(range(data.data0.shape[1]))"
+    "fdc.nom_list = [0]\n",
+    "fdc.cont_list = list(range(data.data0.shape[1]))[1:]"
    ]
   },
   {
@@ -85,16 +89,18 @@
    "cell_type": "code",
    "execution_count": 6,
    "id": "ad01be2b",
-   "metadata": {},
+   "metadata": {
+    "scrolled": false
+   },
    "outputs": [
     {
      "name": "stderr",
      "output_type": "stream",
      "text": [
-      "2022-10-24 13:22:01.772778: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory\n",
-      "2022-10-24 13:22:01.772808: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)\n",
-      "2022-10-24 13:22:01.772828: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (efdcb09fb24e): /proc/driver/nvidia/version does not exist\n",
-      "2022-10-24 13:22:01.773733: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA\n",
+      "2022-11-10 15:52:43.112497: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory\n",
+      "2022-11-10 15:52:43.112538: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)\n",
+      "2022-11-10 15:52:43.112565: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (efdcb09fb24e): /proc/driver/nvidia/version does not exist\n",
+      "2022-11-10 15:52:43.112811: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA\n",
       "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n"
      ]
     }
@@ -116,20 +122,24 @@
      "output_type": "stream",
      "text": [
       "FDC.normalize (init): 0.00003 / 0.000s\n",
-      "|data| = (43, 11)\n",
-      "FDC.normalize (clustering CONT): 0.00005 / 0.000s\n",
-      "FDC.normalize (clustering ORD): 0.00001 / 0.000s\n",
+      "|data| = (58, 8)\n",
+      "umap with metric 'euclidean'\n",
+      "|part| = (58, 7)\n",
+      "|emb_A| = (58, 2)\n",
+      "|emb_A| = (58, 2)\n",
+      "FDC.normalize (clustering CONT): 5.65696 / 5.657s\n",
+      "FDC.normalize (clustering ORD): 0.00002 / 5.657s\n",
       "umap with metric 'hamming'\n",
-      "|part| = (43, 11)\n",
-      "|emb_A| = (43, 1)\n",
-      "|emb_A| = (43, 1)\n",
-      "FDC.normalize (clustering NOM): 5.66512 / 5.665s\n",
-      "FDC.normalize (concat): 0.00007 / 5.665s\n",
-      "|fdc| = (43, 1)\n",
-      "FDC.normalize (total): 0.00002 / 5.665s\n",
-      "|N| = (43, 1)\n",
-      "|D| = (43, 11)\n",
-      "[==========] [==========] [==========]\r"
+      "|part| = (58, 1)\n",
+      "|emb_A| = (58, 1)\n",
+      "|emb_A| = (58, 1)\n",
+      "FDC.normalize (clustering NOM): 1.14268 / 6.800s\n",
+      "FDC.normalize (concat): 0.00005 / 6.800s\n",
+      "|fdc| = (58, 3)\n",
+      "FDC.normalize (total): 0.00004 / 6.800s\n",
+      "|N| = (58, 3)\n",
+      "|D| = (58, 8)\n",
+      "[==========] [======    ] [======    ]\r"
      ]
     }
    ],
@@ -140,53 +150,10 @@
   {
    "cell_type": "code",
    "execution_count": 8,
-   "id": "fe3027a2",
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Train: #1 213.6447s\n",
-      "BMB: #2580 0.8377s\n",
-      "NbhSearch: #1 0.0139s\n",
-      "NBH: #2150 1.4677s\n",
-      "GenSamples: #2150 68.9012s\n",
-      "Fit: #2150 89.1429s\n"
-     ]
-    }
-   ],
-   "source": [
-    "for x in gen.timing:\n",
-    "    print(gen.timing[x])"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 9,
-   "id": "919390c3",
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "<fdc.fdc.FDC at 0x7ff70b133910>"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "gen.fdc"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 10,
    "id": "cda17654",
-   "metadata": {},
+   "metadata": {
+    "scrolled": false
+   },
    "outputs": [],
    "source": [
     "syntheticPoints = gen.generateData(10)"
@@ -194,26 +161,36 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 9,
    "id": "41853bd3",
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "array([[2., 0., 0., 1., 0., 1., 1., 1., 0., 1., 1.],\n",
-       "       [0., 1., 0., 1., 0., 1., 1., 1., 2., 0., 0.],\n",
-       "       [4., 1., 1., 1., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [0., 1., 1., 1., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [2., 1., 1., 2., 0., 1., 1., 1., 3., 0., 0.],\n",
-       "       [0., 1., 0., 1., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [0., 1., 0., 2., 0., 0., 1., 0., 1., 0., 0.],\n",
-       "       [2., 1., 1., 2., 0., 1., 1., 1., 3., 0., 0.],\n",
-       "       [4., 2., 0., 0., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [0., 1., 0., 0., 0., 0., 1., 0., 0., 0., 0.]], dtype=float32)"
+       "array([[1.        , 0.53445315, 0.42945328, 0.1744535 , 0.96993124,\n",
+       "        0.3640874 , 0.23348743, 0.29893178],\n",
+       "       [2.        , 0.56035066, 0.41464847, 0.1654633 , 0.9590763 ,\n",
+       "        0.37012604, 0.23675683, 0.3104632 ],\n",
+       "       [1.        , 0.548009  , 0.43936524, 0.1713553 , 0.9616028 ,\n",
+       "        0.3593513 , 0.21599998, 0.30743402],\n",
+       "       [1.        , 0.54999954, 0.43999964, 0.16499987, 0.86049926,\n",
+       "        0.31199974, 0.16899987, 0.29999977],\n",
+       "       [1.        , 0.5539543 , 0.4433802 , 0.16721351, 0.90213394,\n",
+       "        0.33197013, 0.18213706, 0.30834144],\n",
+       "       [2.        , 0.5534017 , 0.44726777, 0.16168031, 0.9173514 ,\n",
+       "        0.35133395, 0.1702083 , 0.29730922],\n",
+       "       [2.        , 0.58627754, 0.469185  , 0.17290716, 1.060739  ,\n",
+       "        0.40853333, 0.20428768, 0.37035084],\n",
+       "       [2.        , 0.5510869 , 0.4343453 , 0.16286607, 0.9295284 ,\n",
+       "        0.35263863, 0.20032436, 0.29319543],\n",
+       "       [0.        , 0.52999955, 0.42499965, 0.16999985, 0.9489992 ,\n",
+       "        0.34849972, 0.2394998 , 0.27799976],\n",
+       "       [0.        , 0.5421706 , 0.42764086, 0.16827805, 0.9629398 ,\n",
+       "        0.35746834, 0.23870556, 0.28831378]], dtype=float32)"
       ]
      },
-     "execution_count": 11,
+     "execution_count": 9,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -224,70 +201,32 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 10,
    "id": "da5ebdb9",
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "array([[2., 0., 1., 2., 0., 1., 1., 1., 0., 0., 0.],\n",
-       "       [2., 0., 1., 1., 0., 1., 1., 0., 4., 0., 0.],\n",
-       "       [0., 0., 1., 1., 0., 1., 1., 0., 1., 0., 0.],\n",
-       "       [0., 1., 1., 1., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [2., 0., 1., 2., 2., 1., 1., 1., 1., 0., 0.],\n",
-       "       [2., 1., 1., 1., 0., 1., 1., 1., 1., 0., 0.],\n",
-       "       [0., 1., 0., 1., 0., 1., 1., 0., 2., 0., 0.],\n",
-       "       [2., 1., 1., 2., 0., 1., 1., 1., 3., 0., 0.],\n",
-       "       [4., 2., 0., 0., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [0., 1., 0., 0., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [4., 1., 0., 2., 0., 1., 1., 0., 2., 0., 0.],\n",
-       "       [4., 1., 1., 1., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [3., 1., 0., 1., 0., 1., 1., 0., 1., 0., 0.],\n",
-       "       [1., 2., 0., 2., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [2., 1., 0., 1., 0., 1., 1., 0., 4., 0., 0.],\n",
-       "       [0., 1., 1., 2., 0., 1., 1., 1., 1., 1., 0.],\n",
-       "       [0., 1., 1., 2., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [0., 1., 0., 1., 0., 1., 1., 0., 1., 0., 0.],\n",
-       "       [0., 1., 0., 1., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [0., 1., 1., 1., 0., 1., 1., 0., 1., 0., 0.],\n",
-       "       [0., 1., 0., 2., 0., 0., 1., 0., 0., 0., 0.],\n",
-       "       [2., 0., 0., 1., 0., 1., 1., 1., 0., 1., 1.],\n",
-       "       [2., 0., 0., 2., 0., 1., 1., 1., 0., 0., 0.],\n",
-       "       [2., 1., 0., 1., 0., 1., 1., 1., 0., 0., 0.],\n",
-       "       [4., 1., 1., 1., 0., 1., 1., 0., 2., 0., 0.],\n",
-       "       [0., 1., 1., 1., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [0., 1., 0., 1., 0., 1., 1., 1., 1., 0., 0.],\n",
-       "       [2., 0., 1., 2., 0., 1., 1., 1., 0., 0., 0.],\n",
-       "       [0., 1., 1., 1., 0., 1., 1., 0., 1., 0., 1.],\n",
-       "       [0., 1., 1., 1., 0., 1., 1., 0., 3., 0., 0.],\n",
-       "       [4., 2., 1., 1., 0., 0., 1., 0., 0., 0., 0.],\n",
-       "       [2., 1., 0., 1., 0., 1., 1., 0., 1., 0., 0.],\n",
-       "       [0., 1., 1., 1., 2., 1., 1., 0., 0., 0., 0.],\n",
-       "       [4., 1., 0., 2., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [0., 0., 1., 2., 0., 1., 1., 1., 2., 0., 0.],\n",
-       "       [0., 1., 1., 1., 0., 1., 1., 0., 2., 0., 0.],\n",
-       "       [2., 1., 1., 1., 2., 1., 1., 0., 0., 0., 0.],\n",
-       "       [0., 1., 0., 1., 0., 1., 1., 0., 4., 0., 0.],\n",
-       "       [0., 1., 1., 1., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [1., 2., 0., 1., 0., 0., 1., 0., 0., 0., 0.],\n",
-       "       [4., 1., 0., 2., 0., 1., 1., 0., 1., 0., 0.],\n",
-       "       [0., 1., 0., 1., 0., 1., 1., 0., 0., 0., 0.],\n",
-       "       [1., 2., 0., 1., 0., 1., 1., 0., 1., 0., 0.]])"
+       "array([[2.    , 0.565 , 0.425 , 0.16  , 0.9425, 0.3495, 0.2185, 0.275 ],\n",
+       "       [0.    , 0.495 , 0.4   , 0.155 , 0.6445, 0.242 , 0.1325, 0.205 ],\n",
+       "       [2.    , 0.54  , 0.435 , 0.18  , 0.996 , 0.3835, 0.226 , 0.325 ],\n",
+       "       [0.    , 0.69  , 0.56  , 0.215 , 1.719 , 0.68  , 0.299 , 0.47  ],\n",
+       "       [0.    , 0.68  , 0.55  , 0.21  , 1.7445, 0.5975, 0.305 , 0.625 ]])"
       ]
      },
-     "execution_count": 12,
+     "execution_count": 10,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "data.data1"
+    "data.data1[:5]"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": 11,
    "id": "4043256c",
    "metadata": {},
    "outputs": [
@@ -295,16 +234,16 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "0.0\n",
-      "1.0\n",
-      "0.0\n",
-      "0.0\n",
-      "0.0\n",
-      "0.0\n",
-      "1.0\n",
-      "0.0\n",
-      "0.0\n",
-      "1.0\n"
+      "0.08049949828195788\n",
+      "0.038820822032602086\n",
+      "0.08678922927950353\n",
+      "1.0214483365545625e-06\n",
+      "0.049054203874789606\n",
+      "0.06402187676961534\n",
+      "0.03621533523715291\n",
+      "0.03359559417587524\n",
+      "1.056058840778465e-06\n",
+      "0.023233951625306986\n"
      ]
     }
    ],
@@ -313,6 +252,28 @@
     "for p in syntheticPoints:\n",
     "    print(min([math.sqrt(sum(y*y)) for y in (data.data1 - p) ]))"
    ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 12,
+   "id": "3bcc8cb7",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "(0.4632151, 0.5130856, 0.49341423603995094)"
+      ]
+     },
+     "execution_count": 12,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "v = gen.predictReal(data.data1)\n",
+    "(min(v), max(v), sum(v) / len(v))"
+   ]
   }
  ],
  "metadata": {