修改覆盖模式

pull/30/head
thenk008 5 years ago
parent 7ab9886674
commit f389cffe26

@ -106,7 +106,7 @@ public class Convolution extends Frequency {
return features; return features;
} }
public List<double[]> getCenterColor(ThreeChannelMatrix threeChannelMatrix, int poolSize, int sqNub) throws Exception { public List<Double> getCenterColor(ThreeChannelMatrix threeChannelMatrix, int poolSize, int sqNub) throws Exception {
Matrix matrixR = threeChannelMatrix.getMatrixR(); Matrix matrixR = threeChannelMatrix.getMatrixR();
Matrix matrixG = threeChannelMatrix.getMatrixG(); Matrix matrixG = threeChannelMatrix.getMatrixG();
Matrix matrixB = threeChannelMatrix.getMatrixB(); Matrix matrixB = threeChannelMatrix.getMatrixB();
@ -126,12 +126,15 @@ public class Convolution extends Frequency {
meanClustering.start(); meanClustering.start();
List<RGBNorm> rgbNorms = meanClustering.getMatrices(); List<RGBNorm> rgbNorms = meanClustering.getMatrices();
Collections.sort(rgbNorms, rgbSort); Collections.sort(rgbNorms, rgbSort);
List<double[]> feature = new ArrayList<>(); List<Double> features = new ArrayList<>();
for (int i = 0; i < sqNub; i++) { for (int i = 0; i < sqNub; i++) {
feature.add(rgbNorms.get(i).getRgb()); double[] rgb = rgbNorms.get(i).getRgb();
for (int j = 0; j < 3; j++) {
features.add(rgb[j]);
}
} }
//System.out.println("feature==" + feature); //System.out.println("feature==" + feature);
return feature; return features;
} }
private void regression(XYBody xyBody) { private void regression(XYBody xyBody) {

@ -67,38 +67,36 @@ public class Operation {//进行计算
int xSize = maxX - minX; int xSize = maxX - minX;
int ySize = maxY - minY; int ySize = maxY - minY;
ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize); ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize);
List<double[]> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(), List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(),
templeConfig.getFeatureNub()); templeConfig.getFeatureNub());
if (templeConfig.isShowLog()) { if (templeConfig.isShowLog()) {
for (double[] f : feature) { System.out.println(feature);
System.out.println(Arrays.toString(f));
}
} }
System.out.println("====================================="); System.out.println("=====================================");
int classifier = templeConfig.getClassifier(); int classifier = templeConfig.getClassifier();
// switch (classifier) { switch (classifier) {
// case Classifier.DNN: case Classifier.DNN:
// Map<Integer, Double> map = new HashMap<>(); Map<Integer, Double> map = new HashMap<>();
// map.put(tag, 1.0); map.put(tag, 1.0);
// if (templeConfig.getSensoryNerves().size() == templeConfig.getFeatureNub()) { if (templeConfig.getSensoryNerves().size() == templeConfig.getFeatureNub()) {
// intoDnnNetwork(1, feature, templeConfig.getSensoryNerves(), true, map, null); intoDnnNetwork(1, feature, templeConfig.getSensoryNerves(), true, map, null);
// } else { } else {
// throw new Exception("nerves number is not equal featureNub"); throw new Exception("nerves number is not equal featureNub");
// } }
// break; break;
// case Classifier.LVQ: case Classifier.LVQ:
// Matrix vector = MatrixOperation.listToRowVector(feature); Matrix vector = MatrixOperation.listToRowVector(feature);
// lvqStudy(tag, vector); lvqStudy(tag, vector);
// break; break;
// case Classifier.VAvg: case Classifier.VAvg:
// Matrix vec = MatrixOperation.listToRowVector(feature); Matrix vec = MatrixOperation.listToRowVector(feature);
// avgStudy(tag, vec); avgStudy(tag, vec);
// break; break;
// case Classifier.KNN: case Classifier.KNN:
// Matrix veck = MatrixOperation.listToRowVector(feature); Matrix veck = MatrixOperation.listToRowVector(feature);
// knnStudy(tag, veck); knnStudy(tag, veck);
// break; break;
// } }
} }
private void knnStudy(int tagging, Matrix vector) throws Exception { private void knnStudy(int tagging, Matrix vector) throws Exception {
@ -131,37 +129,37 @@ public class Operation {//进行计算
int xSize = maxX - minX; int xSize = maxX - minX;
int ySize = maxY - minY; int ySize = maxY - minY;
ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize); ThreeChannelMatrix threeChannelMatrix1 = convolution.getRegionMatrix(threeChannelMatrix, minX, minY, xSize, ySize);
List<double[]> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(), List<Double> feature = convolution.getCenterColor(threeChannelMatrix1, templeConfig.getPoolSize(),
templeConfig.getFeatureNub()); templeConfig.getFeatureNub());
if (templeConfig.isShowLog()) { if (templeConfig.isShowLog()) {
System.out.println(feature); System.out.println(feature);
} }
// int classifier = templeConfig.getClassifier(); int classifier = templeConfig.getClassifier();
// int id = 0; int id = 0;
// switch (classifier) { switch (classifier) {
// case Classifier.LVQ: case Classifier.LVQ:
// Matrix myMatrix = MatrixOperation.listToRowVector(feature); Matrix myMatrix = MatrixOperation.listToRowVector(feature);
// id = getIdByLVQ(myMatrix); id = getIdByLVQ(myMatrix);
// break; break;
// case Classifier.DNN: case Classifier.DNN:
// if (templeConfig.getSensoryNerves().size() == templeConfig.getFeatureNub()) { if (templeConfig.getSensoryNerves().size() == templeConfig.getFeatureNub()) {
// intoDnnNetwork(IdCreator.get().nextId(), feature, templeConfig.getSensoryNerves(), false, null, maxPoint); intoDnnNetwork(IdCreator.get().nextId(), feature, templeConfig.getSensoryNerves(), false, null, maxPoint);
// id = maxPoint.getId(); id = maxPoint.getId();
// } else { } else {
// throw new Exception("nerves number is not equal featureNub"); throw new Exception("nerves number is not equal featureNub");
// } }
// break; break;
// case Classifier.VAvg: case Classifier.VAvg:
// Matrix myMatrix1 = MatrixOperation.listToRowVector(feature); Matrix myMatrix1 = MatrixOperation.listToRowVector(feature);
// id = getIdByVag(myMatrix1); id = getIdByVag(myMatrix1);
// break; break;
// case Classifier.KNN: case Classifier.KNN:
// Matrix myMatrix2 = MatrixOperation.listToRowVector(feature); Matrix myMatrix2 = MatrixOperation.listToRowVector(feature);
// Knn knn = templeConfig.getKnn(); Knn knn = templeConfig.getKnn();
// id = knn.getType(myMatrix2); id = knn.getType(myMatrix2);
// break; break;
// } }
// regionBody.setType(id); regionBody.setType(id);
//System.out.println("类别" + id); //System.out.println("类别" + id);
} }
return regionList; return regionList;

@ -312,13 +312,13 @@ public class TempleConfig {
case StudyPattern.Cover_Pattern://覆盖学习模式 case StudyPattern.Cover_Pattern://覆盖学习模式
switch (classifier) { switch (classifier) {
case Classifier.DNN: case Classifier.DNN:
initNerveManager(initPower, sensoryNerveNub, deep, studyPoint); initNerveManager(initPower, sensoryNerveNub * 3, deep, studyPoint);
break; break;
case Classifier.LVQ: case Classifier.LVQ:
lvq = new LVQ(classificationNub, lvqNub, studyPoint); lvq = new LVQ(classificationNub, lvqNub, studyPoint);
break; break;
case Classifier.VAvg: case Classifier.VAvg:
vectorK = new VectorK(featureNub); vectorK = new VectorK(featureNub * 3);
break; break;
case Classifier.KNN: case Classifier.KNN:
knn = new Knn(knnNub); knn = new Knn(knnNub);

Loading…
Cancel
Save