public List <float[, ]> Delta(float[,] error) { List <float[, ]> deltas = new List <float[, ]>(); float[,] delta = new float[1, shapes[shapesSize - 1]]; //Debug.Log("Error " + error.GetLength(0) + "-" + error.GetLength(1)); //Debug.Log("layers[shapesSize - 1] " + DerivativeActivation(layers[shapesSize - 1]).GetLength(0) + "-" + DerivativeActivation(layers[shapesSize - 1]).GetLength(1)); delta = Multiplication.ElementWise(error, UActivation.OutputDerivativeActivation(layers[shapesSize - 1], "Sigmoid")); deltas.Add(delta); for (int i = shapesSize - 2; i > 0; i--) { //Debug.Log("Deltas " + deltas[deltas.Count - 1].GetLength(0) + "-" + deltas[deltas.Count - 1].GetLength(1)); //Debug.Log("Deltas " + weights[i].GetLength(0) + "-" + weights[i].GetLength(1)); //float[,] tmp = Multiplication.ElementWise(Multiplication.ElementWise(deltas[deltas.Count - 1], weights[i]), DerivativeActivation(layers[i])); //float[,] tmp = weights[i].TransposeRowsAndColumns(); deltas.Add(Multiplication.ElementWise(Multiplication.FalkScheme(deltas[deltas.Count - 1], weights[i], false, true), UActivation.InternalDerivativeActivation(layers[i], "Sigmoid"))); } WriteListArray("Deltas", "deltas", deltas); return(deltas); }
public void PropagateForward(float[,] data) { for (int i = 0; i < layers[0].GetLength(0); i++) { for (int j = 0; j < layers[0].GetLength(1) - 1; j++) { //Debug.Log("layers[0]" + layers[0].GetLength(0) + "-" + layers[0].GetLength(1)); //Debug.Log("i,j" + i + "-" + j); layers[0][i, j] = data[0, j]; } } for (int i = 1; i < shapesSize - 1; i++) { layers[i] = UActivation.InternalActivation(Multiplication.FalkScheme(layers[i - 1], weights[i - 1]), "Sigmoid", false); } //Debug.Log("output " + layers[shapesSize - 2].GetLength(0) +" -- " + layers[shapesSize - 2].GetLength(1)); //Debug.Log("outputscsd " + weights[shapesSize - 2].GetLength(0) + " -- " + weights[shapesSize - 2].GetLength(1)); layers[shapesSize - 1] = UActivation.OutputActivation(Multiplication.FalkScheme(layers[shapesSize - 2], weights[shapesSize - 2]), "Sigmoid", false); //Debug.Log("output" + layers[shapesSize - 1][0,0]); WriteListArray("Layers", "propagate", layers); }