Skip to content

Commit a75c68e

Browse files
1.20版本发布 (#8)
* 文档更新 * 更新其中的1.17版本官方文档 * 开始新版本1.18的开发 开始开发任务 * update * 新增矩阵 AGG 函数的逻辑实现 * update * 新增边框对象 * update * update * 完善模板匹配函数的实现,增加步长,提升效率。 * update * update * 矩阵开始被归一化计算组件支持 * Update Case.md * update * 针对图像矩阵进行了合并功能的更新 * 针对IO数据流进行了优化。 * update * 为AS库添加第三方数据源支持,并允许通过摄像头获取到图像数据 * update * update * update * 更新HDFS数据IO组件 * update * 1.18版本发布 * 1.18版本发布,新版本已发布至maven * update log * 更新日志中英文文档链接 * update * 格式化文档 * Update Case.md * Update Case.md * Create sourceMaterial.md * update * 更新1.18版本的文档 * 更新主页文档 * 1.18-1.19版本开发开始 * update * 新增 单例数据DF对象,其在存在大量重复数据的场景下,内存将节省很多倍。 * update * update * update * update * 支持目标外绝矩形,图像监督分类两种模型的计算。 * Update sourceMaterial.md * Update sourceMaterial.md * Update sourceMaterial.md * update * update * 更新数学模型类 * 新增线性神经网络训练模型 * 数据输入设备对象升级 * Input HDFS 支持针对矩阵的输入操作 * 线性神经网络支持进行训练时的附加Task。 * update * update * 1.19版本上传至maven * 更新1.19版本代码,准备合并分支 * update * Update sourceMaterial.md * update * 更新了单层卷积神经网络模型 * update * update * Update sourceMaterial.md * update * Update sourceMaterial.md * Update sourceMaterial.md * Update sourceMaterial.md * Update sourceMaterial.md * Update sourceMaterial.md * Update ASMath.java * update * 更新本地文件数据集加载器 * Update Share.java * update * 为所有的操作数对象添加不同维度形状的数据类型计算操作,例如其支持矩阵与向量或单个数值之间的计算操作。 * 为所有的操作数对象都提供了父类到子类的转换实现。 * 拓展灵活性 * 矩阵与矩阵空间操作数对象支持维度重设操作。 * 针对图像矩阵对象,新增了均值池化操作 * 图像矩阵新增均值池化与分通道均值池化的常量处理模块。 * 准备更新1.20版本 * 更新文档 * 矩阵灵活性提升,单例池灵活性提升 * 支持 fill 一个数值类型的矩阵对象 * 支持 clear 单例单元格数据存储池 * update * 1.20版本发布 * 新版本更新 * 更新新版本文档
1 parent b1e1daa commit a75c68e

File tree

79 files changed

+7572
-2005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+7572
-2005
lines changed

AsLib/libBeardedManZhao.dll

0 Bytes
Binary file not shown.

README-Chinese.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ AS库目录有多个版本,如果希望查询不同版本的更新日志以及
2323
<dependency>
2424
<groupId>io.github.BeardedManZhao</groupId>
2525
<artifactId>algorithmStar</artifactId>
26-
<version>1.19</version>
26+
<version>1.20</version>
2727
</dependency>
2828
</dependencies>
2929
```

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ can add it to your maven project, or you can download it from Releases and manua
2929
<dependency>
3030
<groupId>io.github.BeardedManZhao</groupId>
3131
<artifactId>algorithmStar</artifactId>
32-
<version>1.19</version>
32+
<version>1.20</version>
3333
</dependency>
3434
</dependencies>
3535
```

sourceMaterial.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,24 @@
3434
![test4](https://user-images.githubusercontent.com/113756063/229441864-ec1770d5-1154-4e9c-837e-a4acfc5fb259.jpg)
3535
![](https://user-images.githubusercontent.com/113756063/231062465-f8396edb-993d-4c65-a1cc-43ea45c40359.jpg)
3636

37+
![字母样本A](https://user-images.githubusercontent.com/113756063/234247437-32e5b5ff-0baf-4637-805c-27472f07fd17.jpg)
38+
![字母样本B](https://user-images.githubusercontent.com/113756063/235287575-fcd9f3a9-7be7-4528-8190-8c9e54cef7fd.jpg)
39+
![字母样本C](https://user-images.githubusercontent.com/113756063/235287578-29acf0f9-df03-4a62-8455-ed7a56f8f35c.jpg)
40+
![字母样本X](https://user-images.githubusercontent.com/113756063/234247472-1df7f892-89b5-467f-9d8d-eb397b92c6ce.jpg)
41+
![字母样本Y](https://user-images.githubusercontent.com/113756063/234247497-0a329b5d-a15d-451f-abf7-abdc1655b77d.jpg)
42+
![字母样本Z](https://user-images.githubusercontent.com/113756063/235150408-233cc477-c97d-48a1-b39e-ff9a497ea9ff.jpg)
43+
![字母A1](https://user-images.githubusercontent.com/113756063/234247630-46319338-b8e6-47bf-9918-4b734e665cf9.jpg)
44+
![字母B1](https://user-images.githubusercontent.com/113756063/235287584-90f2361b-0292-41cc-9469-6d4a64258c8d.jpg)
45+
![字母C1](https://user-images.githubusercontent.com/113756063/235287616-446108e1-1e1c-4416-991b-3b0cbb888d5b.jpg)
46+
![字母C2](https://user-images.githubusercontent.com/113756063/235335944-9e7b1a84-9b44-40d1-b943-30fc290b11ac.jpg)
47+
![字母X1](https://user-images.githubusercontent.com/113756063/234247550-01777cee-493a-420f-8665-da31e60a1cbe.jpg)
48+
![字母X2](https://user-images.githubusercontent.com/113756063/235150686-c4b84e78-1b24-409d-a26f-6a860ed104d8.jpg)
49+
![字母Y1](https://user-images.githubusercontent.com/113756063/234247607-bfc59b79-bc6a-4ff1-992c-7ab1e9fd0116.jpg)
50+
![字母Y2](https://user-images.githubusercontent.com/113756063/235150464-9d082c41-ae06-4ee7-a680-59e62cd55b10.jpg)
51+
![字母Z1](https://user-images.githubusercontent.com/113756063/235150989-e71036bd-f8bb-43b9-b566-e3131827d7ac.jpg)
52+
![字母2](https://user-images.githubusercontent.com/113756063/235335680-05f44579-9ea6-407b-b301-bf8774a68b2a.jpg)
53+
54+
3755
## 风景类
3856

3957
![7c58100e7b96a7e87bf0e9b135e2e9f](https://user-images.githubusercontent.com/113756063/231062982-0620903f-183d-48fe-ad7b-d295fcbd7b95.jpg)

src_code/Case.md

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ public class MAIN1 {
491491

492492
线性随机神经网络相较于 线性神经网络训练模型 来说具有强大的兼容性和较好的性能,但是其牺牲了些精确度,线性随机神经网络模型的使用以及训练出来的模型从保存如下所示。
493493

494+
- 1.19 版本中的线性神经网络计算实现案例
495+
494496
```java
495497
package zhao.algorithmMagic;
496498

@@ -550,4 +552,90 @@ public class MAIN1 {
550552
ASModel.Utils.write(new File("C:\\Users\\zhao\\Desktop\\fsDownload\\MytModel.as"), model);
551553
}
552554
}
553-
```
555+
```
556+
557+
- 1.20 版本中的图像分类模型训练案例。
558+
559+
```java
560+
package zhao.algorithmMagic;
561+
562+
import zhao.algorithmMagic.core.model.*;
563+
import zhao.algorithmMagic.core.model.dataSet.ASDataSet;
564+
import zhao.algorithmMagic.operands.matrix.ColorMatrix;
565+
import zhao.algorithmMagic.operands.matrix.DoubleMatrix;
566+
import zhao.algorithmMagic.operands.matrix.block.DoubleMatrixSpace;
567+
import zhao.algorithmMagic.operands.matrix.block.IntegerMatrixSpace;
568+
import zhao.algorithmMagic.operands.table.FinalCell;
569+
import zhao.algorithmMagic.operands.vector.DoubleVector;
570+
import zhao.algorithmMagic.utils.ASMath;
571+
import zhao.algorithmMagic.utils.dataContainer.KeyValue;
572+
573+
import java.io.File;
574+
import java.util.Arrays;
575+
576+
public class MAIN1 {
577+
578+
public static void main(String[] args) {
579+
580+
// 指定图尺寸
581+
int w = 91, h = 87;
582+
583+
// 准备 CNN 神经网络模型
584+
SingleLayerCNNModel singleLayerCnnModel = ASModel.SINGLE_LAYER_CNN_MODEL;
585+
// 设置学习率
586+
singleLayerCnnModel.setLearningRate(0.1f);
587+
// 设置训练次数
588+
singleLayerCnnModel.setLearnCount(200);
589+
// 设置激活函数
590+
singleLayerCnnModel.setActivationFunction(ActivationFunction.LEAKY_RE_LU);
591+
// 设置损失函数
592+
singleLayerCnnModel.setLossFunction(LossFunction.MAE);
593+
594+
// 准备卷积核,目标为突出图形轮廓
595+
DoubleMatrix parse = DoubleMatrix.parse(
596+
new double[]{-1, -1, -1},
597+
new double[]{-1, 8, -1},
598+
new double[]{-1, -1, -1}
599+
);
600+
DoubleMatrixSpace core = DoubleMatrixSpace.parse(parse, parse, parse);
601+
// 设置 卷积核
602+
singleLayerCnnModel.setArg(SingleLayerCNNModel.KERNEL, new FinalCell<>(core));
603+
// 设置 附加任务 池化 然后进行二值化操作 TODO 注意 如果需要模型的保存,请使用 Class 的方式进行设置,使用 lambda 将会导致模型无法反序列化
604+
// 如果不需要,此处可以不进行设置
605+
singleLayerCnnModel.setTransformation(
606+
new PoolBinaryTfTask(2, 1, true, 50, 0x011001, 0x010101, ColorMatrix._R_)
607+
);
608+
609+
// 获取到字母数据集
610+
ASDataSet load = ASDataSet.Load.LETTER.load(w, h);
611+
// 将目标数值与权重设置到网络
612+
singleLayerCnnModel.setWeight(load.getY_train(), load.getImageWeight());
613+
614+
// 准备训练时的附加任务 打印信息
615+
SingleLayerCNNModel.TaskConsumer taskConsumer = (loss, g, weight1) -> {
616+
System.out.println("\n损失函数 = " + loss);
617+
System.out.println("梯度数据 = " + Arrays.toString(g));
618+
};
619+
620+
// 训练出结果模型
621+
long start = System.currentTimeMillis();
622+
ClassificationModel<IntegerMatrixSpace> model = singleLayerCnnModel.function(taskConsumer, load.getX_train());
623+
System.out.println("训练模型完成,耗时:" + (System.currentTimeMillis() - start));
624+
// 保存模型
625+
ASModel.Utils.write(new File("C:\\Users\\Liming\\Desktop\\fsDownload\\MytModel.as"), model);
626+
627+
628+
// 提供一个新图 开始进行测试
629+
IntegerMatrixSpace parse1 = IntegerMatrixSpace.parse("C:\\Users\\Liming\\Desktop\\fsDownload\\字母5.jpg", w, h);
630+
// 放到模型中 获取到结果
631+
KeyValue<String[], DoubleVector[]> function = model.function(new IntegerMatrixSpace[]{parse1});
632+
// 提取结果向量
633+
DoubleVector[] value = function.getValue();
634+
// 由于被分类的图像对象只有一个,因此直接查看 0 索引的数据就好 这里是一个向量,其中每一个索引代表对应索引的类别得分值
635+
System.out.println(value[0]);
636+
// 查看向量中不同维度对应的类别
637+
System.out.println(Arrays.toString(function.getKey()));
638+
System.out.println("当前图像类别 = " + function.getKey()[ASMath.findMaxIndex(value[0].toArray())]);
639+
}
640+
}
641+
```

0 commit comments

Comments
 (0)