Skip to content

Instantly share code, notes, and snippets.

@brookisme
brookisme / keras_weighted_categorical_crossentropy.py
Created August 29, 2018 19:58
Keras: Weighted Categorical Crossentropy
import numpy as np
import tensorflow as tf
import keras.backend as K
def weighted_categorical_crossentropy(weights):
""" weighted_categorical_crossentropy
Args:
* weights<ktensor|nparray|list>: crossentropy weights
@brookisme
brookisme / pytorch_weighted_categorical_crossentropy.py
Created August 29, 2018 20:01
Pytorch Weighted Categorical Crossentropy
import torch.nn as nn
import pytorch_nns.helpers as h
import pytorch_nns.functional as f
#
# HELPERS
#
def category_weights(
count_dict,
total=None,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.