本文整理汇总了C++中NeuralNetwork::getControlInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ NeuralNetwork::getControlInterface方法的具体用法?C++ NeuralNetwork::getControlInterface怎么用?C++ NeuralNetwork::getControlInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeuralNetwork
的用法示例。
在下文中一共展示了NeuralNetwork::getControlInterface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateNetworkConnection
void ActivationFrequencyCalculator::updateNetworkConnection() {
QList<NeuralNetwork*> networks = Neuro::getNeuralNetworkManager()->getNeuralNetworks();
for(QListIterator<NeuralNetwork*> i(networks); i.hasNext();) {
NeuralNetwork *net = i.next();
if(net->getControlInterface() != 0
&& net->getControlInterface()->getName() == mAgentName->get())
{
QList<Neuron*> neurons = net->getNeurons();
for(QListIterator<Neuron*> j(neurons); j.hasNext();) {
Neuron *neuron = j.next();
if(neuron->getId() == mNeuronId->get()) {
if(mObservedNeuron == neuron) {
return;
}
mObservedNeuron = neuron;
mFrequency->set(0);
mLastActivation = neuron->getOutputActivationValue().get();
mStepCounter = 0;
mFoundFirstReference = false;
return;
}
}
}
}
mObservedNeuron = 0;
mFrequency->set(0);
mLastActivation = 0.0;
mStepCounter = 0;
mFoundFirstReference = false;
}
示例2: testDuplicationAndEquals
// Chris
void TestNeuralNetwork::testDuplicationAndEquals() {
TransferFunctionAdapter tfa("TFA", -0.5, 0.5);
ActivationFunctionAdapter afa("AFA");
SynapseFunctionAdapter sfa("SFA");
NeuralNetwork *net = new NeuralNetwork(afa, tfa, sfa);
ControlInterfaceAdapter controlInterface;
net->setControlInterface(&controlInterface);
QVERIFY(net->getControlInterface() == &controlInterface);
Neuron *neuron1 = new Neuron("Neuron1", tfa, afa, 2001);
Neuron *neuron2 = new Neuron("Neuron1", tfa, afa, 2002);
Neuron *neuron3 = new Neuron("Neuron1", tfa, afa, 2003);
neuron1->setProperty(Neuron::NEURON_TYPE_INPUT);
neuron3->setProperty(Neuron::NEURON_TYPE_OUTPUT);
Synapse *synapse1 = Synapse::createSynapse(neuron1, neuron2, 0.5, sfa, 3001);
Synapse *synapse2 = Synapse::createSynapse(neuron2, neuron3, 1.5, sfa, 3002);
Synapse *synapse3 = Synapse::createSynapse(neuron3, synapse1, 0.1, sfa, 3003);
net->addNeuron(neuron1);
net->addNeuron(neuron2);
net->addNeuron(neuron3);
QCOMPARE(net->getNeurons().size(), 3);
QVERIFY(net->getNeurons().contains(neuron1));
QVERIFY(net->getNeurons().contains(neuron2));
QVERIFY(net->getNeurons().contains(neuron3));
QCOMPARE(net->getSynapses().size(), 3);
QVERIFY(net->getSynapses().contains(synapse1));
QVERIFY(net->getSynapses().contains(synapse2));
QVERIFY(net->getSynapses().contains(synapse3));
NeuralNetwork *copy = net->createCopy();
//control interface is NOT copied.
QVERIFY(copy->getControlInterface() == 0);
QCOMPARE(copy->getNeurons().size(), 3);
QVERIFY(!copy->getNeurons().contains(neuron1));
QVERIFY(!copy->getNeurons().contains(neuron2));
QVERIFY(!copy->getNeurons().contains(neuron3));
QCOMPARE(copy->getSynapses().size(), 3);
QVERIFY(!copy->getSynapses().contains(synapse1));
QVERIFY(!copy->getSynapses().contains(synapse2));
QVERIFY(!copy->getSynapses().contains(synapse3));
Neuron *cNeuron1 = NeuralNetwork::selectNeuronById(neuron1->getId(), copy->getNeurons());
Neuron *cNeuron2 = NeuralNetwork::selectNeuronById(neuron2->getId(), copy->getNeurons());
Neuron *cNeuron3 = NeuralNetwork::selectNeuronById(neuron3->getId(), copy->getNeurons());
Synapse *cSynapse1 = NeuralNetwork::selectSynapseById(synapse1->getId(), copy->getSynapses());
Synapse *cSynapse2 = NeuralNetwork::selectSynapseById(synapse2->getId(), copy->getSynapses());
Synapse *cSynapse3 = NeuralNetwork::selectSynapseById(synapse3->getId(), copy->getSynapses());
QVERIFY(cNeuron1 != 0);
QVERIFY(cNeuron2 != 0);
QVERIFY(cNeuron3 != 0);
QVERIFY(cNeuron1->equals(neuron1));
QVERIFY(cNeuron2->equals(neuron2));
QVERIFY(cNeuron3->equals(neuron3));
QCOMPARE(cNeuron1->getId(), (qulonglong) 2001);
QCOMPARE(cNeuron2->getId(), (qulonglong) 2002);
QCOMPARE(cNeuron3->getId(), (qulonglong) 2003);
QVERIFY(net->getInputNeurons().size() == 1);
QVERIFY(copy->getInputNeurons().size() == 1);
QVERIFY(net->getInputNeurons().at(0) == neuron1);
QVERIFY(copy->getInputNeurons().at(0) == cNeuron1);
QVERIFY(net->getOutputNeurons().size() == 1);
QVERIFY(copy->getOutputNeurons().size() == 1);
QVERIFY(net->getOutputNeurons().at(0) == neuron3);
QVERIFY(copy->getOutputNeurons().at(0) == cNeuron3);
QVERIFY(cSynapse1 != 0);
QVERIFY(cSynapse2 != 0);
QVERIFY(cSynapse3 != 0);
QVERIFY(cSynapse1->equals(synapse1));
QVERIFY(cSynapse2->equals(synapse2));
QVERIFY(cSynapse3->equals(synapse3));
QCOMPARE(cSynapse1->getId(), (qulonglong) 3001);
QCOMPARE(cSynapse2->getId(), (qulonglong) 3002);
QCOMPARE(cSynapse3->getId(), (qulonglong) 3003);
QVERIFY(cSynapse1->getSource() == cNeuron1);
QVERIFY(cSynapse2->getSource() == cNeuron2);
QVERIFY(cSynapse3->getSource() == cNeuron3);
QVERIFY(cSynapse1->getTarget() == cNeuron2);
QVERIFY(cSynapse2->getTarget() == cNeuron3);
//.........这里部分代码省略.........