func (network Network) Run(input []float32) []float32 {
	if len(network.neuronLayers) < 3 {
		panic("Neural Network was configured incorrectly. It has less than required input, one hidden and output layer.")
	}
	if len(network.neuronLayers[0]) != len(input) {
		panic("input doesn't match first layeur of Neural Network")
	}

	// insert input values on the first layer
	for neuronIndex := 0; neuronIndex < len(network.neuronLayers[0]); neuronIndex++ {
		network.neuronLayers[0][neuronIndex].value = input[neuronIndex]
	}

	// run the network
	for layerIndex := 1; layerIndex < len(network.neuronLayers); layerIndex++ {
		for neuronInCurrentLayerIndex := 0; neuronInCurrentLayerIndex < len(network.neuronLayers[layerIndex]); neuronInCurrentLayerIndex++ {
			var value float32
			for neuronInPreviousLayerIndex := 0; neuronInPreviousLayerIndex < len(network.neuronLayers[layerIndex-1]); neuronInPreviousLayerIndex++ {
				value += network.neuronLayers[layerIndex][neuronInCurrentLayerIndex].weights[neuronInPreviousLayerIndex] * network.neuronLayers[layerIndex-1][neuronInPreviousLayerIndex].value
			}
			network.neuronLayers[layerIndex][neuronInCurrentLayerIndex].value = float32(math.Tanh(float64(value)))
		}
	}

	// return last leyers values as output
	outputLength := len(network.neuronLayers[len(network.neuronLayers)-1])
	output := make([]float32, outputLength)
	for neuronIndex := 0; neuronIndex < outputLength; neuronIndex++ {
		output[neuronIndex] = network.neuronLayers[len(network.neuronLayers)-1][neuronIndex].value
	}
	return output
}
// Run method takes input values, inserts them to the first layer of
// Neural Network and runs the network using weights to previous layers'
// neurons and Tanh as activator function. Return last layer as output.
Run method takes input values, inserts them to the first layer of
Neural Network and runs the network using weights to previous layers'
neurons and Tanh as activator function. Return last layer as output.
// Run method takes input values inserts them to the first layer of // Neural Network and runs the network using weights to previous layers ' // neurons and Tanh as activator function . Return last layer as output .
func (network Network) Run(input []float32) []float32 {
	if len(network.neuronLayers) < 3 {
		panic("Neural Network was configured incorrectly. It has less than required input, one hidden and output layer.")
	}
	if len(network.neuronLayers[0]) != len(input) {
		panic("input doesn't match first layeur of Neural Network")
	}
	for neuronIndex := 0; neuronIndex < len(network.neuronLayers[0]); neuronIndex++ {
		network.neuronLayers[0][neuronIndex].value = input[neuronIndex]
	}
	for layerIndex := 1; layerIndex < len(network.neuronLayers); layerIndex++ {
		for neuronInCurrentLayerIndex := 0; neuronInCurrentLayerIndex < len(network.neuronLayers[layerIndex]); neuronInCurrentLayerIndex++ {
			var value float32
			for neuronInPreviousLayerIndex := 0; neuronInPreviousLayerIndex < len(network.neuronLayers[layerIndex-1]); neuronInPreviousLayerIndex++ {
				value += network.neuronLayers[layerIndex][neuronInCurrentLayerIndex].weights[neuronInPreviousLayerIndex] * network.neuronLayers[layerIndex-1][neuronInPreviousLayerIndex].value
			}
			network.neuronLayers[layerIndex][neuronInCurrentLayerIndex].value = float32(math.Tanh(float64(value)))
		}
	}
	outputLength := len(network.neuronLayers[len(network.neuronLayers)-1])
	output := make([]float32, outputLength)
	for neuronIndex := 0; neuronIndex < outputLength; neuronIndex++ {
		output[neuronIndex] = network.neuronLayers[len(network.neuronLayers)-1][neuronIndex].value
	}
	return output
}
func ( network Network ) Run ( input [ ] float32 ) [ ] float32 { if len ( network . neuronLayers ) < 3 { panic ( " " ) } if len ( network . neuronLayers [ 0 ] ) != len ( input ) { panic ( " " ) } for neuronIndex := 0 ; neuronIndex < len ( network . neuronLayers [ 0 ] ) ; neuronIndex ++ { network . neuronLayers [ 0 ] [ neuronIndex ] . value = input [ neuronIndex ] } for layerIndex := 1 ; layerIndex < len ( network . neuronLayers ) ; layerIndex ++ { for neuronInCurrentLayerIndex := 0 ; neuronInCurrentLayerIndex < len ( network . neuronLayers [ layerIndex ] ) ; neuronInCurrentLayerIndex ++ { var value float32 for neuronInPreviousLayerIndex := 0 ; neuronInPreviousLayerIndex < len ( network . neuronLayers [ layerIndex - 1 ] ) ; neuronInPreviousLayerIndex ++ { value += network . neuronLayers [ layerIndex ] [ neuronInCurrentLayerIndex ] . weights [ neuronInPreviousLayerIndex ] * network . neuronLayers [ layerIndex - 1 ] [ neuronInPreviousLayerIndex ] . value } network . neuronLayers [ layerIndex ] [ neuronInCurrentLayerIndex ] . value = float32 ( math . Tanh ( float64 ( value ) ) ) } } outputLength := len ( network . neuronLayers [ len ( network . neuronLayers ) - 1 ] ) output := make ( [ ] float32 , outputLength ) for neuronIndex := 0 ; neuronIndex < outputLength ; neuronIndex ++ { output [ neuronIndex ] = network . neuronLayers [ len ( network . neuronLayers ) - 1 ] [ neuronIndex ] . value } return output }
Run method takes input values, inserts them to the first layer of
Neural Network and runs the network using weights to previous layers'
neurons and Tanh as activator function.
Run method takes input values inserts them to the first layer of Neural Network and runs the network using weights to previous layers ' neurons and Tanh as activator function .
// insert input values on the first layer // run the network // return last leyers values as output