animation.py 文件源码

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

项目:trading-stock-thailand 作者: adminho 项目源码 文件源码
def train(self, training_agent, total_episode, save_movie=False):
        def animate_func(step):     
            #self.step = step       
            if step > total_episode:                 
                print("Finish training ")               
                #plt.close()
            else:
                training_agent(episode=step, visual=self)
                plt.pause(1.001) # makes the UI a little more responsive 

            if not self.ispause:
                return self._update()

        self.am = animation.FuncAnimation(self._fig, animate_func, total_episode, init_func=self._init, interval=16, repeat=False, blit=False)
        if save_movie:
            mywriter = animation.FFMpegWriter(fps=24, codec='libx264', extra_args=['-pix_fmt', 'yuv420p', '-profile:v', 'high', '-tune', 'animation', '-crf', '18'])
            self.am.save("./video.mp4", writer=mywriter)
        else:
            plt.show(block=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号