Forráskód Böngészése

Make batch workers explicitly private

Alexey Edelev 5 éve
szülő
commit
34302cc0bb

+ 2 - 2
neuralnetwork/neuralnetwork/batchworker.go

@@ -51,7 +51,7 @@ func newBatchWorker(nn *NeuralNetwork) (bw *batchWorker) {
 	return
 }
 
-func (bw *batchWorker) Run(trainer training.Trainer, startIndex, endIndex int) {
+func (bw *batchWorker) run(trainer training.Trainer, startIndex, endIndex int) {
 	for i := startIndex; i < endIndex; i++ {
 		dB, dW := bw.network.backward(trainer.GetDataByIndex(i))
 		for l := 1; l < bw.network.LayerCount; l++ {
@@ -62,6 +62,6 @@ func (bw *batchWorker) Run(trainer training.Trainer, startIndex, endIndex int) {
 	trainer.Reset()
 }
 
-func (bw *batchWorker) Result(layer int) (dB, dW *mat.Dense) {
+func (bw *batchWorker) result(layer int) (dB, dW *mat.Dense) {
 	return bw.BGradient[layer].Gradients(), bw.WGradient[layer].Gradients()
 }

+ 2 - 2
neuralnetwork/neuralnetwork/neuralnetwork.go

@@ -340,7 +340,7 @@ func (nn *NeuralNetwork) trainBatch(trainer training.Trainer, epocs int) {
 				panic("wGradient is not a BatchGradientDescent")
 			}
 			for _, bw := range batchWorkers {
-				dB, dW := bw.Result(l)
+				dB, dW := bw.result(l)
 				bGradient.AccumGradients(dB)
 				wGradient.AccumGradients(dW)
 			}
@@ -366,7 +366,7 @@ func (nn *NeuralNetwork) runBatchWorkers(threadCount int, trainer training.Train
 		wg.Add(1)
 		s := i
 		go func() {
-			workers[s].Run(trainer, s*chunkSize, (s+1)*chunkSize)
+			workers[s].run(trainer, s*chunkSize, (s+1)*chunkSize)
 			wg.Done()
 		}()
 	}