0 votes

I was going through the tensorflow API docs here. In the tensorflow documentation, they used a keyword called logits. What is it? In a lot of methods in the API docs it is written like

`tf.nn.softmax(logits, name=None)`

If what is written is those logits are only Tensors, why keeping a different name like logits?

Another thing is that there are two methods I could not differentiate. They were

```tf.nn.softmax(logits, name=None)
tf.nn.softmax_cross_entropy_with_logits(logits, labels, name=None)```

What are the differences between them? The docs are not clear to me. I know what tf.nn.softmaxdoes. But not the other. An example will be really helpful.

Nov 12, 2018 in Python 4,355 views

## 1 answer to this question.

–1 vote

Suppose you have two tensors, where y_hat contains computed scores for each class (for example, from y = W*x +b) and y_true contains one-hot encoded true labels.

```y_hat  = ... # Predicted label, e.g. y = tf.matmul(X, W) + b
y_true = ... # True label, one-hot encoded```

If you interpret the scores in y_hat as unnormalized log probabilities, then they are logits.

Additionally, the total cross-entropy loss computed in this manner:

```y_hat_softmax = tf.nn.softmax(y_hat)
total_loss = tf.reduce_mean(-tf.reduce_sum(y_true * tf.log(y_hat_softmax), [1]))```

is essentially equivalent to the total cross-entropy loss computed with the function softmax_cross_entropy_with_logits():

`total_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(y_hat, y_true))`
answered Nov 12, 2018 by
• 3,560 points

+1 vote
7 answers

## What do you mean by python scripting? What is a script and a module in python?

A module is a file containing a ...READ MORE

+1 vote
1 answer

## What is the difference between range and xrange functions in Python 2.X?

xrange only stores the range params and ...READ MORE

0 votes
4 answers

## What is a Tuple in Python and how to use it?

Tuples  are a  Unchanging sequence of values, ...READ MORE

+1 vote
4 answers

## In Python, what is difference between Array and List?

Lists and arrays are used in Python ...READ MORE

0 votes
2 answers

## how can i randomly select items from a list?

You can also use the random library's ...READ MORE

+1 vote
2 answers

## how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

0 votes
1 answer

## how do i use the enumerate function inside a list?

Enumerate() method adds a counter to an ...READ MORE

+5 votes
6 answers

## Lowercase in Python

You can simply the built-in function in ...READ MORE

0 votes
1 answer

## What is absolute import in Python and how is it used?

An absolute {import, path, URL} tells you exactly how ...READ MORE

0 votes
1 answer

## Is multi-threading supported in Python and can it speed up execution time as well?

The GIL does not prevent threading. All ...READ MORE