Skip to content

Instantly share code, notes, and snippets.

View jojonki's full-sized avatar

Junki Ohmura jojonki

View GitHub Profile
@jojonki
jojonki / find_and_nkf.sh
Created March 12, 2018 00:14
Convert search files to utf-8
find . -type f -print0 | xargs -0 nkf --overwrite -w -Lu
@jojonki
jojonki / test.txt
Created March 12, 2018 15:12
pudb_debug
ああああああああああああああああ
ああああああああああああああああ
ああああああああああああああああ
ああああああああああああああああ
ああああああああああああああああ
ああああああああああああああああ
ああああああああああああああああ
ああああああああああああああああ
ああああああああああああああああ
ああああああああああああああああ
@jojonki
jojonki / read_lines_until_eof.py
Created April 4, 2018 13:32
Read lines until the EOF in Python
refs = []
while True:
try:
ref = input()
refs.append(ref)
except EOFError:
break
@jojonki
jojonki / pack_padded_sequence-pad_packed_sequence.ipynb
Created April 17, 2018 14:24
A simple usage of pack_padded_sequence and pad_packed_sequence in pytorch
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jojonki
jojonki / pca_t-SNE_mnist.ipynb
Created April 17, 2018 20:34
Comparison of MNIST visualization between PCA and t-SNE
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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]
liens = [line.rstrip('\n') for line in open('file')]
@jojonki
jojonki / get_current_git_revision.py
Created June 24, 2018 14:09
Get a current Git revision in python
import subprocess
rev = subprocess.check_output(['git', 'describe', '--always']).strip().decode('utf-8')
@jojonki
jojonki / load_glove_weight_sample.py
Created August 9, 2018 14:29
Glove embeddings in PyTorch
import numpy as np
import torch
from torch import nn
class Model(nn.Module):
def __init__(self, vocab_size, embd_size, pre_embd_w=None):
super(Model, self).__init__()
self.embd = nn.Embedding(vocab_size, embd_size, padding_idx=0)
@jojonki
jojonki / gist:cb18b14e789eb8bdb2ae2950eef1019f
Created August 22, 2018 22:00
run illustrator in Japanese
defaults write com.adobe.illustrator AppleLanguages '("ja")'