zl程序教程

您现在的位置是:首页 >  其他

当前栏目

DL之HNN:基于HNN(subplot)将凌乱数字矩阵图像(模拟手写数字图片)实现转为最相近的阿拉伯数字

模拟 实现 基于 图片 数字 图像 矩阵 手写
2023-09-14 09:04:47 时间

DL:基于HNN将凌乱数字矩阵图像(模拟手写数字图片)实现转为最相近的阿拉伯数字

 

 

目录

输出结果

代码设计


 

 

 

 

输出结果

 

代码设计

#DL:基于HNN将凌乱数字矩阵图像(模拟手写数字图片)实现转为最相近的阿拉伯数字
import numpy as np
import neurolab as nl
import matplotlib.pyplot as plt

# 012数字形矩阵————————16*8改为6*5
target=np.array([[0, 1, 1, 1, 0,
                 1, 0, 0, 0, 1,
                 1, 0, 0, 0, 1,
                 1, 0, 0, 0, 1,
                 1, 0, 0, 0, 1,
                 0, 1, 1, 1, 0],
                 
                 [0, 1, 1, 0, 0,
                  0, 0, 1, 0, 0,
                  0, 0, 1, 0, 0,
                  0, 0, 1, 0, 0,
                  0, 0, 1, 0, 0,
                  0, 0, 1, 0, 0],
                 
                 [1, 1, 1, 0, 0,
                  0, 0, 0, 1, 0,
                  0, 0, 0, 1, 0,
                  0, 1, 1, 0, 0,
                  1, 0, 0, 0, 0,
                  1, 1, 1, 1, 1]])
test_data0=np.asfarray([0, 0, 1, 1, 0,
                        1, 0, 1, 0, 0,
                        1, 0, 0, 0, 1,
                        1, 0, 1, 0, 0,
                        1, 0, 0, 0, 1,
                        0, 1, 0, 1, 1])
test_data1=np.asfarray([0, 1, 1, 0, 0,
                        0, 0, 0, 0, 0,
                        0, 1, 1, 0, 0,
                        0, 0, 0, 0, 1,
                        1, 0, 1, 0, 0,
                        0, 0, 1, 0, 0])
test_data2=np.asfarray([1, 0, 1, 0, 0,
                        0, 0, 0, 1, 0,
                        1, 0, 0, 1, 0,
                        0, 1, 1, 0, 1,
                        1, 0, 0, 0, 1,
                        1, 0, 0, 1, 0])
……
ax6.imshow(out0,cmap=plt.cm.gray, interpolation='nearest')
ax6.set_title("after HNN")  #DL: Based on HNN, turn to the closest Arabia number 0
ax7.imshow(out1,cmap=plt.cm.gray, interpolation='nearest')
ax7.set_title("after HNN") 
ax8.imshow(out2,cmap=plt.cm.gray, interpolation='nearest')
ax8.set_title("after HNN") 

fig.tight_layout() #轴域的位置自动调整
plt.suptitle("DL: Based on HNN, turn to the closest Arabia number By Jason Niu")  #设置总图标题
plt.show()

 

相关文章推荐

GitHub