修改覆盖模式

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

@ -106,7 +106,7 @@ public class Convolution extends Frequency {
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 matrixG = threeChannelMatrix.getMatrixG();
Matrix matrixB = threeChannelMatrix.getMatrixB();
@ -126,12 +126,15 @@ public class Convolution extends Frequency {
meanClustering.start();
List<RGBNorm> rgbNorms = meanClustering.getMatrices();
Collections.sort(rgbNorms, rgbSort);
List<double[]> feature = new ArrayList<>();
List<Double> features = new ArrayList<>();
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);
return feature;
return features;
}
private void regression(XYBody xyBody) {

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

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

Loading…
Cancel
Save