models_actinf.py 文件源码

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

项目:smp_base 作者: x75 项目源码 文件源码
def plot_hebbsom_links_distances_activations(X, Y, mdl, predictions, distances, activities, saveplot = False):
    """plot the hebbian link matrix, and all node distances and activities for all inputs"""


    hebblink_log = np.log(mdl.hebblink_filter.T + 1.0)

    fig = pl.figure()
    fig.suptitle("Debugging SOM: hebbian links, distances, activities (%s)" % (mdl.__class__.__name__))
    gs = gridspec.GridSpec(4, 1)
    # pl.plot(X, Y, "k.", alpha=0.5)
    # pl.subplot(numplots, 1, numplots-1)
    ax1 = fig.add_subplot(gs[0])
    ax1.set_title('hebbian associative links')
    # im1 = ax1.imshow(mdl.hebblink_filter, interpolation="none", cmap=pl.get_cmap("gray"))
    im1 = ax1.pcolormesh(hebblink_log, cmap=pl.get_cmap("gray"))
    ax1.set_xlabel("in (e)")
    ax1.set_ylabel("out (p)")
    cbar = fig.colorbar(mappable = im1, ax=ax1, orientation="horizontal")

    ax2 = fig.add_subplot(gs[1])
    ax2.set_title('distances over time')

    distarray = np.array(distances)
    # print("distarray.shape", distarray.shape)
    pcm = ax2.pcolormesh(distarray.T)
    cbar = fig.colorbar(mappable = pcm, ax=ax2, orientation="horizontal")

    # pl.subplot(numplots, 1, numplots)
    ax3 = fig.add_subplot(gs[2])
    ax3.set_title('activations propagated via hebbian links')
    actarray = np.array(activities)
    # print("actarray.shape", actarray.shape)
    pcm = ax3.pcolormesh(actarray.T)
    cbar = fig.colorbar(mappable = pcm, ax=ax3, orientation="horizontal")

    ax4 = fig.add_subplot(gs[3])
    ax4.set_title('flattened link table')
    ax4.plot(hebblink_log.flatten())

    # print("hebblink_log", hebblink_log)

    if saveplot:
        filename = "plot_hebbsom_links_distances_activations_%s.jpg" % (mdl.__class__.__name__,)
        savefig(fig, filename)
    fig.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号