mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-26 20:06:28 -08:00
Change AutoBone's decay function to be more standard (#630)
This commit is contained in:
1 parent
ccef1dff6b
commit
a3a331a9a6
2 files changed
+13
-15
No files matched your search
@@ -415,14 +415,8 @@ class AutoBone(server: VRServer) {
|
||||
|
||||
// Epoch loop, each epoch is one full iteration over the full dataset
|
||||
for (epoch in (if (calcInitError) -1 else 0) until config.numEpochs) {
|
||||
val adjustRate = if (epoch >= 0) {
|
||||
(
|
||||
config.initialAdjustRate
|
||||
* FastMath.pow(config.adjustRateMultiplier, epoch.toFloat())
|
||||
)
|
||||
} else {
|
||||
0f
|
||||
}
|
||||
val adjustRate = decayFunc(config.initialAdjustRate, config.adjustRateDecay, epoch)
|
||||
|
||||
var randomFrameIndices: IntArray? = null
|
||||
if (config.randomizeFrameOrder) {
|
||||
randomFrameIndices = IntArray(frameCount)
|
||||
@@ -585,7 +579,7 @@ class AutoBone(server: VRServer) {
|
||||
val adjVal = stepHeightDiff * (length / stepHeight)
|
||||
|
||||
// Scale the length to fit the target height
|
||||
entry.setValue(Math.max(length + adjVal / 2f, 0.01f))
|
||||
entry.setValue((length + adjVal / 2f).coerceAtLeast(0.01f))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -598,7 +592,7 @@ class AutoBone(server: VRServer) {
|
||||
if (epoch <= 0 || epoch >= config.numEpochs - 1 || (epoch + 1) % config.printEveryNumEpochs == 0) {
|
||||
LogManager
|
||||
.info(
|
||||
"[AutoBone] Epoch ${epoch + 1} average error: ${errorStats.mean} (SD ${errorStats.standardDeviation})"
|
||||
"[AutoBone] Epoch: ${epoch + 1}, Mean error: ${errorStats.mean} (SD ${errorStats.standardDeviation}), Adjust rate: $adjustRate"
|
||||
)
|
||||
}
|
||||
applyConfig(legacyConfigs)
|
||||
@@ -607,7 +601,7 @@ class AutoBone(server: VRServer) {
|
||||
val finalHeight = sumSelectConfigs(heightOffsets, offsets)
|
||||
LogManager
|
||||
.info(
|
||||
"[AutoBone] Target height: $targetHeight New height: $finalHeight"
|
||||
"[AutoBone] Target height: $targetHeight, New height: $finalHeight"
|
||||
)
|
||||
return AutoBoneResults(finalHeight, targetHeight, errorStats, legacyConfigs)
|
||||
}
|
||||
@@ -740,7 +734,7 @@ class AutoBone(server: VRServer) {
|
||||
val configValues: EnumMap<SkeletonConfigOffsets, Float>,
|
||||
) {
|
||||
override fun toString(): String {
|
||||
return "Epoch: $epoch, Epoch Error: $epochError"
|
||||
return "Epoch: $epoch, Epoch error: $epochError"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -759,8 +753,12 @@ class AutoBone(server: VRServer) {
|
||||
val loadDir = File("Load AutoBone Recordings")
|
||||
|
||||
// Mean square error function
|
||||
protected fun errorFunc(errorDeriv: Float): Float {
|
||||
private fun errorFunc(errorDeriv: Float): Float {
|
||||
return 0.5f * (errorDeriv * errorDeriv)
|
||||
}
|
||||
|
||||
private fun decayFunc(initialAdjustRate: Float, adjustRateDecay: Float, epoch: Int): Float {
|
||||
return if (epoch >= 0) initialAdjustRate / (1 + (adjustRateDecay * epoch)) else 0.0f
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ class AutoBoneConfig {
|
||||
var maxDataDistance = 1
|
||||
var numEpochs = 100
|
||||
var printEveryNumEpochs = 25
|
||||
var initialAdjustRate = 10f
|
||||
var adjustRateMultiplier = 0.995f
|
||||
var initialAdjustRate = 10.0f
|
||||
var adjustRateDecay = 1.0f
|
||||
var slideErrorFactor = 0.0f
|
||||
var offsetSlideErrorFactor = 2.0f
|
||||
var footHeightOffsetErrorFactor = 0.0f
|
||||
|
||||
Reference in new issue
Block a user