Commit 433e706b authored by Milan Straka's avatar Milan Straka Committed by Rasmus Munk Larsen
Browse files

Remove errorneous squeeze in `tf.contrib.losses.sparse_softmax_cross_entropy_loss` (#7021)

* Remove errorneous squeeze.

The tf.contrib.losses.sparse_softmax_cross_entropy_loss has an weights
parameter which can be used to weight the individual batch elements.
The weights parameter can have various shape, which are all taken care
of in compute_weighted_loss.

However, the sparse_softmax_cross_entropy_loss methods contains an
errorneous squeeze of the weights. If some dimension of weights is not
known, the number of dimensions after the squeeze is unknown, which
causes the compute_weighted_loss method to throw an exception.
However, if the squeeze in sparse_softmax_cross_entropy_loss is not
called, compute_weighted_loss can deal even with unknown dimensions of
weights.

Note that tf.contrib.losses.softmax_cross_entropy_loss does not contain
the squeeze of the weights, even if it uses the weights argument in an
equal way.

Should fix #6846.

* Add tests for #6846 (dynamically shaped weights).

Add tests for #6846 -- dynamically shaped weights of the
contrib.losses.softmax_cross_entropy and
contrib.losses.sparse_softmax_cross_entropy losses.
parent d413f62f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment