We know that we can pass the dictionary of weight classes in the fitting method for unbalanced data in binary classification. My question is that when using only 1 node in the output layer with sigmoid activation, can we still apply class weights during training?
model = Sequential()
model.add(Dense(64, activation='tanh',input_shape=(len(x_train[0]),)))
model.add(Dense(1, activation='sigmoid'))
model.compile(
optimizer=optimizer,
loss=loss,
metrics=metrics)
model.fit(
x_train, y_train,
epochs=args.e,
batch_size=batch_size,
class_weight={0: 1, 1: 3})
source
share