diff --git a/examples/0_quick_start_guide.ipynb b/examples/0_quick_start_guide.ipynb index 0f8daa0..2545d6b 100644 --- a/examples/0_quick_start_guide.ipynb +++ b/examples/0_quick_start_guide.ipynb @@ -34,32 +34,9 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Processing frames: 100%|██████████| 500/500 [00:00<00:00, 561.72it/s]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Loading 477 graphs into CustomSpektralDataset...\n", - "Loading 477 graphs into CustomSpektralDataset...\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\n" - ] - } - ], + "outputs": [], "source": [ "from unravel.soccer import GraphConverter\n", "from unravel.utils import CustomSpektralDataset\n", @@ -93,7 +70,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -116,17 +93,9 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING:absl:At this time, the v2.11+ optimizer `tf.keras.optimizers.Adam` runs slowly on M1/M2 Macs, please use the legacy Keras optimizer instead, located at `tf.keras.optimizers.legacy.Adam`.\n" - ] - } - ], + "outputs": [], "source": [ "from unravel.classifiers import CrystalGraphClassifier\n", "\n", @@ -153,74 +122,9 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Epoch 1/10\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/jbekkers/PycharmProjects/unravelsports/.venv311/lib/python3.11/site-packages/keras/src/initializers/initializers.py:120: UserWarning: The initializer GlorotUniform is unseeded and being called multiple times, which will return identical values each time (even if the initializer is unseeded). Please update your code to provide a seed to the initializer, or avoid using the same initializer instance more than once.\n", - " warnings.warn(\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10/10 [==============================] - 2s 26ms/step - loss: 16.1988 - auc: 0.4597 - binary_accuracy: 0.4560 - val_loss: 7.9675 - val_auc: 0.5101 - val_binary_accuracy: 0.4625\n", - "Epoch 2/10\n", - "10/10 [==============================] - ETA: 0s - loss: 8.1257 - auc: 0.5055 - binary_accuracy: 0.5283 WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 3 batches). You may need to use the repeat() function when building your dataset.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 3 batches). You may need to use the repeat() function when building your dataset.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10/10 [==============================] - 0s 9ms/step - loss: 8.1257 - auc: 0.5055 - binary_accuracy: 0.5283\n", - "Epoch 3/10\n", - "10/10 [==============================] - 0s 8ms/step - loss: 3.8924 - auc: 0.5408 - binary_accuracy: 0.5535\n", - "Epoch 4/10\n", - "10/10 [==============================] - 0s 10ms/step - loss: 3.6436 - auc: 0.4814 - binary_accuracy: 0.5000\n", - "Epoch 5/10\n", - "10/10 [==============================] - 0s 11ms/step - loss: 2.2543 - auc: 0.4966 - binary_accuracy: 0.4969\n", - "Epoch 6/10\n", - "10/10 [==============================] - 0s 6ms/step - loss: 1.7266 - auc: 0.4905 - binary_accuracy: 0.4780\n", - "Epoch 7/10\n", - "10/10 [==============================] - 0s 6ms/step - loss: 1.4315 - auc: 0.5282 - binary_accuracy: 0.5126\n", - "Epoch 8/10\n", - "10/10 [==============================] - 0s 9ms/step - loss: 1.1989 - auc: 0.5094 - binary_accuracy: 0.4748\n", - "Epoch 9/10\n", - "10/10 [==============================] - 0s 8ms/step - loss: 0.9823 - auc: 0.5714 - binary_accuracy: 0.5440\n", - "Epoch 10/10\n", - "10/10 [==============================] - 0s 6ms/step - loss: 1.0795 - auc: 0.5228 - binary_accuracy: 0.5031\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from tensorflow.keras.callbacks import EarlyStopping\n", "\n", @@ -254,17 +158,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3/3 [==============================] - 0s 22ms/step - loss: 0.7569 - auc: 0.4881 - binary_accuracy: 0.4684\n" - ] - } - ], + "outputs": [], "source": [ "loader_te = DisjointLoader(test, epochs=1, shuffle=False, batch_size=batch_size)\n", "results = model.evaluate(loader_te.load())" @@ -283,110 +179,12 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4/4 [==============================] - 0s 11ms/step\n" - ] - }, - { - "data": { - "text/plain": [ - "array([[0.32064953],\n", - " [0.5187207 ],\n", - " [0.36767447],\n", - " [0.58158153],\n", - " [0.648303 ],\n", - " [0.7250808 ],\n", - " [0.45932224],\n", - " [0.17837673],\n", - " [0.40539873],\n", - " [0.4424542 ],\n", - " [0.30549103],\n", - " [0.4686426 ],\n", - " [0.45274827],\n", - " [0.48409605],\n", - " [0.52468264],\n", - " [0.48941866],\n", - " [0.45071444],\n", - " [0.40024903],\n", - " [0.43896046],\n", - " [0.4752483 ],\n", - " [0.6113058 ],\n", - " [0.51407444],\n", - " [0.63001126],\n", - " [0.4740725 ],\n", - " [0.6078143 ],\n", - " [0.42406863],\n", - " [0.42664722],\n", - " [0.5456678 ],\n", - " [0.6497228 ],\n", - " [0.10468224],\n", - " [0.28870958],\n", - " [0.35573283],\n", - " [0.50675493],\n", - " [0.26084217],\n", - " [0.5045665 ],\n", - " [0.4551955 ],\n", - " [0.2941906 ],\n", - " [0.17870983],\n", - " [0.645881 ],\n", - " [0.44119328],\n", - " [0.5141012 ],\n", - " [0.4944313 ],\n", - " [0.5526908 ],\n", - " [0.3726117 ],\n", - " [0.01953349],\n", - " [0.43424365],\n", - " [0.6119593 ],\n", - " [0.17366503],\n", - " [0.32349864],\n", - " [0.23837146],\n", - " [0.36960262],\n", - " [0.40078542],\n", - " [0.60070145],\n", - " [0.38831863],\n", - " [0.4297107 ],\n", - " [0.30132666],\n", - " [0.19354764],\n", - " [0.33943865],\n", - " [0.6698272 ],\n", - " [0.493429 ],\n", - " [0.71516454],\n", - " [0.47075588],\n", - " [0.9052064 ],\n", - " [0.48426422],\n", - " [0.51765573],\n", - " [0.621886 ],\n", - " [0.56246924],\n", - " [0.5652972 ],\n", - " [0.46242762],\n", - " [0.57170457],\n", - " [0.18469568],\n", - " [0.42506087],\n", - " [0.69418275],\n", - " [0.37345868],\n", - " [0.50700355],\n", - " [0.4964876 ],\n", - " [0.32357928],\n", - " [0.692147 ],\n", - " [0.5441656 ]], dtype=float32)" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "loader_te = DisjointLoader(test, batch_size=batch_size, epochs=1, shuffle=False)\n", - "loaded_pred = model.predict(loader_te.load(), use_multiprocessing=True)\n", - "\n", - "loaded_pred" + "loaded_pred = model.predict(loader_te.load(), use_multiprocessing=True)" ] } ], diff --git a/examples/1_kloppy_gnn_train.ipynb b/examples/1_kloppy_gnn_train.ipynb index 9576db0..c1bbc5e 100644 --- a/examples/1_kloppy_gnn_train.ipynb +++ b/examples/1_kloppy_gnn_train.ipynb @@ -14,7 +14,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -52,7 +52,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -237,7 +237,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -306,7 +306,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -479,19 +479,9 @@ }, { "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Train: CustomSpektralDataset(n_graphs=791)\n", - "Test: CustomSpektralDataset(n_graphs=477)\n", - "Validation: CustomSpektralDataset(n_graphs=336)\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "train, test, val = dataset.split_test_train_validation(\n", " split_train=4, split_test=1, split_validation=1, by_graph_id=True, random_seed=42\n", @@ -510,7 +500,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -538,7 +528,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -597,7 +587,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -629,17 +619,9 @@ }, { "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING:absl:At this time, the v2.11+ optimizer `tf.keras.optimizers.Adam` runs slowly on M1/M2 Macs, please use the legacy Keras optimizer instead, located at `tf.keras.optimizers.legacy.Adam`.\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "from tensorflow.keras.metrics import AUC, BinaryAccuracy\n", "from tensorflow.keras.losses import BinaryCrossentropy\n", @@ -666,80 +648,9 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Epoch 1/10\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/jbekkers/PycharmProjects/unravelsports/.venv311/lib/python3.11/site-packages/keras/src/initializers/initializers.py:120: UserWarning: The initializer GlorotUniform is unseeded and being called multiple times, which will return identical values each time (even if the initializer is unseeded). Please update your code to provide a seed to the initializer, or avoid using the same initializer instance more than once.\n", - " warnings.warn(\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "25/25 [==============================] - 2s 17ms/step - loss: 25.1293 - auc: 0.4867 - binary_accuracy: 0.4930 - val_loss: 2.6669 - val_auc: 0.5928 - val_binary_accuracy: 0.5357\n", - "Epoch 2/10\n", - "21/25 [========================>.....] - ETA: 0s - loss: 6.8008 - auc: 0.4994 - binary_accuracy: 0.5074WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 11 batches). You may need to use the repeat() function when building your dataset.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 11 batches). You may need to use the repeat() function when building your dataset.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "25/25 [==============================] - 0s 10ms/step - loss: 6.5554 - auc: 0.5018 - binary_accuracy: 0.5133\n", - "Epoch 3/10\n", - "25/25 [==============================] - 0s 7ms/step - loss: 3.0297 - auc: 0.5144 - binary_accuracy: 0.5057\n", - "Epoch 4/10\n", - "25/25 [==============================] - 0s 7ms/step - loss: 1.8015 - auc: 0.4956 - binary_accuracy: 0.5019\n", - "Epoch 5/10\n", - "25/25 [==============================] - 0s 12ms/step - loss: 1.4551 - auc: 0.4506 - binary_accuracy: 0.4678\n", - "Epoch 6/10\n", - "WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 250 batches). You may need to use the repeat() function when building your dataset.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "WARNING:tensorflow:Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches (in this case, 250 batches). You may need to use the repeat() function when building your dataset.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "25/25 [==============================] - 0s 3ms/step - loss: 0.0000e+00 - auc: 0.0000e+00 - binary_accuracy: 0.0000e+00\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "model.fit(\n", " loader_tr.load(),\n", @@ -762,28 +673,9 @@ }, { "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "INFO:tensorflow:Assets written to: models/my-first-graph-classifier/assets\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:tensorflow:Assets written to: models/my-first-graph-classifier/assets\n", - "/Users/jbekkers/PycharmProjects/unravelsports/.venv311/lib/python3.11/site-packages/keras/src/initializers/initializers.py:120: UserWarning: The initializer GlorotUniform is unseeded and being called multiple times, which will return identical values each time (even if the initializer is unseeded). Please update your code to provide a seed to the initializer, or avoid using the same initializer instance more than once.\n", - " warnings.warn(\n", - "WARNING:absl:At this time, the v2.11+ optimizer `tf.keras.optimizers.RestoredOptimizer` runs slowly on M1/M2 Macs, please use the legacy Keras optimizer instead, located at `tf.keras.optimizers.legacy.RestoredOptimizer`.\n", - "WARNING:absl:At this time, the v2.11+ optimizer `tf.keras.optimizers.Adam` runs slowly on M1/M2 Macs, please use the legacy Keras optimizer instead, located at `tf.keras.optimizers.legacy.Adam`.\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "from tensorflow.keras.models import load_model\n", "\n", @@ -806,17 +698,9 @@ }, { "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "15/15 [==============================] - 0s 5ms/step - loss: 0.7571 - auc: 0.4744 - binary_accuracy: 0.4948\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "loader_te = DisjointLoader(test, epochs=1, shuffle=False, batch_size=batch_size)\n", "results = model.evaluate(loader_te.load())" @@ -835,7 +719,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -875,24 +759,9 @@ }, { "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Processing frames: 100%|██████████| 500/500 [00:01<00:00, 288.30it/s]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "11/11 [==============================] - 0s 8ms/step\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "# Compute the graphs and add them to the CustomSpektralDataset\n", "pred_dataset = CustomSpektralDataset(graphs=preds_converter.to_spektral_graphs())\n", @@ -914,7 +783,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ diff --git a/tests/files/models/my-test-gnn/fingerprint.pb b/tests/files/models/my-test-gnn/fingerprint.pb index e534493..afda94e 100644 --- a/tests/files/models/my-test-gnn/fingerprint.pb +++ b/tests/files/models/my-test-gnn/fingerprint.pb @@ -1 +1 @@ -𒉼-ӍΕ (˔딬2 \ No newline at end of file +𒉼-ӍΕ (ש偡2 \ No newline at end of file diff --git a/tests/files/models/my-test-gnn/variables/variables.data-00000-of-00001 b/tests/files/models/my-test-gnn/variables/variables.data-00000-of-00001 index c4892e5..3a5809f 100644 Binary files a/tests/files/models/my-test-gnn/variables/variables.data-00000-of-00001 and b/tests/files/models/my-test-gnn/variables/variables.data-00000-of-00001 differ diff --git a/tests/files/models/my-test-gnn/variables/variables.index b/tests/files/models/my-test-gnn/variables/variables.index index b03300b..9c06f04 100644 Binary files a/tests/files/models/my-test-gnn/variables/variables.index and b/tests/files/models/my-test-gnn/variables/variables.index differ diff --git a/tests/files/test.pickle.gz b/tests/files/test.pickle.gz index dbd7373..de8316b 100644 Binary files a/tests/files/test.pickle.gz and b/tests/files/test.pickle.gz differ