test_embedding.py 文件源码

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

项目:sdp_kmeans 作者: simonsfoundation 项目源码 文件源码
def test_square_grid():
    X = np.mgrid[0:16, 0:16]
    X = X.reshape((len(X), -1)).T

    name = 'square'
    D, Q = test_toy_embedding(X, 32, 2, name, palette='hls')

    def plot_mat_on_data(mat, sample):
        plt.figure()
        plot_data_embedded(X, palette='w')
        alpha = np.maximum(mat[sample], 0) / mat[sample].max()
        plot_data_embedded(X, palette='#FF0000', alpha=alpha)

    pdf_file_name = '{}{}_plot_{}_on_data_{}{}'

    plot_mat_on_data(D, 7 * 16 + 7)
    plt.savefig(pdf_file_name.format(dir_name, name, 'D', 'middle', '.pdf'))
    plot_mat_on_data(Q, 7 * 16 + 7)
    plt.savefig(pdf_file_name.format(dir_name, name, 'Q', 'middle', '.pdf'))

    # for s in range(len(X)):
    #     plot_mat_on_data(Q, s)
    #     plt.savefig(pdf_file_name.format(dir_name, name, 'Q', s, '.png'))
    #     plt.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号