forked from Kotlin/kotlindl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/tensorflow/addons/blob/master/tensorflow_addons/activations/tests/softshrink_test.py Related-To: Kotlin#170
- Loading branch information
1 parent
e5b2718
commit c6d3ad5
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
api/src/test/kotlin/org/jetbrains/kotlinx/dl/api/core/activation/SoftShrinkActivationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.jetbrains.kotlinx.dl.api.core.activation | ||
|
||
import org.junit.jupiter.api.Test | ||
|
||
|
||
internal class SoftShrinkActivationTest : ActivationTest() { | ||
@Test | ||
fun defaultBoundaries() { | ||
val input = floatArrayOf(-2.0f, -1.0f, 0.0f, 1.0f, 2.0f) | ||
val actual = floatArrayOf(0f, 0f, 0f, 0f, 0f) | ||
val expected = floatArrayOf(-1.5f, -0.5f, 0.0f, 0.5f, 1.5f) | ||
|
||
assertActivationFunction(SoftShrinkActivation(), input, actual, expected) | ||
} | ||
|
||
@Test | ||
fun explicitBoundaries() { | ||
val input = floatArrayOf(-2.0f, -1.0f, 0.0f, 1.0f, 2.0f) | ||
val actual = floatArrayOf(0f, 0f, 0f, 0f, 0f) | ||
val expected = floatArrayOf(-1.0f, 0.0f, 0.0f, 0.0f, 1.0f) | ||
|
||
assertActivationFunction(SoftShrinkActivation(lower = -1.0f, upper = 1.0f), input, actual, expected) | ||
} | ||
} |