Skip to content

Commit

Permalink
Add missing losses.md file.
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed Mar 13, 2017
1 parent 37e8234 commit 7841b7f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 40 deletions.
29 changes: 29 additions & 0 deletions docs/templates/losses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

## Usage of loss functions

A loss function (or objective function, or optimization score function) is one of the two parameters required to compile a model:

```python
model.compile(loss='mean_squared_error', optimizer='sgd')
```

You can either pass the name of an existing loss function, or pass a TensorFlow/Theano symbolic function that returns a scalar for each data-point and takes the following two arguments:

- __y_true__: True labels. TensorFlow/Theano tensor.
- __y_pred__: Predictions. TensorFlow/Theano tensor of the same shape as y_true.

The actual optimized objective is the mean of the output array across all datapoints.

For a few examples of such functions, check out the [losses source](https://github.com/fchollet/keras/blob/master/keras/losses.py).

## Available loss functions

{{autogenerated}}

**Note**: when using the `categorical_crossentropy` loss, your targets should be in categorical format (e.g. if you have 10 classes, the target for each sample should be a 10-dimensional vector that is all-zeros expect for a 1 at the index corresponding to the class of the sample). In order to convert *integer targets* into *categorical targets*, you can use the Keras utility `to_categorical`:

```python
from keras.utils.np_utils import to_categorical

categorical_labels = to_categorical(int_labels, num_classes=None)
```
40 changes: 0 additions & 40 deletions docs/templates/objectives.md

This file was deleted.

0 comments on commit 7841b7f

Please sign in to comment.