{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pwd","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:22:13.514089Z","iopub.execute_input":"2021-07-26T05:22:13.514412Z","iopub.status.idle":"2021-07-26T05:22:13.523763Z","shell.execute_reply.started":"2021-07-26T05:22:13.514382Z","shell.execute_reply":"2021-07-26T05:22:13.520864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:20:08.794361Z","iopub.execute_input":"2021-07-26T05:20:08.794714Z","iopub.status.idle":"2021-07-26T05:20:09.483746Z","shell.execute_reply.started":"2021-07-26T05:20:08.794682Z","shell.execute_reply":"2021-07-26T05:20:09.482763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs-vs-cats","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:21:31.301383Z","iopub.execute_input":"2021-07-26T05:21:31.301748Z","iopub.status.idle":"2021-07-26T05:21:31.941715Z","shell.execute_reply.started":"2021-07-26T05:21:31.301705Z","shell.execute_reply":"2021-07-26T05:21:31.940805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ./","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:22:42.616766Z","iopub.execute_input":"2021-07-26T05:22:42.617124Z","iopub.status.idle":"2021-07-26T05:22:42.622588Z","shell.execute_reply.started":"2021-07-26T05:22:42.617094Z","shell.execute_reply":"2021-07-26T05:22:42.621453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls -l","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:23:56.585851Z","iopub.execute_input":"2021-07-26T05:23:56.586237Z","iopub.status.idle":"2021-07-26T05:23:57.259276Z","shell.execute_reply.started":"2021-07-26T05:23:56.586202Z","shell.execute_reply":"2021-07-26T05:23:57.258226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pwd","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:26:17.77007Z","iopub.execute_input":"2021-07-26T05:26:17.770418Z","iopub.status.idle":"2021-07-26T05:26:17.775915Z","shell.execute_reply.started":"2021-07-26T05:26:17.770387Z","shell.execute_reply":"2021-07-26T05:26:17.775065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:26:41.211541Z","iopub.execute_input":"2021-07-26T05:26:41.211892Z","iopub.status.idle":"2021-07-26T05:26:41.844507Z","shell.execute_reply.started":"2021-07-26T05:26:41.211865Z","shell.execute_reply":"2021-07-26T05:26:41.843633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs-vs-cats","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:27:05.039425Z","iopub.execute_input":"2021-07-26T05:27:05.039817Z","iopub.status.idle":"2021-07-26T05:27:05.72167Z","shell.execute_reply.started":"2021-07-26T05:27:05.039779Z","shell.execute_reply":"2021-07-26T05:27:05.720494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:27:15.54106Z","iopub.execute_input":"2021-07-26T05:27:15.541432Z","iopub.status.idle":"2021-07-26T05:27:16.243249Z","shell.execute_reply.started":"2021-07-26T05:27:15.541396Z","shell.execute_reply":"2021-07-26T05:27:16.24238Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#ファイルの解凍\nimport zipfile\n\nwith zipfile.ZipFile('../input/dogs-vs-cats-redux-kernels-edition/test.zip') as existing_zip:\n    existing_zip.extractall()\nwith zipfile.ZipFile('../input/dogs-vs-cats-redux-kernels-edition/train.zip') as existing_zip:\n    existing_zip.extractall()","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:28:34.282709Z","iopub.execute_input":"2021-07-26T05:28:34.283072Z","iopub.status.idle":"2021-07-26T05:28:53.17308Z","shell.execute_reply.started":"2021-07-26T05:28:34.283041Z","shell.execute_reply":"2021-07-26T05:28:53.172207Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../input/dogs-vs-cats-redux-kernels-edition","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pwd","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:30:22.452588Z","iopub.execute_input":"2021-07-26T05:30:22.45294Z","iopub.status.idle":"2021-07-26T05:30:22.45885Z","shell.execute_reply.started":"2021-07-26T05:30:22.452911Z","shell.execute_reply":"2021-07-26T05:30:22.457662Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:30:28.682774Z","iopub.execute_input":"2021-07-26T05:30:28.683099Z","iopub.status.idle":"2021-07-26T05:30:29.321182Z","shell.execute_reply.started":"2021-07-26T05:30:28.68307Z","shell.execute_reply":"2021-07-26T05:30:29.320253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd train","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:31:18.967459Z","iopub.execute_input":"2021-07-26T05:31:18.967827Z","iopub.status.idle":"2021-07-26T05:31:18.976185Z","shell.execute_reply.started":"2021-07-26T05:31:18.967795Z","shell.execute_reply":"2021-07-26T05:31:18.975323Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:31:37.387389Z","iopub.execute_input":"2021-07-26T05:31:37.38773Z","iopub.status.idle":"2021-07-26T05:31:38.021195Z","shell.execute_reply.started":"2021-07-26T05:31:37.387699Z","shell.execute_reply":"2021-07-26T05:31:38.020143Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir cats","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:31:46.498445Z","iopub.execute_input":"2021-07-26T05:31:46.49881Z","iopub.status.idle":"2021-07-26T05:31:47.191558Z","shell.execute_reply.started":"2021-07-26T05:31:46.498776Z","shell.execute_reply":"2021-07-26T05:31:47.190368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:31:52.042214Z","iopub.execute_input":"2021-07-26T05:31:52.042603Z","iopub.status.idle":"2021-07-26T05:31:52.912477Z","shell.execute_reply.started":"2021-07-26T05:31:52.042565Z","shell.execute_reply":"2021-07-26T05:31:52.911511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls cats","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:33:43.684061Z","iopub.execute_input":"2021-07-26T05:33:43.684422Z","iopub.status.idle":"2021-07-26T05:33:44.366021Z","shell.execute_reply.started":"2021-07-26T05:33:43.68439Z","shell.execute_reply":"2021-07-26T05:33:44.364847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#フォルダの移動\nimport shutil\nimport glob\nimport os\n\ndef move_glob(dst_path, pathname, recursive=True):\n    for p in glob.glob(pathname, recursive=recursive):\n        shutil.move(p, dst_path)","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:34:10.761532Z","iopub.execute_input":"2021-07-26T05:34:10.761912Z","iopub.status.idle":"2021-07-26T05:34:10.766905Z","shell.execute_reply.started":"2021-07-26T05:34:10.761879Z","shell.execute_reply":"2021-07-26T05:34:10.765948Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"move_glob('/kaggle/working/train/dogs', 'dog*.jpg')","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:34:24.024292Z","iopub.execute_input":"2021-07-26T05:34:24.024617Z","iopub.status.idle":"2021-07-26T05:34:24.484526Z","shell.execute_reply.started":"2021-07-26T05:34:24.024586Z","shell.execute_reply":"2021-07-26T05:34:24.483698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"move_glob('/kaggle/working/train/cats', 'cat*.jpg')","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:34:35.165275Z","iopub.execute_input":"2021-07-26T05:34:35.165595Z","iopub.status.idle":"2021-07-26T05:34:35.599284Z","shell.execute_reply.started":"2021-07-26T05:34:35.165565Z","shell.execute_reply":"2021-07-26T05:34:35.598443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:34:41.25951Z","iopub.execute_input":"2021-07-26T05:34:41.259903Z","iopub.status.idle":"2021-07-26T05:34:41.939565Z","shell.execute_reply.started":"2021-07-26T05:34:41.259869Z","shell.execute_reply":"2021-07-26T05:34:41.938619Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:34:55.159148Z","iopub.execute_input":"2021-07-26T05:34:55.15954Z","iopub.status.idle":"2021-07-26T05:34:55.165672Z","shell.execute_reply.started":"2021-07-26T05:34:55.15951Z","shell.execute_reply":"2021-07-26T05:34:55.164813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir valid","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:35:08.027519Z","iopub.execute_input":"2021-07-26T05:35:08.027921Z","iopub.status.idle":"2021-07-26T05:35:08.6785Z","shell.execute_reply.started":"2021-07-26T05:35:08.027891Z","shell.execute_reply":"2021-07-26T05:35:08.677493Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd valid","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:35:17.48998Z","iopub.execute_input":"2021-07-26T05:35:17.490316Z","iopub.status.idle":"2021-07-26T05:35:17.497443Z","shell.execute_reply.started":"2021-07-26T05:35:17.490286Z","shell.execute_reply":"2021-07-26T05:35:17.496469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:35:27.46636Z","iopub.execute_input":"2021-07-26T05:35:27.466712Z","iopub.status.idle":"2021-07-26T05:35:28.096094Z","shell.execute_reply.started":"2021-07-26T05:35:27.466681Z","shell.execute_reply":"2021-07-26T05:35:28.095102Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir cats","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:35:41.238315Z","iopub.execute_input":"2021-07-26T05:35:41.238663Z","iopub.status.idle":"2021-07-26T05:35:41.867395Z","shell.execute_reply.started":"2021-07-26T05:35:41.238605Z","shell.execute_reply":"2021-07-26T05:35:41.866384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../train","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:35:53.277017Z","iopub.execute_input":"2021-07-26T05:35:53.277342Z","iopub.status.idle":"2021-07-26T05:35:53.282818Z","shell.execute_reply.started":"2021-07-26T05:35:53.277311Z","shell.execute_reply":"2021-07-26T05:35:53.281963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nimport numpy as np\n\ndef resize(src_file, dst_file, width, height):\n    \"\"\"\n    画像ファイルを与えられたサイズにサイズ変換する関数\n    アス比は固定、左上に寄せる、余った部分はゼロで埋める\n\n    Returns\n    -------\n    ret_scale : float\n    拡大/縮小した倍率\n    \"\"\"\n\n    src_img = cv2.imread(src_file)\n    h, w, c = src_img.shape\n    # dst_img = cv2.resize(src_img, dsize=(width, height))\n\n    # アス比固定, padding\n    scale_w = width / w\n    scale_h = height / h\n\n    ret_scale = 1.0\n    # Down Convert\n    if(scale_w < 1.0 or scale_h < 1.0):\n        if(scale_w < scale_h): \n            resize_img = cv2.resize(src_img, dsize=None, fx=scale_w, fy=scale_w, interpolation = cv2.INTER_AREA)\n            ret_scale = scale_w\n        else:\n            resize_img = cv2.resize(src_img, dsize=None, fx=scale_h, fy=scale_h, interpolation = cv2.INTER_AREA)\n            ret_scale = scale_h\n    else:\n        resize_img = src_img\n\n    # dst_img 生成\n    dst_img = np.zeros((height, width, 3), dtype = np.uint8)\n\n    # dst_imgにresize_imgを合成\n    top = 0\n    left = 0\n    #dst_img[top:height + top, left:width + left] = resize_img\n    h, w, c = resize_img.shape\n    dst_img[0:h, 0:w] = resize_img\n\n    cv2.imwrite(dst_file, dst_img)\n\n    return ret_scale","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:36:20.641508Z","iopub.execute_input":"2021-07-26T05:36:20.641898Z","iopub.status.idle":"2021-07-26T05:36:20.877344Z","shell.execute_reply.started":"2021-07-26T05:36:20.641868Z","shell.execute_reply":"2021-07-26T05:36:20.876448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for num in range(0, 12500):\n    resize('/kaggle/working/train/dogs/dog.' + str(num) + '.jpg', '/kaggle/working/train/dogs/dog.' + str(num) + '.jpg', 224, 224)\n    resize('/kaggle/working/train/cats/cat.' + str(num) + '.jpg', '/kaggle/working/train/cats/cat.' + str(num) + '.jpg', 224, 224)","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:37:28.614148Z","iopub.execute_input":"2021-07-26T05:37:28.614482Z","iopub.status.idle":"2021-07-26T05:39:16.172751Z","shell.execute_reply.started":"2021-07-26T05:37:28.614452Z","shell.execute_reply":"2021-07-26T05:39:16.171738Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for num in range(2500):\n    move_glob('/kaggle/working/valid/cats', '/kaggle/working/train/cats/cat.'+ str(num) +'.jpg')\n    move_glob('/kaggle/working/valid/dogs', '/kaggle/working/train/dogs/dog.'+ str(num) +'.jpg')","metadata":{"execution":{"iopub.status.busy":"2021-07-26T05:39:36.669216Z","iopub.execute_input":"2021-07-26T05:39:36.669549Z","iopub.status.idle":"2021-07-26T05:39:37.038237Z","shell.execute_reply.started":"2021-07-26T05:39:36.66952Z","shell.execute_reply":"2021-07-26T05:39:37.037218Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.preprocessing.image import ImageDataGenerator","metadata":{"execution":{"iopub.status.busy":"2021-07-27T01:46:37.763238Z","iopub.execute_input":"2021-07-27T01:46:37.763627Z","iopub.status.idle":"2021-07-27T01:46:42.000461Z","shell.execute_reply.started":"2021-07-27T01:46:37.763546Z","shell.execute_reply":"2021-07-27T01:46:41.999599Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import keras\nfrom keras.models import Sequential\nfrom keras.layers import Dense,Flatten\nfrom keras.layers import Conv2D,MaxPooling2D\nfrom keras import optimizers","metadata":{"execution":{"iopub.status.busy":"2021-07-27T01:46:45.654107Z","iopub.execute_input":"2021-07-27T01:46:45.654439Z","iopub.status.idle":"2021-07-27T01:46:45.661054Z","shell.execute_reply.started":"2021-07-27T01:46:45.65441Z","shell.execute_reply":"2021-07-27T01:46:45.660306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.preprocessing.image import ImageDataGenerator\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras import optimizers, regularizers\nfrom tensorflow.keras.layers import Dense, Flatten, Dropout\nfrom tensorflow.keras.layers import Conv2D, MaxPooling2D\nimport os\nimport datetime\nimport tensorflow as tf","metadata":{"execution":{"iopub.status.busy":"2021-07-27T01:46:48.586812Z","iopub.execute_input":"2021-07-27T01:46:48.587159Z","iopub.status.idle":"2021-07-27T01:46:48.591906Z","shell.execute_reply.started":"2021-07-27T01:46:48.587127Z","shell.execute_reply":"2021-07-27T01:46:48.59086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2021-07-26T06:56:09.43499Z","iopub.execute_input":"2021-07-26T06:56:09.435314Z","iopub.status.idle":"2021-07-26T06:56:10.103175Z","shell.execute_reply.started":"2021-07-26T06:56:09.435284Z","shell.execute_reply":"2021-07-26T06:56:10.102176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../","metadata":{"execution":{"iopub.status.busy":"2021-07-26T06:56:22.804972Z","iopub.execute_input":"2021-07-26T06:56:22.805381Z","iopub.status.idle":"2021-07-26T06:56:22.811412Z","shell.execute_reply.started":"2021-07-26T06:56:22.805345Z","shell.execute_reply":"2021-07-26T06:56:22.810513Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ls","metadata":{"execution":{"iopub.status.busy":"2021-07-26T06:56:29.053388Z","iopub.execute_input":"2021-07-26T06:56:29.05374Z","iopub.status.idle":"2021-07-26T06:56:29.71769Z","shell.execute_reply.started":"2021-07-26T06:56:29.053708Z","shell.execute_reply":"2021-07-26T06:56:29.716708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_dir = 'train'\nvalid_data_dir = 'valid'","metadata":{"execution":{"iopub.status.busy":"2021-07-27T01:46:53.095451Z","iopub.execute_input":"2021-07-27T01:46:53.095794Z","iopub.status.idle":"2021-07-27T01:46:53.099885Z","shell.execute_reply.started":"2021-07-27T01:46:53.095763Z","shell.execute_reply":"2021-07-27T01:46:53.098722Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_datagen = ImageDataGenerator(\n    rescale=1.0/255, rotation_range=90, horizontal_flip=True, channel_shift_range=50.)\nvalid_datagen = ImageDataGenerator(rescale=1.0/255)\n\ntrain_generator = train_datagen.flow_from_directory(\n    directory=train_data_dir, target_size=(224, 224), batch_size=64, class_mode=\"binary\")\nvalid_generator = valid_datagen.flow_from_directory(\n    directory=valid_data_dir, target_size=(224, 224), batch_size=64, class_mode=\"binary\")","metadata":{"execution":{"iopub.status.busy":"2021-07-27T01:46:55.994689Z","iopub.execute_input":"2021-07-27T01:46:55.995025Z","iopub.status.idle":"2021-07-27T01:46:56.307265Z","shell.execute_reply.started":"2021-07-27T01:46:55.994977Z","shell.execute_reply":"2021-07-27T01:46:56.305993Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = Sequential()\n\nmodel.add(Conv2D(64, kernel_size=(5, 5),\n          activation=\"relu\", kernel_regularizer=regularizers.l2(0.0001), input_shape=(224, 224, 3)))\n\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Conv2D(128, kernel_size=(5, 5),\n          kernel_regularizer=regularizers.l2(0.0001), activation=\"relu\"))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Conv2D(128, kernel_size=(5, 5),\n          kernel_regularizer=regularizers.l2(0.0001), activation=\"relu\"))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Conv2D(128, kernel_size=(5, 5),\n          kernel_regularizer=regularizers.l2(0.0001), activation=\"relu\"))\nmodel.add(MaxPooling2D(pool_size=(2, 2)))\nmodel.add(Flatten())\nmodel.add(Dense(256, activation=\"relu\"))\nmodel.add(Dropout(0.5))\nmodel.add(Dense(1, activation=\"sigmoid\"))\n\nopt = optimizers.Adam(learning_rate=0.0001)\nmodel.compile(loss=\"binary_crossentropy\",\n              optimizer=opt, metrics=[\"accuracy\"])","metadata":{"execution":{"iopub.status.busy":"2021-07-27T01:44:35.934696Z","iopub.execute_input":"2021-07-27T01:44:35.935092Z","iopub.status.idle":"2021-07-27T01:44:36.013013Z","shell.execute_reply.started":"2021-07-27T01:44:35.934986Z","shell.execute_reply":"2021-07-27T01:44:36.011245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.summary()","metadata":{"execution":{"iopub.status.busy":"2021-07-26T06:57:36.007974Z","iopub.execute_input":"2021-07-26T06:57:36.008318Z","iopub.status.idle":"2021-07-26T06:57:36.019396Z","shell.execute_reply.started":"2021-07-26T06:57:36.008288Z","shell.execute_reply":"2021-07-26T06:57:36.018528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(train_generator, \n                    epochs=80, \n                    verbose=1, \n                    validation_data=(valid_generator), \n                    steps_per_epoch=20000 / 64, \n                    validation_steps=5000/64)","metadata":{"execution":{"iopub.status.busy":"2021-07-26T06:58:08.509389Z","iopub.execute_input":"2021-07-26T06:58:08.50972Z"},"trusted":true},"execution_count":null,"outputs":[]}]}