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 copy_weights_deconvolution(chainer_model, keras_model, layer_name): | |
deconv_chainer = chainer_model[layer_name] | |
W, b = (deconv_chainer.W.data, deconv_chainer.b.data) | |
keras_model.get_layer(layer_name).set_weights([numpy.transpose(W, (2, 3, 0, 1)), b]) | |
def copy_weights_convolution(chainer_model, keras_model, layer_name): | |
conv_chainer = chainer_model[layer_name] | |
W, b = (conv_chainer.W.data, conv_chainer.b.data) | |
keras_model.get_layer(layer_name).set_weights([numpy.transpose(W, (2, 3, 1, 0)), b]) |
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
''' | |
背景 | |
ドワンゴのマストドンfriends.nicoは、favouriteの代わりにニコるになっている。 | |
全部のトゥートに対してこのニコるを手動で付けているユーザーがいる。 | |
それに対抗して全自動でニコるのが一瞬流行った。 | |
そのときに適当に実装したコードがこれ。 | |
手順 | |
0) このコードをダウンロードして auto_fav.py という名前で保存する | |
1) pythonとかpipとかgccが入ってる環境を用意する |
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
# 歴史にcommitAを持つブランチに関して、commitAよりあとのコミットをcommitBに付け替える | |
# for b in `git branch --contains commitA --sort=-committerdate`; do git rebase --onto commitB commitA $b; done | |
function git-rebase-related-branch () { | |
for b in `git branch --contains $1 --sort=committerdate`; do | |
git rebase --onto $2 $1 $b | |
sleep 1s | |
done | |
} |
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 itertools import chain | |
import re | |
def _parse(string): | |
""" | |
>>> _parse('snake_case') | |
('snake', 'case') | |
>>> _parse('PascalCase') | |
('pascal', 'case') |
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 numpy | |
def concat_recursive(batch, newaxis=False): | |
""" | |
>>> from pprint import pprint | |
>>> onedata = numpy.arange(3).reshape(1, -1) | |
>>> batch = [onedata] * 4 | |
>>> pprint(concat_recursive(batch)) | |
array([[0, 1, 2], |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 chainer | |
class Convolution1D(chainer.links.ConvolutionND): | |
def __init__(self, in_channels, out_channels, ksize, stride=1, pad=0, | |
nobias=False, initialW=None, initial_bias=None, | |
cover_all=False): | |
super(Convolution1D, self).__init__( | |
ndim=1, | |
in_channels=in_channels, |
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
p=`python -c "import matplotlib; print(matplotlib.matplotlib_fname())"` | |
sed -i -e "s/backend\s*:\s*TkAgg/backend : Agg/g" $p |
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 argparse | |
import glob | |
import multiprocessing | |
import numpy | |
import tqdm | |
parser = argparse.ArgumentParser() | |
parser.add_argument('glob') | |
parser.add_argument('--processes', type=int) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer