Created
June 9, 2019 06:15
-
-
Save shubham0204/627b32ae4425700ec0a488dfaf0c46ce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
private fun optimizeParameters( gradients : ArrayList<Array<Any>> , learningRate : Double ) { | |
val weightGradientsList = ArrayList<DoubleArray>() | |
for( gradient in gradients ) { | |
weightGradientsList.add( gradient[0] as DoubleArray ) | |
} | |
val weightGradients = MathOps.multidimMean( weightGradientsList.toTypedArray() ).toDoubleArray() | |
val biasGradientsList = ArrayList<Double>() | |
for( gradient in gradients ) { | |
biasGradientsList.add( gradient[1] as Double ) | |
} | |
val biasGradients = ( biasGradientsList.toTypedArray() ).average() | |
this.weights = MathOps.subtract( this.weights , MathOps.multiplyScalar( weightGradients , learningRate ) ) | |
this.bias = this.bias - ( biasGradients * learningRate ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment