Skip to content

Instantly share code, notes, and snippets.

View jojonki's full-sized avatar

Junki Ohmura jojonki

View GitHub Profile
@jojonki
jojonki / index.html
Created February 12, 2023 12:25
Generated by Bing: 「htmlとjavascriptだけでインベーダーゲームのコードを作ってください」
http://43.4.22.206:8888/<html>
<head>
<style>
canvas {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="canvas" width="600" height="400"></canvas>
@jojonki
jojonki / covariance_matrix.py
Last active December 22, 2022 00:42
A simple example of covariance matrix
import numpy as np
data = np.array([[40, 35, 80],
[80, 50, 90],
[20, 55, 40],
[94, 80, 88],
[90, 30, 100]])
print('Input data (N, featuers):', data, data.shape)
N = data.shape[0]
n_dim = data.shape[1]
# -*- coding: utf-8 -*-
# ref: http://taotao54321.hatenablog.com/entry/2016/11/08/180245
import numpy as np
import gym
from gym import wrappers
# Q learning params
ALPHA = 0.1 # learning rate
GAMMA = 0.99 # reward discount
@jojonki
jojonki / init_weights.py
Created December 1, 2017 22:37
Custom initialization of weights in PyTorch
# https://github.com/pytorch/examples/blob/master/dcgan/main.py#L95-L102
def weights_init(m):
classname = m.__class__.__name__
if classname.find('Conv') != -1:
m.weight.data.normal_(0.0, 0.02)
elif classname.find('BatchNorm') != -1:
m.weight.data.normal_(1.0, 0.02)
m.bias.data.fill_(0)
@jojonki
jojonki / FrozenLake-V0-QLearning.py
Last active May 19, 2022 17:47
FrozenLake-v0 with Q learning
# -*- coding: utf-8 -*-
# ref: https://gym.openai.com/evaluations/eval_1lfzNKEHS9GA7nNWE73w
import numpy as np
import gym
from gym import wrappers
# Q learning params
ALPHA = 0.1 # learning rate
GAMMA = 0.99 # reward discount
@jojonki
jojonki / CustomTrainingParams.py
Created November 10, 2017 22:16
Add custom trainable parameters in PyTorch
import random
import torch
import torch.nn as nn
from torch.autograd import Variable
from torch import optim
import torch.nn.functional as F
seq_len = 10
n_class = 5
class SimpleNet(nn.Module):
@jojonki
jojonki / .direnvrc
Last active February 20, 2021 17:58
direnv for anaconda witch automatically switches anaconda environments.
activate_conda(){
eval "$(conda shell.zsh hook)"
conda activate $1
}
@jojonki
jojonki / mac_keybindings.json
Created January 15, 2021 01:30
VSCode settings
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+0",
"command": "workbench.action.nextEditor"
},
{
"key": "ctrl+9",
"command": "workbench.action.previousEditor"
},
@jojonki
jojonki / gist:029ec7d6fb2d91038646bb287f7180c6
Last active January 11, 2021 11:22
three_length_names
This file has been truncated, but you can view the full file.
あああ
ああい
ああう
ああえ
ああお
ああか
ああき
ああく
ああけ
ああこ
243.2 67.0 1
254.5 70.1 1
253.1 59.3 1
228.1 70.4 1
240.8 69.5 1
244.0 69.0 1
257.9 66.3 1
255.8 68.3 1
249.9 63.5 1
251.3 70.3 1