Created
June 9, 2019 06:11
-
-
Save shubham0204/7315dd301dd822dfc10086d91cba0ccc to your computer and use it in GitHub Desktop.
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
private fun calculateGradients( inputs : DoubleArray , predY : Double , targetY : Double ) : Array<Any> { | |
val dJ_dPred = meanSquaredErrorDerivative( predY , targetY ) | |
val dPred_dW = inputs | |
val dJ_dW = MathOps.multiplyScalar( dPred_dW , dJ_dPred ) | |
val dJ_dB = dJ_dPred | |
return arrayOf( dJ_dW , dJ_dB ) | |
} | |
private fun meanSquaredErrorDerivative( predY : Double , targetY : Double ) : Double { | |
return 2 * ( predY - targetY ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment