use of org.knime.base.data.neural.HiddenLayer in project knime-core by knime.
the class PMMLNeuralNetworkTranslator method initiateFinalLayer.
/**
* @param nnModel
* the PMML neural network model
*/
private void initiateFinalLayer(final NeuralNetwork nnModel) {
NeuralLayer hiddenLayer = nnModel.getNeuralLayerArray(nnModel.getNeuralLayerArray().length - 1);
m_counter = 0;
m_idPosMap = new HashMap<String, Integer>();
m_curLayer++;
m_curPerceptrons = new Vector<Perceptron>();
for (Neuron neuron : hiddenLayer.getNeuronArray()) {
m_weights = new double[m_predPerceptrons.length];
m_curPercpetronID = neuron.getId();
m_curThreshold = -1 * neuron.getBias();
for (Con con : neuron.getConArray()) {
String fromID = con.getFrom();
double weight = con.getWeight();
int pos = m_predidPosMap.get(fromID);
m_weights[pos] = weight;
}
Perceptron p = new SigmoidPerceptron(m_weights, m_predPerceptrons);
p.setThreshold(m_curThreshold);
m_curPerceptrons.add(p);
m_idPosMap.put(m_curPercpetronID, m_counter);
m_counter++;
}
Perceptron[] curPerceptrons = new Perceptron[m_curPerceptrons.size()];
curPerceptrons = m_curPerceptrons.toArray(curPerceptrons);
m_allLayers.add(m_curLayer, new HiddenLayer(m_predLayer, curPerceptrons));
m_predLayer = m_allLayers.get(m_curLayer);
m_predPerceptrons = curPerceptrons;
m_predidPosMap = new HashMap<String, Integer>(m_idPosMap);
}
use of org.knime.base.data.neural.HiddenLayer in project knime-core by knime.
the class PMMLNeuralNetworkTranslator method initiateFinalLayer.
/**
* @param nnModel
* the PMML neural network model
*/
private void initiateFinalLayer(final NeuralNetwork nnModel) {
NeuralLayer hiddenLayer = nnModel.getNeuralLayerArray(nnModel.getNeuralLayerArray().length - 1);
m_counter = 0;
m_idPosMap = new HashMap<String, Integer>();
m_curLayer++;
m_curPerceptrons = new Vector<Perceptron>();
for (Neuron neuron : hiddenLayer.getNeuronArray()) {
m_weights = new double[m_predPerceptrons.length];
m_curPercpetronID = neuron.getId();
m_curThreshold = -1 * neuron.getBias();
for (Con con : neuron.getConArray()) {
String fromID = con.getFrom();
double weight = con.getWeight();
int pos = m_predidPosMap.get(fromID);
m_weights[pos] = weight;
}
Perceptron p = new SigmoidPerceptron(m_weights, m_predPerceptrons);
p.setThreshold(m_curThreshold);
m_curPerceptrons.add(p);
m_idPosMap.put(m_curPercpetronID, m_counter);
m_counter++;
}
Perceptron[] curPerceptrons = new Perceptron[m_curPerceptrons.size()];
curPerceptrons = m_curPerceptrons.toArray(curPerceptrons);
m_allLayers.add(m_curLayer, new HiddenLayer(m_predLayer, curPerceptrons));
m_predLayer = m_allLayers.get(m_curLayer);
m_predPerceptrons = curPerceptrons;
m_predidPosMap = new HashMap<String, Integer>(m_idPosMap);
}
use of org.knime.base.data.neural.HiddenLayer in project knime-core by knime.
the class PMMLNeuralNetworkTranslator method initiateHiddenLayers.
/**
* @param nnModel the PMML neural network model
*/
private void initiateHiddenLayers(final NeuralNetwork nnModel) {
for (int i = 0; i < nnModel.getNeuralLayerArray().length - 1; i++) {
NeuralLayer hiddenLayer = nnModel.getNeuralLayerArray(i);
m_counter = 0;
m_idPosMap = new HashMap<String, Integer>();
m_curLayer++;
m_curPerceptrons = new Vector<Perceptron>();
for (Neuron neuron : hiddenLayer.getNeuronArray()) {
m_weights = new double[m_predPerceptrons.length];
m_curPercpetronID = neuron.getId();
m_curThreshold = -1 * neuron.getBias();
for (Con con : neuron.getConArray()) {
String fromID = con.getFrom();
double weight = con.getWeight();
int pos = m_predidPosMap.get(fromID);
m_weights[pos] = weight;
}
Perceptron p = new SigmoidPerceptron(m_weights, m_predPerceptrons);
p.setThreshold(m_curThreshold);
m_curPerceptrons.add(p);
m_idPosMap.put(m_curPercpetronID, m_counter);
m_counter++;
}
Perceptron[] curPerceptrons = new Perceptron[m_curPerceptrons.size()];
curPerceptrons = m_curPerceptrons.toArray(curPerceptrons);
m_allLayers.add(m_curLayer, new HiddenLayer(m_predLayer, curPerceptrons));
m_predLayer = m_allLayers.get(m_curLayer);
m_predPerceptrons = curPerceptrons;
m_predidPosMap = new HashMap<String, Integer>(m_idPosMap);
}
}
use of org.knime.base.data.neural.HiddenLayer in project knime-core by knime.
the class PMMLNeuralNetworkTranslator method initiateHiddenLayers.
/**
* @param nnModel the PMML neural network model
*/
private void initiateHiddenLayers(final NeuralNetwork nnModel) {
for (int i = 0; i < nnModel.getNeuralLayerArray().length - 1; i++) {
NeuralLayer hiddenLayer = nnModel.getNeuralLayerArray(i);
m_counter = 0;
m_idPosMap = new HashMap<String, Integer>();
m_curLayer++;
m_curPerceptrons = new Vector<Perceptron>();
for (Neuron neuron : hiddenLayer.getNeuronArray()) {
m_weights = new double[m_predPerceptrons.length];
m_curPercpetronID = neuron.getId();
m_curThreshold = -1 * neuron.getBias();
for (Con con : neuron.getConArray()) {
String fromID = con.getFrom();
double weight = con.getWeight();
int pos = m_predidPosMap.get(fromID);
m_weights[pos] = weight;
}
Perceptron p = new SigmoidPerceptron(m_weights, m_predPerceptrons);
p.setThreshold(m_curThreshold);
m_curPerceptrons.add(p);
m_idPosMap.put(m_curPercpetronID, m_counter);
m_counter++;
}
Perceptron[] curPerceptrons = new Perceptron[m_curPerceptrons.size()];
curPerceptrons = m_curPerceptrons.toArray(curPerceptrons);
m_allLayers.add(m_curLayer, new HiddenLayer(m_predLayer, curPerceptrons));
m_predLayer = m_allLayers.get(m_curLayer);
m_predPerceptrons = curPerceptrons;
m_predidPosMap = new HashMap<String, Integer>(m_idPosMap);
}
}
Aggregations