netGradientCheck ================================ .. js:function:: NeuralNetwork.netGradientCheck(batch_Y, exp_work, costs) 勾配の計算のチェック :param float[] batch_Y: 正解の出力 :param float[] exp_work: 作業用データ :param float[] costs: ミニバッチ内のコストの配列 ソース ^^^^^^ .. code-block:: js netGradientCheck(batch_Y, exp_work, costs){ inGradientCheck = true; var last_layer = this.layers[this.layers.length - 1]; var last_delta_y = new Float32Array(last_layer.deltaY.dt); for (var batch_idx = 0; batch_idx < miniBatchSize; batch_idx++){ last_layer.deltaY.dt = new Float32Array(last_delta_y.length); for(var i = 0; i < last_layer.unitSize; i++){ var k = batch_idx * last_layer.unitSize + i; last_layer.deltaY.dt[k] = last_delta_y[k]; } for (var i = this.layers.length - 1; 1 <= i; i--) { this.layers[i].backpropagation(); } for(var layer_idx = 0; layer_idx < this.layers.length; layer_idx++){ console.log("勾配確認 %s", this.layers[layer_idx].constructor.name); this.layers[layer_idx].gradientCheck(batch_Y, exp_work, costs[batch_idx], batch_idx, layer_idx); } } inGradientCheck = false; }