将默认期望矩阵的间隔变成5

This commit is contained in:
Administrator 2020-03-22 11:53:43 +08:00
parent 83115f3779
commit 79c1efcbb8
3 changed files with 68 additions and 52 deletions

View File

@ -54,11 +54,15 @@ public class TempleConfig {
private boolean isShowLog = false;
private ActiveFunction activeFunction = new Tanh();
private double studyPoint = 0;
private double matrixWidth = 1;//期望矩阵间隔
private double matrixWidth = 5;//期望矩阵间隔
private int rzType = RZ.NOT_RZ;//正则化类型默认不进行正则化
private double lParam = 0;//正则参数
private int hiddenNerveNub = 9;//隐层神经元个数
public void setHiddenNerveNub(int hiddenNerveNub) {//设置隐层宽度
this.hiddenNerveNub = hiddenNerveNub;
}
public void setRzType(int rzType) {//设置正则化函数
this.rzType = rzType;
}

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import org.wlld.MatrixTools.Matrix;
import org.wlld.ModelData;
import org.wlld.config.Classifier;
import org.wlld.config.RZ;
import org.wlld.config.StudyPattern;
import org.wlld.imageRecognition.Operation;
import org.wlld.imageRecognition.Picture;
@ -21,45 +22,60 @@ public class FoodTest {
public static void food() throws Exception {
Picture picture = new Picture();
TempleConfig templeConfig = new TempleConfig(false, true);
TempleConfig templeConfig = new TempleConfig();
templeConfig.setClassifier(Classifier.DNN);
//templeConfig.setMatrixWidth(10);
templeConfig.isShowLog(true);
templeConfig.setRzType(RZ.L2);
//templeConfig.setDeep(1);
//templeConfig.setStudyPoint(0.05);
// templeConfig.setHiddenNerveNub(6);
templeConfig.setlParam(0.015);//0.015
templeConfig.init(StudyPattern.Accuracy_Pattern, true, 640, 640, 4);
// ModelParameter modelParameter2 = JSON.parseObject(ModelData.DATA3, ModelParameter.class);
// templeConfig.insertModel(modelParameter2);
ModelParameter modelParameter2 = JSON.parseObject(ModelData.DATA3, ModelParameter.class);
templeConfig.insertModel(modelParameter2);
Operation operation = new Operation(templeConfig);
// 一阶段
for (int j = 0; j < 1; j++) {
for (int i = 1; i < 1500; i++) {//一阶段
System.out.println("study1===================" + i);
//读取本地URL地址图片,并转化成矩阵
Matrix a = picture.getImageMatrixByLocal("D:\\share\\picture/a" + i + ".jpg");
Matrix b = picture.getImageMatrixByLocal("D:\\share\\picture/b" + i + ".jpg");
Matrix c = picture.getImageMatrixByLocal("D:\\share\\picture/c" + i + ".jpg");
Matrix d = picture.getImageMatrixByLocal("D:\\share\\picture/d" + i + ".jpg");
//将图像矩阵和标注加入进行学习Accuracy_Pattern 模式 进行第二次学习
//第二次学习的时候第三个参数必须是 true
operation.learning(a, 1, false);
operation.learning(b, 2, false);
operation.learning(c, 3, false);
operation.learning(d, 4, false);
}
}
//二阶段
for (int i = 1; i < 1500; i++) {
System.out.println("avg==" + i);
Matrix a = picture.getImageMatrixByLocal("D:\\share\\picture/a" + i + ".jpg");
Matrix b = picture.getImageMatrixByLocal("D:\\share\\picture/b" + i + ".jpg");
Matrix c = picture.getImageMatrixByLocal("D:\\share\\picture/c" + i + ".jpg");
Matrix d = picture.getImageMatrixByLocal("D:\\share\\picture/d" + i + ".jpg");
operation.normalization(a, templeConfig.getConvolutionNerveManager());
operation.normalization(b, templeConfig.getConvolutionNerveManager());
operation.normalization(c, templeConfig.getConvolutionNerveManager());
operation.normalization(d, templeConfig.getConvolutionNerveManager());
}
templeConfig.getNormalization().avg();
for (int j = 0; j < 1; j++) {
// 一阶段
// for (int j = 0; j < 1; j++) {
// for (int i = 1; i < 1500; i++) {//一阶段
// System.out.println("study1===================" + i);
// //读取本地URL地址图片,并转化成矩阵
// Matrix a = picture.getImageMatrixByLocal("D:\\share\\picture/a" + i + ".jpg");
// Matrix b = picture.getImageMatrixByLocal("D:\\share\\picture/b" + i + ".jpg");
// Matrix c = picture.getImageMatrixByLocal("D:\\share\\picture/c" + i + ".jpg");
// Matrix d = picture.getImageMatrixByLocal("D:\\share\\picture/d" + i + ".jpg");
// //将图像矩阵和标注加入进行学习Accuracy_Pattern 模式 进行第二次学习
// //第二次学习的时候第三个参数必须是 true
// operation.learning(a, 1, false);
// operation.learning(b, 2, false);
// operation.learning(c, 3, false);
// operation.learning(d, 4, false);
// }
// }
//
// //二阶段
// for (int i = 1; i < 1500; i++) {
// System.out.println("avg==" + i);
// Matrix a = picture.getImageMatrixByLocal("D:\\share\\picture/a" + i + ".jpg");
// Matrix b = picture.getImageMatrixByLocal("D:\\share\\picture/b" + i + ".jpg");
// Matrix c = picture.getImageMatrixByLocal("D:\\share\\picture/c" + i + ".jpg");
// Matrix d = picture.getImageMatrixByLocal("D:\\share\\picture/d" + i + ".jpg");
// operation.normalization(a, templeConfig.getConvolutionNerveManager());
// operation.normalization(b, templeConfig.getConvolutionNerveManager());
// operation.normalization(c, templeConfig.getConvolutionNerveManager());
// operation.normalization(d, templeConfig.getConvolutionNerveManager());
// }
// templeConfig.getNormalization().avg();
// templeConfig.finishStudy();//结束学习
// ModelParameter modelParameter = templeConfig.getModel();
// String model = JSON.toJSONString(modelParameter);
// System.out.println(model);
// System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
for (int j = 0; j < 2; j++) {
for (int i = 1; i < 1500; i++) {
System.out.println("j==" + j + ",study2==================" + i);
//读取本地URL地址图片,并转化成矩阵
@ -77,15 +93,6 @@ public class FoodTest {
}
templeConfig.finishStudy();//结束学习
ModelParameter modelParameter = templeConfig.getModel();
String model = JSON.toJSONString(modelParameter);
System.out.println(model);
// ModelParameter modelParameter2 = JSON.parseObject(model, ModelParameter.class);
// TempleConfig templeConfig2 = new TempleConfig(false);
// templeConfig2.init(StudyPattern.Accuracy_Pattern, true, 1000, 1000, 2);
// templeConfig2.insertModel(modelParameter2);
// Operation operation2 = new Operation(templeConfig2);
int wrong = 0;
int allNub = 0;
for (int i = 1500; i <= 1600; i++) {
@ -124,7 +131,11 @@ public class FoodTest {
}
double wrongPoint = ArithUtil.div(wrong, allNub);
System.out.println("错误率1" + (wrongPoint * 100) + "%");
ModelParameter modelParameter = templeConfig.getModel();
String model = JSON.toJSONString(modelParameter);
System.out.println(model);
}
public static void test1() throws Exception {//覆盖率计算
Picture picture = new Picture();
TempleConfig templeConfig = new TempleConfig(false, true);

File diff suppressed because one or more lines are too long