gpssm_hodgkin_huxley.py 文件源码

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

项目:geepee 作者: thangbui 项目源码 文件源码
def plot_model_no_control(model, plot_title='', name_suffix=''):
    # plot function
    mx, vx = model.get_posterior_x()
    mins = np.min(mx, axis=0) - 0.5
    maxs = np.max(mx, axis=0) + 0.5
    nGrid = 50
    xspaced = np.linspace(mins[0], maxs[0], nGrid)
    yspaced = np.linspace(mins[1], maxs[1], nGrid)
    xx, yy = np.meshgrid(xspaced, yspaced)
    Xplot = np.vstack((xx.flatten(), yy.flatten())).T
    mf, vf = model.predict_f(Xplot)
    fig = plt.figure()
    plt.imshow((mf[:, 0]).reshape(*xx.shape),
               vmin=mf.min(), vmax=mf.max(), origin='lower',
               extent=[mins[0], maxs[0], mins[1], maxs[1]], aspect='auto')
    plt.colorbar()
    plt.contour(
        xx, yy, (mf[:, 0]).reshape(*xx.shape),
        colors='k', linewidths=2, zorder=100)
    zu = model.dyn_layer.zu
    plt.plot(zu[:, 0], zu[:, 1], 'wo', mew=0, ms=4)
    for i in range(mx.shape[0] - 1):
        plt.plot(mx[i:i + 2, 0], mx[i:i + 2, 1],
                 '-bo', ms=3, linewidth=2, zorder=101)
    plt.xlabel(r'$x_{t, 1}$')
    plt.ylabel(r'$x_{t, 2}$')
    plt.xlim([mins[0], maxs[0]])
    plt.ylim([mins[1], maxs[1]])
    plt.title(plot_title)
    plt.savefig('/tmp/hh_gpssm_dim_0' + name_suffix + '.pdf')

    fig = plt.figure()
    plt.imshow((mf[:, 1]).reshape(*xx.shape),
               vmin=mf.min(), vmax=mf.max(), origin='lower',
               extent=[mins[0], maxs[0], mins[1], maxs[1]], aspect='auto')
    plt.colorbar()
    plt.contour(
        xx, yy, (mf[:, 1]).reshape(*xx.shape),
        colors='k', linewidths=2, zorder=100)
    zu = model.dyn_layer.zu
    plt.plot(zu[:, 0], zu[:, 1], 'wo', mew=0, ms=4)
    for i in range(mx.shape[0] - 1):
        plt.plot(mx[i:i + 2, 0], mx[i:i + 2, 1],
                 '-bo', ms=3, linewidth=2, zorder=101)
    plt.xlabel(r'$x_{t, 1}$')
    plt.ylabel(r'$x_{t, 2}$')
    plt.xlim([mins[0], maxs[0]])
    plt.ylim([mins[1], maxs[1]])
    plt.title(plot_title)
    plt.savefig('/tmp/hh_gpssm_dim_1' + name_suffix + '.pdf')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号