浏览代码

Added convGAN Example.

Kristian Schultz 3 年之前
父节点
当前提交
67d302f38c
共有 1 个文件被更改,包括 186 次插入0 次删除
  1. 186 0
      convGeN-Example.ipynb

+ 186 - 0
convGeN-Example.ipynb

@@ -0,0 +1,186 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "id": "c993b281",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "2022-06-13 12:00:08.186819: 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-06-13 12:00:08.186840: 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.convGAN import ConvGAN"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "id": "5c3b99d1",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Load 'data_input/folding_flare-F'\n",
+      "from pickle file\n",
+      "non empty cut in data_input/folding_flare-F! (23 points)\n",
+      "Data loaded.\n"
+     ]
+    }
+   ],
+   "source": [
+    "data = loadDataset(\"data_input/\" + testSets[4])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "id": "3b4a0637",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "(1066, 1023, 43)\n"
+     ]
+    }
+   ],
+   "source": [
+    "print((len(data.data), len(data.data0), len(data.data1)))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "id": "97dfa225",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "gen = ConvGAN(data.data0.shape[1], neb=5)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "id": "c681bcee",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "2022-06-13 12:00:09.935294: 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-06-13 12:00:09.935314: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)\n",
+      "2022-06-13 12:00:09.935330: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (sbi-klabautermann): /proc/driver/nvidia/version does not exist\n",
+      "2022-06-13 12:00:09.935515: 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"
+     ]
+    }
+   ],
+   "source": [
+    "gen.reset(data)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "id": "6ac6fc34",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "gen.train(data)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "id": "523e4106",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "syntheticPoints = gen.generateData(10)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "id": "13ee7dd4",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "array([[1.9999993 , 0.6453496 , 0.2968364 , 1.3546498 , 0.        ,\n",
+       "        0.99999964, 0.99999964, 0.99999964, 0.2968364 , 0.        ,\n",
+       "        0.        ],\n",
+       "       [0.7537636 , 0.9999999 , 0.7530866 , 1.3768817 , 0.        ,\n",
+       "        0.9999999 , 0.9999999 , 0.3768818 , 3.2469125 , 0.        ,\n",
+       "        0.        ],\n",
+       "       [0.        , 0.9999995 , 0.5992881 , 0.9999995 , 0.        ,\n",
+       "        0.9999995 , 0.9999995 , 0.        , 0.40071142, 0.        ,\n",
+       "        0.        ],\n",
+       "       [0.        , 0.9999996 , 0.64247733, 1.3485842 , 0.        ,\n",
+       "        0.9999996 , 0.9999996 , 0.        , 0.        , 0.        ,\n",
+       "        0.        ],\n",
+       "       [1.9999995 , 0.3972343 , 0.99999976, 1.6027652 , 0.        ,\n",
+       "        0.99999976, 0.99999976, 0.99999976, 0.3972343 , 0.        ,\n",
+       "        0.        ],\n",
+       "       [2.304937  , 0.7317089 , 0.2787703 , 1.2682906 , 0.        ,\n",
+       "        0.99999976, 0.99999976, 0.6950623 , 0.3154169 , 0.        ,\n",
+       "        0.        ],\n",
+       "       [0.        , 0.99999964, 0.33072543, 0.99999964, 0.        ,\n",
+       "        0.99999964, 0.99999964, 0.2920961 , 1.1246573 , 0.        ,\n",
+       "        0.        ],\n",
+       "       [1.2489054 , 0.9999997 , 0.7045903 , 1.0157089 , 0.        ,\n",
+       "        0.9999997 , 0.9999997 , 0.32904333, 2.6687403 , 0.        ,\n",
+       "        0.        ],\n",
+       "       [3.6535707 , 0.9999997 , 0.29958388, 1.3539872 , 0.        ,\n",
+       "        0.9999997 , 0.9999997 , 0.        , 0.34642833, 0.        ,\n",
+       "        0.        ],\n",
+       "       [0.        , 0.9999995 , 0.24637261, 0.97887444, 0.        ,\n",
+       "        0.9999995 , 0.9999995 , 0.        , 0.35920745, 0.        ,\n",
+       "        0.        ]], dtype=float32)"
+      ]
+     },
+     "execution_count": 8,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "syntheticPoints"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3 (ipykernel)",
+   "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.7"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}