Skip to content

Commit

Permalink
Add test based on python code.
Browse files Browse the repository at this point in the history
  • Loading branch information
michalharakal committed Nov 30, 2021
1 parent e5b2718 commit c6d3ad5
Showing 1 changed file with 24 additions and 0 deletions.
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)
}
}

0 comments on commit c6d3ad5

Please sign in to comment.