func (manager NetworkManager) SaveToFile(name string) error {
	neuralSerialized := ""

	manager.SortNetworksByFitness()

	network := manager.Networks[0]

	for layer := 0; layer < len(manager.layers); layer++ {
		neuralSerialized += strconv.Itoa(manager.layers[layer])
		if layer < len(manager.layers)-1 {
			neuralSerialized += ","
		}
	}

	neuralSerialized += "|"

	for layerIndex := 0; layerIndex < len(network.neuronLayers); layerIndex++ {
		for neuronIndex := 0; neuronIndex < len(network.neuronLayers[layerIndex]); neuronIndex++ {
			for weightIndex := 0; weightIndex < len(network.neuronLayers[layerIndex][neuronIndex].weights); weightIndex++ {
				neuralSerialized += fmt.Sprintf("%f,", network.neuronLayers[layerIndex][neuronIndex].weights[weightIndex])
			}
		}
	}
	neuralSerialized = neuralSerialized[:len(neuralSerialized)-1]

	err := ioutil.WriteFile(name, []byte(neuralSerialized), 0644)

	return err
}
// SaveToFile sorts neural network by their fitness and saves the top performant
// network to file with a given name, returns an error in case of a save failure
SaveToFile sorts neural network by their fitness and saves the top performant
network to file with a given name, returns an error in case of a save failure
// SaveToFile sorts neural network by their fitness and saves the top performant // network to file with a given name returns an error in case of a save failure
func (manager NetworkManager) SaveToFile(name string) error {
	neuralSerialized := ""
	manager.SortNetworksByFitness()
	network := manager.Networks[0]
	for layer := 0; layer < len(manager.layers); layer++ {
		neuralSerialized += strconv.Itoa(manager.layers[layer])
		if layer < len(manager.layers)-1 {
			neuralSerialized += ","
		}
	}
	neuralSerialized += "|"
	for layerIndex := 0; layerIndex < len(network.neuronLayers); layerIndex++ {
		for neuronIndex := 0; neuronIndex < len(network.neuronLayers[layerIndex]); neuronIndex++ {
			for weightIndex := 0; weightIndex < len(network.neuronLayers[layerIndex][neuronIndex].weights); weightIndex++ {
				neuralSerialized += fmt.Sprintf("%f,", network.neuronLayers[layerIndex][neuronIndex].weights[weightIndex])
			}
		}
	}
	neuralSerialized = neuralSerialized[:len(neuralSerialized)-1]
	err := ioutil.WriteFile(name, []byte(neuralSerialized), 0644)
	return err
}
func ( manager NetworkManager ) SaveToFile ( name string ) error { neuralSerialized := " " manager . SortNetworksByFitness ( ) network := manager . Networks [ 0 ] for layer := 0 ; layer < len ( manager . layers ) ; layer ++ { neuralSerialized += strconv . Itoa ( manager . layers [ layer ] ) if layer < len ( manager . layers ) - 1 { neuralSerialized += " " } } neuralSerialized += " " for layerIndex := 0 ; layerIndex < len ( network . neuronLayers ) ; layerIndex ++ { for neuronIndex := 0 ; neuronIndex < len ( network . neuronLayers [ layerIndex ] ) ; neuronIndex ++ { for weightIndex := 0 ; weightIndex < len ( network . neuronLayers [ layerIndex ] [ neuronIndex ] . weights ) ; weightIndex ++ { neuralSerialized += fmt . Sprintf ( " " , network . neuronLayers [ layerIndex ] [ neuronIndex ] . weights [ weightIndex ] ) } } } neuralSerialized = neuralSerialized [ : len ( neuralSerialized ) - 1 ] err := ioutil . WriteFile ( name , [ ] byte ( neuralSerialized ) , 0644 ) return err }
SaveToFile sorts neural network by their fitness and saves the top performant
network to file with a given name, returns an error in case of a save failure
SaveToFile sorts neural network by their fitness and saves the top performant network to file with a given name returns an error in case of a save failure