我是靠谱客的博主 动听山水,这篇文章主要介绍[解决方法] 如何将训练过程保存为视频,现在分享给大家,希望可以做个参考。

如下测试代码可将训练过程保存在视频中:

import gym
from gym import wrappers
 
env=gym.make('CartPole-v0')
env=wrappers.Monitor(env,'/tmp/cartpole-experiment-1')

for _ in range(20):
	observation=env.reset()
	for t in range(100):
		env.render()
		print observation
		action=env.action_space.sample()
		observation,reward,done,info=env.step(action)
		if done:
			print("Episode finished after {} timesteps".format(t+1))
			break

如果保存的视频不能观看,可能是软件问题,可以尝试下述命令:

sudo apt install libdvdnav4 libdvdread4 gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly libdvd-pkg
sudo apt install ubuntu-restricted-extras

若需要保存整个视频,请参考链接中的问题回复

最后

以上就是动听山水最近收集整理的关于[解决方法] 如何将训练过程保存为视频的全部内容,更多相关[解决方法]内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部