From f1ca0a9e540b44e1743ce36ab32a0f5a49334e90 Mon Sep 17 00:00:00 2001 From: lluni Date: Wed, 25 May 2022 17:26:55 +0200 Subject: [PATCH] Changed initialization of weights to gaussian distributed values and biases to 1 (this helps (Leaky)ReLu and doesn't seem hurt tanh yet) --- src/main/java/FCLayer.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/FCLayer.java b/src/main/java/FCLayer.java index 038d7a9..8f646a7 100644 --- a/src/main/java/FCLayer.java +++ b/src/main/java/FCLayer.java @@ -14,11 +14,8 @@ public class FCLayer extends Layer { } private void initialize(int inputSize) { - Random random = new Random(); - this.weights = new SimpleMatrix(inputSize, numNeurons, true, - random.doubles((long) inputSize*numNeurons, -1, 1).toArray()); - this.biases = new SimpleMatrix(1, numNeurons, true, - random.doubles(numNeurons, -1, 1).toArray()); + this.weights = Utilities.gaussianMatrix(inputSize, numNeurons, 0, 1, 0.1d); + this.biases = Utilities.ones(1, numNeurons); this.isInitialized = true; }