12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package earlystop
- import (
- "log"
- neuralnetwork "git.semlanik.org/semlanik/NeuralNetwork/neuralnetwork"
- training "git.semlanik.org/semlanik/NeuralNetwork/training"
- )
- type constantRateEarlyStop struct {
- network *neuralnetwork.NeuralNetwork
- trainer training.Trainer
- minFailRate float64
- }
- func NewConstantRateEarlyStop(minFailRate float64, network *neuralnetwork.NeuralNetwork, trainer training.Trainer) (es *constantRateEarlyStop) {
- es = nil
- if network == nil || trainer == nil {
- return
- }
- es = &constantRateEarlyStop{
- network: network,
- trainer: trainer,
- minFailRate: minFailRate,
- }
- return
- }
- func (es *constantRateEarlyStop) Test() bool {
- _, fails, total := es.network.Validate(es.trainer)
- log.Printf("Fail count: %v/%v\n", fails, total)
- failRate := float64(fails) / float64(total)
- return es.minFailRate >= failRate
- }
- func (es *constantRateEarlyStop) Reset() {
- }
|