test.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:attention_ocr 作者: lightcaster 项目源码 文件源码
def plot_alpha(alpha, x, y):

    f, (a0, a1) = plt.subplots(2)
    gs = grd.GridSpec(2,1, wspace=0.01) #, height_ratios=[1, 4])
    a0 = plt.subplot(gs[0])

    a0.matshow(x.T, cmap=plt.cm.Greys_r) #, aspect='auto')

    probs = np.zeros_like(alpha)
    for i in range(len(alpha)):
        probs[i] = np.convolve(
            alpha[i], np.ones((2,))/2., mode='same')

    a1.matshow(alpha, interpolation='none', aspect='auto')
    xticks = np.argmax(probs, axis=1)

    a1.set_xticks(xticks)
    a1.set_xticklabels(y, fontsize=16)
    a1.grid(which='both') 
    plt.subplots_adjust(top=None, bottom=None, wspace=0.05, hspace=0.05)

    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号