File size: 1,244 Bytes
68ed147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from tensorflow.keras.models import Sequential
import tensorflow.keras.layers as tfl

def cat_dog_model(image_size, image_channel):
    model = Sequential([
        # Block 1
        tfl.Conv2D(32, (3, 3), activation='relu', input_shape=(image_size, image_size, image_channel)),
        tfl.BatchNormalization(),
        tfl.MaxPooling2D(pool_size=(2, 2)),
        tfl.Dropout(0.2),

        # Block 2
        tfl.Conv2D(64, (3, 3), activation='relu'),
        tfl.BatchNormalization(),
        tfl.MaxPooling2D(pool_size=(2, 2)),
        tfl.Dropout(0.2),

        # Block 3
        tfl.Conv2D(128, (3, 3), activation='relu'),
        tfl.BatchNormalization(),
        tfl.MaxPooling2D(pool_size=(2, 2)),
        tfl.Dropout(0.2),

        # Block 4
        tfl.Conv2D(256, (3, 3), activation='relu'),
        tfl.BatchNormalization(),
        tfl.MaxPooling2D(pool_size=(2, 2)),
        tfl.Dropout(0.2),

        # Fully Connected Layers
        tfl.Flatten(),
        tfl.Dense(512, activation='relu'),
        tfl.BatchNormalization(),
        tfl.Dropout(0.2),

        # Output Layer (Softmax for multi-class classification)
        tfl.Dense(1, activation='sigmoid')
    ])
    
    return model