This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import makedirs | |
import wandb | |
import pandas as pd | |
import seaborn as sns | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy import stats | |
# 保存ディレクトリ名を指定 (Exist_ok) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torchvision | |
import random | |
import matplotlib.pyplot as plt | |
class MNISTHandler: | |
def __init__(self, train=True): | |
""" | |
Initializes the MNIST dataset. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from : https://twitter.com/karpathy/status/1610822271157022720?s=20&t=kEsA7YdbLhb7bMqg_PUxww | |
import code; code.interact(local=locals()) | |
# something you want to check... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deconvsize(w_in, k, stride, pad, output_pad): | |
return (w_in - 1) * stride - 2 * pad + k + output_pad |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)): |
NewerOlder