CNN Project Cat_Dog.ipynb - Colab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

6/27/24, 10:35 AM CNN Project Cat_Dog.

ipynb - Colab

1 import tensorflow as tf
2 from tensorflow.keras.models import Sequential
3 from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Dropout
4 from tensorflow.keras.preprocessing.image import ImageDataGenerator
5 from tensorflow.keras.callbacks import ModelCheckpoint
6
7 # Ensure TensorFlow uses a GPU if available
8 print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
9

Num GPUs Available: 0

1 # Data generators for loading and augmenting images


2 train_datagen = ImageDataGenerator(
3 rescale=1./255,
4 shear_range=0.2,
5 zoom_range=0.2,
6 horizontal_flip=True
7 )
8
9 test_datagen = ImageDataGenerator(rescale=1./255)
10
11 # --------------------------------------------------------------------------------
12
13 training_set = train_datagen.flow_from_directory(
14 'dataset/training_set',
15 target_size=(64, 64),
16 batch_size=32,
17 class_mode='binary'
18 )
19
20 test_set = test_datagen.flow_from_directory(
21 'dataset/test_set',
22 target_size=(64, 64),
23 batch_size=32,
24 class_mode='binary'
25 )
26

https://colab.research.google.com/drive/1_zHYIMJQTErgo_YxcM_xyTZw6voZENs5#printMode=true 1/1

You might also like