Gymnasium 借游戏来学习人工智能

既然有了免费的linux系统+GPU,干脆演示一下使用drive+colab套件来训练模型。

!apt-get install -y build-essential swig

!pip install box2d-py

!pip install gymnasium[all]

!pip install gymnasium[atari] gymnasium[accept-rom-license]

!pip install stable_baselines3

!pip install moviepy

如果你要训练模型,记得选GPU,默认是CPU ,两者的速度完全不可同日而语。

为了保持连接避免断线,请记得在浏览器的console(F12)输入JS代码 - 

function ConnectButton(){
    console.log("Connect pushed"); 
    document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click() 
}
setInterval(ConnectButton,60000);

现在测试一下环境吧 = 

import gymnasium as gym
from gymnasium.wrappers import RecordVideo

env = gym.make("LunarLander-v2",render_mode="rgb_array")
env = RecordVideo(env, './video')
observation, info = env.reset(seed=42)
for _ in range(1000):
   action = env.action_space.sample()  # this is where you would insert your policy
   observation, reward, terminated, truncated, info = env.step(action)
 
   if terminated or truncated:
      observation, info = env.reset()
env.close()

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 06:54:05       99 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 06:54:05       107 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 06:54:05       90 阅读
  4. Python语言-面向对象

    2024-07-10 06:54:05       98 阅读

热门阅读

  1. mysql实战入门-基础篇

    2024-07-10 06:54:05       26 阅读
  2. Linux安装Docker以及Docker Componse

    2024-07-10 06:54:05       35 阅读
  3. 通信技术在反无人机中的作用分析

    2024-07-10 06:54:05       34 阅读
  4. FastGPT源码部署,不使用docker

    2024-07-10 06:54:05       31 阅读
  5. 【ROS2】中级-编写动作服务器和客户端(Python)

    2024-07-10 06:54:05       24 阅读
  6. 等保测评视角下的哈尔滨智慧城市安全框架构建

    2024-07-10 06:54:05       33 阅读
  7. 如何判断服务器是否被攻击

    2024-07-10 06:54:05       25 阅读
  8. Go中gin框架的*gin.Context参数常见实用方法

    2024-07-10 06:54:05       28 阅读
  9. qt writeDatagram 函数详解

    2024-07-10 06:54:05       49 阅读
  10. CSS - 深入理解选择器的使用方式

    2024-07-10 06:54:05       39 阅读
  11. 基于gunicorn+flask+docker模型高并发部署

    2024-07-10 06:54:05       25 阅读