Quantcast
Channel: Latest Questions by f_rodrigues
Viewing all articles
Browse latest Browse all 18

Matrix Multiplication, Standard Deviant and More usefull methods

$
0
0
I'm trying to create a Artificial Neural Network to make a evolving AI for a simple game. But I'm struggling with the math required by it. I made a neural net in Python, in around 100 lines, but when I tried to port it to c# I'm already at 200 lines of code, and I haven't even begin the back propagation algorithm (the bulk of the code in python). For instance a simple input normalization in python takes 1 line: self.input_values = (inputs - np.mean(inputs , axis=0)) / np.std(inputs , axis=0) While in C# I've to do it step by step: float[] normalize_input(float[] inputs){ float sum = 0.0f; for (int i = 0; i < inputs.Length; i++) { sum += inputs[i] ; } float average = sum / inputs.Length; float[] deviations = new float[inputs.Length]; for (int i = 0; i < inputs.Length; i++) { deviations[i] = Mathf.Pow(inputs[i] - average,2); } float sum_deviation = 0; for (int i = 0; i < deviations.Length; i++) { sum_deviation += deviations[i]; } float variance = sum_deviation / deviations.Length; float std = Mathf.Sqrt (variance); for (int i = 0; i < inputs.Length; i++) { inputs[i] = (inputs[i] - average)/std; } return inputs; } **Is there any way to have access to this sort of math functions and matrix computation?** I know I can do it step by step like I'm doing, but it will take a lot longer, and further more, it's very hard to debug once something is off.

Viewing all articles
Browse latest Browse all 18

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>