This file contains 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 | |
from collections import deque | |
plt.figure() | |
ax = plt.subplot(1,1,1) | |
plt.ylim([-1.1, 1.1]) | |
plt.xlim([0, 50]) |
This file contains 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
# Reference: https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles | |
# Quaternion to Euler | |
def qtoeuler(q): | |
""" quaternion to Euler angle | |
:param q: quaternion | |
:return: | |
""" |
This file contains 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 datetime import datetime | |
s = datetime.now().strftime("%Y-%m-%d-%H-%M-%S") | |
print(s) | |
""" | |
You'll get something like.... 🍺 | |
'2021-06-08-15-35-32' | |
""" |
This file contains 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 numpy as np | |
from sklearn import datasets | |
""" | |
8x8 tiny NIST image handler | |
NIST dataset: https://scikit-learn.org/stable/datasets/toy_dataset.html#digits-dataset | |
If you chose NistHandle(flat=True), you'll get 64-dim vector instead of 8x8 numpy array. |
This file contains 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 os | |
from datetime import datetime | |
import logging.config | |
from logging import StreamHandler, FileHandler, Formatter | |
from logging import INFO, DEBUG, NOTSET | |
def get_new_logger(name, file_path="./log"): | |
# ストリームハンドラの設定 |
This file contains 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 seaborn as sns | |
import matplotlib.pyplot as plt | |
# load data | |
x_ticks = np.linspace(0, 1, 10) | |
y_ticks = np.linspace(0, 1, 10) | |
# ちなみに save は np.save("data_matrix.npy", data_matrix) みたいなかんじで | |
data_matrix = np.load("data_matrix.npy") |
This file contains 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 random | |
import functools | |
import numpy as np | |
import tensorflow as tf | |
import torch | |
import gym | |
import tianshou as ts |
This file contains 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
print('{:.3f}'.format(123.456)) | |
# 123.456 | |
print(f"{0.12345678:.3f}") | |
# 0.123 | |
# Other Examples | |
print('{:.3e}'.format(123.456)) | |
print('{:.3g}'.format(123.456)) | |
print('{:.3}'.format(123.456)) |
This file contains 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 numpy as np | |
import gym | |
from gym.envs.mujoco import mujoco_env | |
from mujoco_py.generated import const | |
from scipy.spatial.transform import Rotation | |
""" Marker types in const | |
GEOM_PLANE = 0 |
This file contains 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 numpy as np | |
from IPython.core.display import HTML | |
import matplotlib.pyplot as plt | |
# if you like seaborn: | |
import seaborn as sns | |
sns.set() | |
sns.set_context("talk") | |
HTML(""" |
OlderNewer