This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Example TensorFlow script for finetuning a VGG model on your own data. | |
| Uses tf.contrib.data module which is in release v1.2 | |
| Based on PyTorch example from Justin Johnson | |
| (https://gist.github.com/jcjohnson/6e41e8512c17eae5da50aebef3378a4c) | |
| Required packages: tensorflow (v1.2) | |
| Download the weights trained on ImageNet for VGG: | |
| ``` | |
| wget http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz |