-
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.
- Loading branch information
1 parent
a17dd02
commit fce98a3
Showing
3 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
core/src/main/java/com/jonahshader/systems/neuralnet/Layer.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,13 @@ | ||
package com.jonahshader.systems.neuralnet | ||
|
||
import org.jetbrains.kotlinx.multik.ndarray.data.D1 | ||
import org.jetbrains.kotlinx.multik.ndarray.data.NDArray | ||
|
||
interface Layer { | ||
fun update(input: NDArray<Float, D1>, dt: Float) : NDArray<Float, D1> | ||
fun mutateParameters(amount: Float) | ||
fun getParameters() : NDArray<Float, D1> | ||
fun setParameters(params: NDArray<Float, D1>) | ||
fun clone() : Layer | ||
fun reset() | ||
} |
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
40 changes: 40 additions & 0 deletions
40
core/src/main/java/com/jonahshader/systems/neuralnet/washboard/WashboardLayer.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,40 @@ | ||
package com.jonahshader.systems.neuralnet.washboard | ||
|
||
import com.jonahshader.systems.neuralnet.Layer | ||
import com.jonahshader.systems.utils.Rand | ||
import org.jetbrains.kotlinx.multik.api.* | ||
import org.jetbrains.kotlinx.multik.ndarray.data.D1 | ||
import org.jetbrains.kotlinx.multik.ndarray.data.D2 | ||
import org.jetbrains.kotlinx.multik.ndarray.data.NDArray | ||
|
||
class WashboardLayer(inputSize: Int, outputSize: Int) : Layer { | ||
private var weights: NDArray<Float, D2> | ||
private var output: NDArray<Float, D1> = mk.zeros(outputSize) | ||
private var theta = mk.d1array(outputSize) { 0f } | ||
init { | ||
weights = mk.d2array(outputSize, inputSize) { Rand.randx.nextFloat() * 40f } | ||
} | ||
override fun update(input: NDArray<Float, D1>, dt: Float): NDArray<Float, D1> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun mutateParameters(amount: Float) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getParameters(): NDArray<Float, D1> { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun setParameters(params: NDArray<Float, D1>) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun clone(): Layer { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun reset() { | ||
TODO("Not yet implemented") | ||
} | ||
} |