Both training and validation accuracy is stuck at 50%

I am trying to perform binary classification on image data (mammographs). The dataset is perfectly balanced. I am using EfficientnetV2S model for the classification, but the training and validation accuracy both are stuck at 50%. The following is the code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Loading the Data
train_df = new_df.sample(frac=0.7, random_state=0) # 70% of the data for training
valid_df = new_df.drop(train_df.index) # remaining 30% for validation and testing
batch_size = 32
# Create a data generator for training data
train_datagen = ImageDataGenerator(
# rescale=1./255,
rotation_range=20,
width_shift_range=0.1,
height_shift_range=0.1,
zoom_range=0.2,
horizontal_flip=True,
vertical_flip=False, # Typically not used for mammography
fill_mode='nearest'
)
train_generator = train_datagen.flow_from_dataframe(
dataframe=train_df,
x_col='images_filepath',
y_col='labels',
target_size=(224, 224), # adjust this to the size of your images
batch_size=batch_size,
shuffle = True,
class_mode='binary' # use 'categorical' for multi-class problems
)
# Create a data generator for test data
valid_datagen = ImageDataGenerator(
# rescale=1./255,
rotation_range=20,
width_shift_range=0.1,
height_shift_range=0.1,
zoom_range=0.2,
horizontal_flip=True,
vertical_flip=False, # Typically not used for mammography
fill_mode='nearest'
)
valid_generator = valid_datagen.flow_from_dataframe(
dataframe=valid_df,
x_col='images_filepath',
y_col='labels',
target_size=(224, 224), # adjust this to the size of your images
batch_size=batch_size,
shuffle = True,
class_mode='binary' # use 'categorical' for multi-class problems
)
# Train the model
efficientnet_model = keras.applications.EfficientNetV2S(
include_top=False,
weights="imagenet",
input_tensor=Input(shape=(224, 224, 3))
)
x = Flatten()(efficientnet_model.output)
x_class = Dense(256, activation='relu')(x)
x_class = Dropout(0.5)(x_class)
output = Dense(1, activation='sigmoid')(x)
model = Model(inputs=efficientnet_model.input, outputs=output)
optimizer = Adam(learning_rate=1e-6, beta_1=0.9, beta_2=0.999)
model.compile(
loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
optimizer=optimizer,
metrics=["accuracy"],
)
history = model.fit(train_generator, epochs=10, validation_data=valid_generator)
</code>
<code># Loading the Data train_df = new_df.sample(frac=0.7, random_state=0) # 70% of the data for training valid_df = new_df.drop(train_df.index) # remaining 30% for validation and testing batch_size = 32 # Create a data generator for training data train_datagen = ImageDataGenerator( # rescale=1./255, rotation_range=20, width_shift_range=0.1, height_shift_range=0.1, zoom_range=0.2, horizontal_flip=True, vertical_flip=False, # Typically not used for mammography fill_mode='nearest' ) train_generator = train_datagen.flow_from_dataframe( dataframe=train_df, x_col='images_filepath', y_col='labels', target_size=(224, 224), # adjust this to the size of your images batch_size=batch_size, shuffle = True, class_mode='binary' # use 'categorical' for multi-class problems ) # Create a data generator for test data valid_datagen = ImageDataGenerator( # rescale=1./255, rotation_range=20, width_shift_range=0.1, height_shift_range=0.1, zoom_range=0.2, horizontal_flip=True, vertical_flip=False, # Typically not used for mammography fill_mode='nearest' ) valid_generator = valid_datagen.flow_from_dataframe( dataframe=valid_df, x_col='images_filepath', y_col='labels', target_size=(224, 224), # adjust this to the size of your images batch_size=batch_size, shuffle = True, class_mode='binary' # use 'categorical' for multi-class problems ) # Train the model efficientnet_model = keras.applications.EfficientNetV2S( include_top=False, weights="imagenet", input_tensor=Input(shape=(224, 224, 3)) ) x = Flatten()(efficientnet_model.output) x_class = Dense(256, activation='relu')(x) x_class = Dropout(0.5)(x_class) output = Dense(1, activation='sigmoid')(x) model = Model(inputs=efficientnet_model.input, outputs=output) optimizer = Adam(learning_rate=1e-6, beta_1=0.9, beta_2=0.999) model.compile( loss=tf.keras.losses.BinaryCrossentropy(from_logits=True), optimizer=optimizer, metrics=["accuracy"], ) history = model.fit(train_generator, epochs=10, validation_data=valid_generator) </code>
# Loading the Data
train_df = new_df.sample(frac=0.7, random_state=0)  # 70% of the data for training
valid_df = new_df.drop(train_df.index)  # remaining 30% for validation and testing

batch_size = 32

# Create a data generator for training data
train_datagen = ImageDataGenerator(
    # rescale=1./255,
    rotation_range=20,
    width_shift_range=0.1,
    height_shift_range=0.1,
    zoom_range=0.2,
    horizontal_flip=True,
    vertical_flip=False,  # Typically not used for mammography
    fill_mode='nearest'
    )
train_generator = train_datagen.flow_from_dataframe(
    dataframe=train_df,
    x_col='images_filepath',
    y_col='labels',
    target_size=(224, 224),  # adjust this to the size of your images
    batch_size=batch_size,
    shuffle = True,
    class_mode='binary'  # use 'categorical' for multi-class problems
)

# Create a data generator for test data
valid_datagen = ImageDataGenerator(
    # rescale=1./255,
    rotation_range=20,
    width_shift_range=0.1,
    height_shift_range=0.1,
    zoom_range=0.2,
    horizontal_flip=True,
    vertical_flip=False,  # Typically not used for mammography
    fill_mode='nearest'
    )

valid_generator = valid_datagen.flow_from_dataframe(
    dataframe=valid_df,
    x_col='images_filepath',
    y_col='labels',
    target_size=(224, 224),  # adjust this to the size of your images
    batch_size=batch_size,
    shuffle = True,
    class_mode='binary'  # use 'categorical' for multi-class problems
)

# Train the model

efficientnet_model = keras.applications.EfficientNetV2S(
    include_top=False,
    weights="imagenet",
    input_tensor=Input(shape=(224, 224, 3))
)
x = Flatten()(efficientnet_model.output)
x_class = Dense(256, activation='relu')(x)
x_class = Dropout(0.5)(x_class)
output = Dense(1, activation='sigmoid')(x)

model = Model(inputs=efficientnet_model.input, outputs=output)

optimizer = Adam(learning_rate=1e-6, beta_1=0.9, beta_2=0.999)

model.compile(
    loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
    optimizer=optimizer,
    metrics=["accuracy"],
)

history = model.fit(train_generator, epochs=10, validation_data=valid_generator)

I tried changing the hyperparameters but its still the same.

New contributor

Harshkumar Mahesh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật