Created
September 27, 2023 16:24
-
-
Save DiogoRibeiro7/8fc0f09369cbadcbae6c7dea891d7f4c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tensorflow.keras.models import Sequential | |
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense | |
def build_cnn(input_shape): | |
""" | |
Build a Convolutional Neural Network (CNN) for medical imaging. | |
Parameters: | |
input_shape (tuple): The shape of input images. | |
Returns: | |
Sequential: A simple CNN model. | |
""" | |
model = Sequential() | |
model.add(Conv2D(32, (3, 3), activation='relu', input_shape=input_shape)) | |
model.add(MaxPooling2D(pool_size=(2, 2))) | |
model.add(Flatten()) | |
model.add(Dense(128, activation='relu')) | |
model.add(Dense(1, activation='sigmoid')) | |
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy']) | |
return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment