python_for_microscopists
python_for_microscopists copied to clipboard
Unable to use class_weights: `class_weight` not supported for 3+ dimensional targets.
I have 9 classes and one is for background. But when I pass class_weight to model.fit(), an error pops in:
class_weight not supported for 3+ dimensional targets.
I'm using the following set of lines to calculate class_weights
classweights = class_weight.compute_class_weight('balanced', classes = np.unique(y), y= y_reshaped)
class_weights = {}
for i in range(n_classes):
class_weights[i] = classweights[i]
print(class_weights)