I have imbalanced dataset with 2 classes. I am using categorical_crossentropy
. I wonder about my code. Is it correct to use class_weight
with categorical_crossentropy
?? If yes , does the class_weight
applied only to training set or to the whole data??
I have searched many times but I didn't find any helpful sites. Any help would be appreciated.
my code:
model.compile(loss='categorical_crossentropy', optimizer=opt_adam, metrics=['accuracy'])
history=model.fit_generator(generate_arrays_for_training(indexPat, train_data, start=0,end=100)
validation_data=generate_arrays_for_training(indexPat, test_data, start=0,end=100)
steps_per_epoch=int((len(train_data)/2)),
validation_steps=int((len(test_data)/2)),
verbose=2,class_weight = {0:1, 1:1.181},
epochs=65, max_queue_size=2, shuffle=True)