log_softmax#
- ivy.log_softmax(x, /, *, axis=None, complex_mode='jax', out=None)[source]#
- Apply the log_softmax function element-wise. - Parameters:
- x ( - Union[- Array,- NativeArray]) – Input array.
- axis ( - Optional[- int], default:- None) – The dimension log_softmax would be performed on. The default is- None.
- complex_mode ( - Literal[- 'split',- 'magnitude',- 'jax'], default:- 'jax') – optional specifier for how to handle complex data types. See- ivy.func_wrapper.handle_complex_inputfor more detail.
- out ( - Optional[- Array], default:- None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.
 
- Return type:
- Returns:
- ret – The output array with log_softmax applied element-wise to input. 
 - Examples - With - ivy.Arrayinput:- >>> x = ivy.array([-1.0, -0.98]) >>> y = ivy.log_softmax(x) >>> print(y) ivy.array([-0.703, -0.683]) - >>> x = ivy.array([1.0, 2.0, 3.0]) >>> y = ivy.log_softmax(x) >>> print(y) ivy.array([-2.41, -1.41, -0.408]) - With - ivy.NativeArrayinput:- >>> x = ivy.native_array([1.5, 0.5, 1.0]) >>> y = ivy.log_softmax(x) >>> print(y) ivy.array([-0.68, -1.68, -1.18]) - With - ivy.Containerinput:- >>> x = ivy.Container(a=ivy.array([1.5, 0.5, 1.0])) >>> y = ivy.log_softmax(x) >>> print(y) { a: ivy.array([-0.68, -1.68, -1.18]) } - >>> x = ivy.Container(a=ivy.array([1.0, 2.0]), b=ivy.array([0.4, -0.2])) >>> y = ivy.log_softmax(x) >>> print(y) { a: ivy.array([-1.31, -0.313]), b: ivy.array([-0.437, -1.04]) } 
- Array.log_softmax(self, /, *, axis=-1, complex_mode='jax', out=None)[source]#
- ivy.Array instance method variant of ivy.log_softmax. This method simply wraps the function, and so the docstring for ivy.log_softmax also applies to this method with minimal changes. - Parameters:
- self ( - Array) – input array.
- axis ( - Optional[- int], default:- -1) – the axis or axes along which the log_softmax should be computed
- complex_mode ( - Literal[- 'split',- 'magnitude',- 'jax'], default:- 'jax') – optional specifier for how to handle complex data types. See- ivy.func_wrapper.handle_complex_inputfor more detail.
- out ( - Optional[- Array], default:- None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.
 
- Return type:
- Array
- Returns:
- ret – an array with the log_softmax activation function applied element-wise. 
 - Examples - >>> x = ivy.array([-1.0, -0.98, 2.3]) >>> y = x.log_softmax() >>> print(y) ivy.array([-3.37, -3.35, -0.0719]) - >>> x = ivy.array([2.0, 3.4, -4.2]) >>> y = x.log_softmax(x) ivy.array([-1.62, -0.221, -7.82 ]) 
- Container.log_softmax(self, /, *, axis=-1, complex_mode='jax', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
- ivy.Container instance method variant of ivy.log_softmax. This method simply wraps the function, and so the docstring for ivy.log_softmax also applies to this method with minimal changes. - Parameters:
- self ( - Container) – input container.
- axis ( - Optional[- Container], default:- -1) – the axis or axes along which the log_softmax should be computed
- complex_mode ( - Literal[- 'split',- 'magnitude',- 'jax'], default:- 'jax') – optional specifier for how to handle complex data types. See- ivy.func_wrapper.handle_complex_inputfor more detail.
- key_chains ( - Optional[- Union[- List[- str],- Dict[- str,- str],- Container]], default:- None) – The key-chains to apply or not apply the method to. Default is- None.
- to_apply ( - Union[- bool,- Container], default:- True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is- True.
- prune_unapplied ( - Union[- bool,- Container], default:- False) – Whether to prune key_chains for which the function was not applied. Default is- False.
- map_sequences ( - Union[- bool,- Container], default:- False) – Whether to also map method to sequences (lists, tuples). Default is- False.
- out ( - Optional[- Container], default:- None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.
 
- Returns:
- ret – a container with the log_softmax unit function applied element-wise. 
 - Examples - >>> x = ivy.Container(a=ivy.array([-1.0, -0.98, 2.3])) >>> y = x.log_softmax() >>> print(y) { a: ivy.array([-3.37, -3.35, -0.0719]) } - >>> x = ivy.Container(a=ivy.array([1.0, 2.4]), b=ivy.array([-0.2, -1.0])) >>> y = x.log_softmax() >>> print(y) { a: ivy.array([-1.62, -0.22]), b: ivy.array([-0.371, -1.17]) }