コード例 #1
0
ファイル: Network.cpp プロジェクト: danpritch/NeuralNetwork
//Added this
void hiddenLayer::calculate(inputLayer iL, weights wil)
{
	for(int j=0; j < numHidden; j++)
	{
		//clear value
		setNeuron(j, 0);
		
		//get weighted sum of pattern and bias neuron
		for( int i=0; i <= iL.getInputs(); i++ )
		{
			setNeuron(j, (getNeuron(j) + (iL.getNeuron(i) * wil.getWeight(i,j))));
		}
		
		//set to result of sigmoid
		setNeuron(j, activationFunction(getNeuron(j)));
	}
}
コード例 #2
0
ファイル: Network.cpp プロジェクト: danpritch/NeuralNetwork
//Added this
void outputLayer::calculate(hiddenLayer hL, weights who)
{
	for(int k=0; k < numOutput; k++)
	{
		//clear value
		setNeuron(k, 0);
		
		//get weighted sum of pattern and bias neuron
		for( int j=0; j <= hL.getNumHidden(); j++ ) 
		{
			setNeuron(k, (getNeuron(k) + (hL.getNeuron(j) * who.getWeight(j,k))));
		}
		
		//set to result of sigmoid
		setNeuron(k, activationFunction(getNeuron(k)));
	}
}
コード例 #3
0
ファイル: Layer.cpp プロジェクト: w-martin/nn-simulator
Input const Layer::processInput(Input const &input) const {
    Input output(size);
    for (int i = 0; i < size; i++) {
        Output result = getNeuron(i)->processInput(input);
        output.setValue(i, result.getValue());
    }
    return output;
}
コード例 #4
0
ファイル: net.cpp プロジェクト: episkipoe/Agents
void Net::load(ifstream & loadStream) {
	clear();

	name = loadString(loadStream);
	loadStream.read((char*)&data, sizeof(NetData));

	//load private data
	loadStream.read((char*)(&neuronIndex), sizeof(int));
	loadStream.read((char*)(&synapseIndex), sizeof(int));

	//load neurons
	int count;
	loadStream.read((char*)(&count), sizeof(int));
	while(count>0){
		Neuron * newNode = new Neuron;
		newNode->load(loadStream);
		neuron.push_back(newNode);
		count--;
	}

	//load synapses
	loadStream.read((char*)(&count), sizeof(int));
	while(count>0){
		Synapse newSynapse;
		loadStream.read((char*)(&newSynapse.index), sizeof(int));
		loadStream.read((char*)(&newSynapse.weight), sizeof(float));
		loadStream.read((char*)(&newSynapse.potentiation), sizeof(float));
		loadStream.read((char*)(&newSynapse.fire_frequency), sizeof(char));
		loadStream.read((char*)(&newSynapse.fire_timer), sizeof(char));

		int idx;
		loadStream.read((char*)(&idx), sizeof(int));
		newSynapse.from = getNeuron(idx);
		loadStream.read((char*)(&idx), sizeof(int));
		newSynapse.to = getNeuron(idx);

		//cout<<"loading synapse #"<<newSynapse.index<<endl;
		synapse.push_back(newSynapse);
		count--;
	}

}
コード例 #5
0
QVariant ZFlyEmNeuronListModel::data(const QModelIndex &index, int role) const
{
  if (!index.isValid()) {
    return QVariant();
  }

  if (index.row() >= m_neuronList.size() || index.row() < 0) {
    return QVariant();
  }

  const ZFlyEmNeuron *neuron = getNeuron(index.row());
  if (neuron != NULL) {
    return m_presenter->data(*neuron, index.column(), role);
  }

/*
  if (role == Qt::DisplayRole) {
    const ZFlyEmNeuron *neuron = getNeuron(index);
    switch (index.column()) {
    case 0:
    {
      QString data = QString("%1").arg(neuron->getId());

      return data;
    }
    case 1:
      return neuron->getName().c_str();
    case 2:
      return neuron->getClass().c_str();
    case 3:
      if (neuron->getMatched() == NULL) {
        return "";
      } else {
        return QString(":") + neuron->getMatched()->getClass().c_str() +
            QString(" (%1)").arg(neuron->getMatched()->getId());
      }
    case 4:
      return neuron->getModelPath().c_str();
    default:
      return QVariant();
    }
  } else if (role == Qt::ToolTipRole) {
    const ZFlyEmNeuron *neuron = getNeuron(index);
    if (neuron != NULL) {
      QString data = QString("%1").arg(neuron->getId()) +
          " (" + neuron->getModelPath().c_str() + ")";
      return data;
    }
  }
  */

  return QVariant();
}
コード例 #6
0
const ZFlyEmNeuron* ZFlyEmNeuronListModel::getNeuron(
    const QModelIndex &index) const
{
  return getNeuron(index.row(), index.column());
}