Beispiel #1
0
bool NeuralNetwork::AreNeuronsConnected(const Neuron& lhs,const Neuron & rhs) const {
	for (auto& connection : rhs.GetConnections()) {
		if (!connection.outGoing && &lhs == connection.neuron) {
			return true;
		}
	}
	return false;
}
Beispiel #2
0
void NeuralNetwork::CategorizeNeuronBranchIntoLayers(Neuron& currNode) {
	for (auto &in : currNode.GetConnections()) {
		if (!in.isRecursive) {
			CategorizeNeuronBranchIntoLayers(*in.neuron);
			currNode.SetLayer(in.neuron->GetLayer() + 1);
		}
	}
}
Beispiel #3
0
void NeuralNetwork::CategorizeNeuronBranchIntoLayers(Neuron& currNode, size_t currentDepth) {
	currNode.layer = currentDepth;
	const size_t nextLayer = currNode.layer + 1;


	auto HasYetToBeLayered = [&nextLayer](const Neuron::Connection& c) {
		return nextLayer > c.neuron->layer;
	};
	auto IsInHigherLayer = [](const Neuron::Connection& c) {
		return (c.outGoing != c.isRecursive);
	};

	for (auto &c : currNode.GetConnections()) {
		if (HasYetToBeLayered(c) && IsInHigherLayer(c)) {
			CategorizeNeuronBranchIntoLayers(*c.neuron, nextLayer);
		}
	}
}