hooks.py 文件源码

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

项目:jack 作者: uclmr 项目源码 文件源码
def plot(self, ylim=None):
        import matplotlib.patches as mpatches
        import matplotlib.pyplot as plt
        from pylab import subplot
        number_of_subplots=len(self.scores.keys())
        colors = ['blue', 'green', 'orange']
        patches = []
        for plot_idx, metric in enumerate(self.scores):
            for i, set_name in enumerate(self.scores[metric].keys()):
                data = self.scores[metric][set_name][0]
                time = self.scores[metric][set_name][1]
                patches.append(mpatches.Patch(color=colors[i], label='{0} {1}'.format(set_name, metric)))
                ax1 = subplot(number_of_subplots,1,plot_idx+1)
                ax1.plot(time,data, label='{0}'.format(metric), color=colors[i])
                if ylim != None:
                    plt.ylim(ymin=ylim[0])
                    plt.ylim(ymax=ylim[1])
                plt.xlabel('iter')
                plt.ylabel('{0} {1}'.format(set_name, metric))
        ax1.legend(handles=patches)

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


问题


面经


文章

微信
公众号

扫码关注公众号