Parellization ok!

This commit is contained in:
2026-05-21 17:45:28 +02:00
parent 2174ab1fb0
commit 4b56e164a1

View File

@@ -29,7 +29,7 @@ Original file is located at
import sys
IN_COLAB = 'google.colab' in sys.modules
#if IN_COLAB:
# if IN_COLAB:
# !pip install pandas numpy matplotlib seaborn pillow scikit-learn tensorflow
# !pip install --upgrade kagglehub[pandas-datasets,hf-datasets]
@@ -282,24 +282,28 @@ data_augmentation = tf.keras.Sequential([
tf.keras.layers.RandomContrast(0.1),
])
base_model = DenseNet121(
with strategy.scope():
base_model = DenseNet121(
weights='imagenet',
include_top=False,
input_shape=(224, 224, 3)
)
)
inputs = tf.keras.Input(shape=(224,224,3))
with strategy.scope():
inputs = tf.keras.Input(shape=(224,224,3))
x = data_augmentation(inputs)
x = data_augmentation(inputs)
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(512, activation='relu')(x) # Added another Dense layer
x = Dense(256, activation='relu')(x) # Existing Dense layer
predictions = Dense(1, activation='sigmoid')(x) # Output layer for binary classification
with strategy.scope():
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dense(512, activation='relu')(x) # Added another Dense layer
x = Dense(256, activation='relu')(x) # Existing Dense layer
predictions = Dense(1, activation='sigmoid')(x) # Output layer for binary classification
model = Model(inputs=base_model.input, outputs=predictions)
model.compile(optimizer=Adam(learning_rate=0.0001), loss='binary_crossentropy', metrics=['accuracy'])
with strategy.scope():
model = Model(inputs=base_model.input, outputs=predictions)
model.compile(optimizer=Adam(learning_rate=0.0001), loss='binary_crossentropy', metrics=['accuracy'])
"""## 4. Data Generators