この記事は強化学習 Advent Calendar 2021の12/22の記事です。
はじめまして!東京大学の吉田です。
大学では身体を持って自律的に発達する人工知能をつくることに興味があって、それを研究しています。
今回の記事は強化学習というよりは強化学習の環境をmujoco-pyを使って作るときのtipsといった内容です。 すでに強化学習の環境を作ってみたり、mujoco-pyを使ってMujocoをつかった物理シミュレーションをしている・やろうとしている人向けの内容です。
import torch | |
import torchvision | |
import random | |
import matplotlib.pyplot as plt | |
class MNISTHandler: | |
def __init__(self, train=True): | |
""" | |
Initializes the MNIST dataset. |
import matplotlib.pyplot as plt | |
import numpy as np | |
n_bins = 100 | |
def get_dist(center, scale, bins): | |
dist = np.ones(bins) | |
s_list = [15, 10, 5, 2] | |
power_list = [10, 20, 40, 50] |
# from : https://twitter.com/karpathy/status/1610822271157022720?s=20&t=kEsA7YdbLhb7bMqg_PUxww | |
import code; code.interact(local=locals()) | |
# something you want to check... |
class BetaHead(nn.Module): | |
def __init__(self, in_features, action_size): | |
super(BetaHead, self).__init__() | |
self.fcc_c0 = nn.Linear(in_features, action_size) | |
nn.init.orthogonal_(self.fcc_c0.weight, gain=0.01) | |
nn.init.zeros_(self.fcc_c0.bias) | |
self.fcc_c1 = nn.Linear(in_features, action_size) | |
nn.init.orthogonal_(self.fcc_c1.weight, gain=0.01) |
import torchvision.transforms as transforms | |
import matplotlib.pyplot as plt | |
from torch.utils.data import DataLoader | |
from torchvision.datasets import MNIST | |
mnist_data = MNIST('./mnist', train=True, download=True, transform=transforms.ToTensor()) | |
data_loader = DataLoader(mnist_data, batch_size=4, shuffle=False) | |
data_iter = iter(data_loader) |
def deconvsize(w_in, k, stride, pad, output_pad): | |
return (w_in - 1) * stride - 2 * pad + k + output_pad |
# Run by : python get_parser.py --seed 0 --gpu -1 | |
import argparser | |
# argparser | |
parser = argparse.ArgumentParser(description="When RL, something similar like...") | |
parser.add_argument("--seed", help="Seed value. An Int value", type=int, required=True) | |
parser.add_argument("--gpu", help="GPU ID", type=int, default=-1) | |
parser.add_argument("--group", help="Run group, like 'Apr19'", default="test", type=str) |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
class Model(nn.Module): | |
def __init__(self): | |
super(Model, self).__init__() | |
self.conv1 = nn.Conv2d(1, 20, 5) | |
self.conv2 = nn.Conv2d(20, 20, 5) |
import matplotlib.pyplot as plt | |
import numpy as np | |
x = np.linspace(0, 2, 10) | |
y = np.linspace(2, 0, 10) | |
err = 0.1 + np.random.rand(len(x)) * 0.3 | |
angle = np.random.rand(len(x)) * np.pi / 3 | |
plt.figure(figsize=(2, 2), dpi=300) | |
for i in range(len(x)): |
この記事は強化学習 Advent Calendar 2021の12/22の記事です。
はじめまして!東京大学の吉田です。
大学では身体を持って自律的に発達する人工知能をつくることに興味があって、それを研究しています。
今回の記事は強化学習というよりは強化学習の環境をmujoco-pyを使って作るときのtipsといった内容です。 すでに強化学習の環境を作ってみたり、mujoco-pyを使ってMujocoをつかった物理シミュレーションをしている・やろうとしている人向けの内容です。