public String getWeightArray() { ArrayList<String> weightArray = new ArrayList<String>(); int lastLayerIndex = -99; for (NodeInner nodeInner : nodeInners) { // skip outputs here and add them later // layer name int layerIndex = nodeInner.getLayerIndex(); if (layerIndex != NNNode.OUTPUT) { if ((lastLayerIndex == -99) || (lastLayerIndex != layerIndex)) { lastLayerIndex = layerIndex; } // input weights double[] weights = nodeInner.getWeights(); NNNode[] inputNodes = nodeInner.getInputNodes(); for (int i = 0; i <= inputNodes.length; i++) { double temp = weights[i]; if (Double.isNaN(temp)) { temp = 0.0; } weightArray.add(String.valueOf(temp)); } } } // add output nodes for (NodeInner nodeInner : nodeInners) { // layer name int layerIndex = nodeInner.getLayerIndex(); if (layerIndex == NNNode.OUTPUT) { // input weights double[] weights = nodeInner.getWeights(); NNNode[] inputNodes = nodeInner.getInputNodes(); for (int i = 0; i <= inputNodes.length; i++) { double temp = weights[i]; if (Double.isNaN(temp)) { temp = 0.0; } weightArray.add(String.valueOf(temp)); } } } return CommonUtility.array2OracleArray(weightArray, CommonUtility.OracleDataType.Float) .toString(); }
private int getWeightCount() { int weightCount = 0; int lastLayerIndex = -99; for (NodeInner nodeInner : nodeInners) { // skip outputs here and add them later // layer name int layerIndex = nodeInner.getLayerIndex(); if (layerIndex != NNNode.OUTPUT) { if ((lastLayerIndex == -99) || (lastLayerIndex != layerIndex)) { lastLayerIndex = layerIndex; } // input weights double[] weights = nodeInner.getWeights(); NNNode[] inputNodes = nodeInner.getInputNodes(); for (int i = 0; i <= inputNodes.length; i++) { double temp = weights[i]; if (Double.isNaN(temp)) { temp = 0.0; } weightCount++; } } } // add output nodes for (NodeInner nodeInner : nodeInners) { // layer name int layerIndex = nodeInner.getLayerIndex(); if (layerIndex == NNNode.OUTPUT) { // input weights double[] weights = nodeInner.getWeights(); NNNode[] inputNodes = nodeInner.getInputNodes(); for (int i = 0; i <= inputNodes.length; i++) { double temp = weights[i]; if (Double.isNaN(temp)) { temp = 0.0; } weightCount++; } } } return weightCount; }