{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceType":"competition","sourceId":3649,"databundleVersionId":46718,"isSourceIdPinned":false}],"dockerImageVersionId":31286,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras import datasets, layers, models\nimport matplotlib.pyplot as plt","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T21:09:12.519775Z","iopub.execute_input":"2026-03-04T21:09:12.523586Z","iopub.status.idle":"2026-03-04T21:09:12.535369Z","shell.execute_reply.started":"2026-03-04T21:09:12.523544Z","shell.execute_reply":"2026-03-04T21:09:12.534209Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"(x_train, y_train), (x_test, y_test) = datasets.cifar10.load_data()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T21:09:12.537991Z","iopub.execute_input":"2026-03-04T21:09:12.538389Z","iopub.status.idle":"2026-03-04T21:09:15.423733Z","shell.execute_reply.started":"2026-03-04T21:09:12.538361Z","shell.execute_reply":"2026-03-04T21:09:15.422621Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = models.Sequential([\n    layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)),\n    layers.MaxPooling2D((2, 2)),\n    layers.Conv2D(64, (3, 3), activation='relu'),\n    layers.MaxPooling2D((2, 2)),\n    layers.Conv2D(64, (3, 3), activation='relu'),\n    layers.Flatten(),\n    layers.Dense(64, activation='relu'),\n    layers.Dense(10)\n])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T21:09:15.424830Z","iopub.execute_input":"2026-03-04T21:09:15.425233Z","iopub.status.idle":"2026-03-04T21:09:15.496544Z","shell.execute_reply.started":"2026-03-04T21:09:15.425203Z","shell.execute_reply":"2026-03-04T21:09:15.495434Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.compile(optimizer='adam',\n              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n              metrics=['accuracy'])\n\nmodel.fit(x_train, y_train, epochs=10, validation_data=(x_test, y_test))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T21:09:15.497865Z","iopub.execute_input":"2026-03-04T21:09:15.498317Z","iopub.status.idle":"2026-03-04T21:15:15.871459Z","shell.execute_reply.started":"2026-03-04T21:09:15.498275Z","shell.execute_reply":"2026-03-04T21:15:15.870050Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_loss, test_acc = model.evaluate(x_test, y_test, verbose=2)\nprint(f'\\nTest accuracy: {test_acc}')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T21:15:15.873816Z","iopub.execute_input":"2026-03-04T21:15:15.874565Z","iopub.status.idle":"2026-03-04T21:15:18.475383Z","shell.execute_reply.started":"2026-03-04T21:15:15.874530Z","shell.execute_reply":"2026-03-04T21:15:18.474157Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.save('my_cifar10_model.h5')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T21:15:18.476581Z","iopub.execute_input":"2026-03-04T21:15:18.476830Z","iopub.status.idle":"2026-03-04T21:15:18.547762Z","shell.execute_reply.started":"2026-03-04T21:15:18.476807Z","shell.execute_reply":"2026-03-04T21:15:18.546469Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"loaded_model = tf.keras.models.load_model('my_cifar10_model.h5')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-03-04T21:15:18.549167Z","iopub.execute_input":"2026-03-04T21:15:18.549547Z","iopub.status.idle":"2026-03-04T21:15:18.652941Z","shell.execute_reply.started":"2026-03-04T21:15:18.549507Z","shell.execute_reply":"2026-03-04T21:15:18.651849Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}