Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Define Top2 and Top3 Accuracy
- from keras.metrics import categorical_accuracy, top_k_categorical_accuracy
- def top_3_accuracy(y_true, y_pred):
- return top_k_categorical_accuracy(y_true, y_pred, k=3)
- def top_2_accuracy(y_true, y_pred):
- return top_k_categorical_accuracy(y_true, y_pred, k=2)
- # Compile the model
- model.compile(Adam(lr=0.01), loss='categorical_crossentropy', metrics=[categorical_accuracy, top_2_accuracy, top_3_accuracy])
- # Add weights to make the model more sensitive to melanoma
- class_weights={
- 0: 1.0, # akiec
- 1: 1.0, # bcc
- 2: 1.0, # bkl
- 3: 1.0, # df
- 4: 3.0, # mel
- 5: 1.0, # nv
- 6: 1.0, # vasc
- }
Add Comment
Please, Sign In to add comment