giagrad.Tensor.log_softmax#
- Tensor.log_softmax(axis: int) Tensor [source]#
Applies LogSoftmax function to every 1-D slice defined by
axis
.LogSoftmax for a one-dimensional slice is defined as:
\[\text{LogSoftmax}(x_i) = \log \left( \frac{\exp(x_i)}{\sum_j \exp(x_j)} \right)\]- Parameters:
axis¶ (int) – The dimension along which LogSoftmax will be computed.
Examples
>>> t = Tensor.empty(2, 3).uniform(-1, 1) >>> t tensor: [[-0.07469178 0.7226724 0.98966014] [-0.01990889 -0.4521888 0.26520386]] >>> t.softmax(axis=1) tensor: [[-0.72091377 -0.26915795 -0.39513725] [-0.6661309 -1.4440191 -1.1195936 ]] fn: LogSoftmax(axis=0)