I am currently struggling with a problem that occurs when I execute my CNN training algorithm with class weights dictionary. I am following this tutorial. There are no problems with the code but, when I start to train the network, suddenly the inscription appears:
Kernel died, restarting
Has someone had my same problem? Could it be a problem with the loss function?
loss_fun = 'categorical_crossentropy'
Optimizer = 'Adam with lr=0.0001'
model = create_model_fun(choice, H, W, input_size)
model.compile(Adam(lr=.0001), loss=loss_fun, metrics=['accuracy'])
# Class Weights
output_shape = len(PD_Dict)
total = sum(N_PD_Samples)
weight_for_i = [(1 / N_PD_Samples[ii])*(total)/output_shape for ii in range(output_shape)]
class_weight = {}
for ii in range(output_shape):
class_weight[ii] = weight_for_i[ii]
history = model.fit(train_map, np.array(train_lab_Matr), validation_data=(valid_map, np.array(
valid_lab_Matr)), epochs=N_epochs, shuffle=True, batch_size=Dim_Batch, callbacks=[es, mc], class_weight=class_weight)