Hard shrink function.

activation_hardshrink(x, lower = -0.5, upper = 0.5)

Arguments

x

A `Tensor`. Must be one of the following types: `float16`, `float32`, `float64`.

lower

`float`, lower bound for setting values to zeros.

upper

`float`, upper bound for setting values to zeros. Returns: A `Tensor`. Has the same type as `x`.

Value

A `Tensor`. Has the same type as `x`.

Details

Computes hard shrink function: `x if x < lower or x > upper else 0`.

Computes hard shrink function

`x if x < lower or x > upper else 0`.

Examples

if (FALSE) { library(keras) library(tfaddons) model = keras_model_sequential() %>% layer_conv_2d(filters = 10, kernel_size = c(3,3),input_shape = c(28,28,1), activation = activation_hardshrink) }