Skip to content

Instantly share code, notes, and snippets.

View TsaiYunLin's full-sized avatar
🤑
Working from home

KevinTsai TsaiYunLin

🤑
Working from home
View GitHub Profile
@TsaiYunLin
TsaiYunLin / live_loss_plot_keras.ipynb
Created April 10, 2019 03:25 — forked from stared/live_loss_plot_keras.ipynb
Live loss plot for training models in Keras (see: https://github.com/stared/livelossplot/ for a library)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""
A weighted version of categorical_crossentropy for keras (2.0.6). This lets you apply a weight to unbalanced classes.
@url: https://gist.github.com/wassname/ce364fddfc8a025bfab4348cf5de852d
@author: wassname
"""
from keras import backend as K
def weighted_categorical_crossentropy(weights):
"""
A weighted version of keras.objectives.categorical_crossentropy