{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"tpu1vmV38","dataSources":[{"sourceId":21154,"databundleVersionId":1243559,"sourceType":"competition"}],"dockerImageVersionId":30734,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import re\nimport os, glob\nimport time\nimport pandas as pd\nimport numpy as np\nimport tensorflow as tf\nimport matplotlib.pyplot as plt\nfrom tensorflow import keras\nfrom sklearn.model_selection import train_test_split\nfrom tensorflow.keras.applications import inception_v3\nfrom tensorflow.keras.applications.inception_v3 import InceptionV3\nfrom tensorflow.keras.layers import Dense, GlobalAveragePooling2D\nfrom tensorflow.keras.models import Model\nfrom tensorflow.keras.optimizers import Adam\nfrom tensorflow.keras.metrics import categorical_crossentropy","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-07-04T01:14:24.463646Z","iopub.execute_input":"2024-07-04T01:14:24.463888Z","iopub.status.idle":"2024-07-04T01:14:43.472898Z","shell.execute_reply.started":"2024-07-04T01:14:24.463861Z","shell.execute_reply":"2024-07-04T01:14:43.471885Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#zuerst wird sich mit der TPU verbunden und dann die Strategie definiert. Falls keine erreichbar ist, wird der Wert auf None gesetzt\ntry:\n    tpu = tf.distribute.cluster_resolver.TPUClusterResolver()\n    print('Running on TPU ', tpu.master())\nexcept ValueError:\n    tpu = None\n    \nif tpu:\n    tf.config.experimental_connect_to_cluster(tpu)              # Runtime verbindet sich mit der TPU\n    tf.tpu.experimental.initialize_tpu_system(tpu)              # TPU wird initialisiert\n    strategy = tf.distribute.experimental.TPUStrategy(tpu)      # Eine Strategie-Instanz wird erstellt (später wichtig)\nelse:\n    strategy = tf.distribute.get_strategy()\n    \n    \nprint(\"REPLICAS: \", strategy.num_replicas_in_sync)              # gibt die Anzahl der verfügbaren Cores der TPU aus\n","metadata":{"execution":{"iopub.status.busy":"2024-07-04T01:23:30.261324Z","iopub.execute_input":"2024-07-04T01:23:30.262048Z","iopub.status.idle":"2024-07-04T01:23:38.882762Z","shell.execute_reply.started":"2024-07-04T01:23:30.262016Z","shell.execute_reply":"2024-07-04T01:23:38.881514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Daten importieren\n\nfrom kaggle_datasets import KaggleDatasets\nGCS_DS_PATH = KaggleDatasets().get_gcs_path('tpu-getting-started')  # wir laden hier den Pfad vom GCS-Bucket in dem die Daten gespeichert sind\nprint(GCS_DS_PATH)","metadata":{"execution":{"iopub.status.busy":"2024-07-04T01:34:03.252341Z","iopub.execute_input":"2024-07-04T01:34:03.252651Z","iopub.status.idle":"2024-07-04T01:34:03.257467Z","shell.execute_reply.started":"2024-07-04T01:34:03.252625Z","shell.execute_reply":"2024-07-04T01:34:03.256858Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}