{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "b9b5254c", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "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 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" ] }, { "cell_type": "code", "execution_count": 2, "id": "6bfec0a2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Load 'folding_abalone_17_vs_7_8_9_10'\n", "from pickle file\n", "Data loaded.\n" ] } ], "source": [ "data = loadDataset(testSets[0])" ] }, { "cell_type": "code", "execution_count": 3, "id": "6d686da5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(2338, 2280, 58)\n" ] } ], "source": [ "print((len(data.data), len(data.data0), len(data.data1)))" ] }, { "cell_type": "code", "execution_count": 4, "id": "9e3e3806", "metadata": {}, "outputs": [], "source": [ "fdc = FDC()\n", "fdc.nom_list = [0]\n", "fdc.cont_list = list(range(data.data0.shape[1]))[1:]" ] }, { "cell_type": "code", "execution_count": 5, "id": "01d71d6a", "metadata": {}, "outputs": [], "source": [ "gen = NextConvGeN(data.data0.shape[1], neb=5, fdc=fdc)" ] }, { "cell_type": "code", "execution_count": 6, "id": "ad01be2b", "metadata": { "scrolled": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "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" ] } ], "source": [ "gen.reset(data.data1)" ] }, { "cell_type": "code", "execution_count": 7, "id": "4698522c", "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "FDC.normalize (init): 0.00003 / 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| = (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" ] } ], "source": [ "gen.train(data.data1)" ] }, { "cell_type": "code", "execution_count": 8, "id": "cda17654", "metadata": { "scrolled": false }, "outputs": [], "source": [ "syntheticPoints = gen.generateData(10)" ] }, { "cell_type": "code", "execution_count": 9, "id": "41853bd3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "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": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "syntheticPoints" ] }, { "cell_type": "code", "execution_count": 10, "id": "da5ebdb9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "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": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.data1[:5]" ] }, { "cell_type": "code", "execution_count": 11, "id": "4043256c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "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" ] } ], "source": [ "import math\n", "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": { "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.8.15" } }, "nbformat": 4, "nbformat_minor": 5 }