license import { customGrad } from '../gradients' ; import { Tensor } from '../tensor' ; import { convertToTensor } from '../tensor_util_env' ; import { TensorLike } from '../types' ; import { mul } from './mul' ; import { neg } from './neg' ; import { op } from './operation' ; import { sigmoid } from './sigmoid' ; import { softplus } from './softplus' ; param x doc function logSigmoid_ < T extends Tensor > ( x ) { const $x = convertToTensor ( x , 'x' , 'logSigmoid' ) ; const customOp = customGrad ( ( x ) => { const value = neg ( softplus ( neg ( x ) ) ) ; const gradFunc = ( dy ) => { const derX = mul ( dy , sigmoid ( neg ( x ) ) ) ; return derX ; } ; return { value , gradFunc } ; } ) ; return customOp ( $x ) as T ; } export const logSigmoid = op ( { logSigmoid_ } ) ;