SHARE
TWEET

Untitled

a guest Dec 15th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Define Top2 and Top3 Accuracy
  2. from keras.metrics import categorical_accuracy, top_k_categorical_accuracy
  3.  
  4. def top_3_accuracy(y_true, y_pred):
  5.     return top_k_categorical_accuracy(y_true, y_pred, k=3)
  6.  
  7. def top_2_accuracy(y_true, y_pred):
  8.     return top_k_categorical_accuracy(y_true, y_pred, k=2)
  9.  
  10. # Compile the model
  11. model.compile(Adam(lr=0.01), loss='categorical_crossentropy', metrics=[categorical_accuracy, top_2_accuracy, top_3_accuracy])
  12.  
  13. # Add weights to make the model more sensitive to melanoma
  14. class_weights={
  15.     0: 1.0,  # akiec
  16.     1: 1.0,  # bcc
  17.     2: 1.0,  # bkl
  18.     3: 1.0,  # df
  19.     4: 3.0,  # mel
  20.     5: 1.0,  # nv
  21.     6: 1.0,  # vasc
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top