Skip to content

Instantly share code, notes, and snippets.

View musyoku's full-sized avatar
🤔
thinking

musyoku

🤔
thinking
View GitHub Profile
# coding: utf-8
from __future__ import division
import time, chainer, argparse, sys
import fft, config
import numpy as np
from chainer import cuda
import alsaaudio, pyaudio
from multiprocessing import Process, Queue
from model import load_model
from __future__ import division
from __future__ import print_function
import argparse, chainer, time, sys
import numpy as np
import chainer.functions as F
from chainer import cuda
from model import Model
from aae.optim import Optimizer, GradientClipping
from aae.utils import onehot, printr, clear_console
from aae.dataset.semi_supervised import Dataset
import chainer
import numpy as np
train, test = chainer.datasets.get_mnist()
dataset = train._datasets[0] * 10 - 5
num_data = dataset.shape[0]
def calculate_parameter():
mean = np.mean(dataset, axis=0)
import re
text = "BASIC_LATIN U+0000 U+007F (128)\n" \
"LATIN_1_SUPPLEMENT U+0080 U+00FF (128)\n" \
"LATIN_EXTENDED_A U+0100 U+017F (128)\n" \
"LATIN_EXTENDED_B U+0180 U+024F (208)\n" \
"IPA_EXTENSIONS U+0250 U+02AF (96)\n" \
"SPACING_MODIFIER_LETTERS U+02B0 U+02FF (80)\n" \
"COMBINING_DIACRITICAL_MARKS U+0300 U+036F (112)\n" \
"GREEK_AND_COPTIC U+0370 U+03FF (135)\n" \
@musyoku
musyoku / v2.py
Created May 16, 2017 08:42
Chainer v2 beta
# encoding: utf-8
import numpy as np
import chainer
import chainer.links as L
import chainer.functions as F
from chainer import cuda, optimizers
from chainer.optimizer import GradientClipping, WeightDecay
class Model(chainer.Chain):
def __init__(self):
@musyoku
musyoku / gist:0875ed9e0a43de038d9b7357cd22f968
Last active May 6, 2017 06:44
chainer.links.linearの精度
# encoding: utf-8
from __future__ import division
from __future__ import print_function
import numpy as np
import chainer.links as L
from chainer import cuda
def test_linear():
np.set_printoptions(precision=32)
xp = cuda.cupy
import math
import numpy as np
batchsize = 2
r = 2
out_channels = 3
in_channels = r ** 2 * out_channels
in_height = 3
in_width = 3
out_height = in_height * r
@musyoku
musyoku / mh.py
Created March 17, 2017 14:54
尤度比によるメトロポリス・ヘイスティングス法の実験
# coding: utf-8
import numpy as np
import math
def compute_log_likelihood(x, mean, stddev):
return math.log(1 / (stddev * math.sqrt(2.0 * math.pi))) - (x - mean) ** 2 / (2.0 * stddev ** 2)
def main():
prior_mean = 2.5
prior_stddev = 0.15
# -*- coding: utf-8 -*-
import math
import json, os, sys
from args import args
from chainer import cuda
sys.path.append(os.path.split(os.getcwd())[0])
from gan import GAN, DiscriminatorParams, GeneratorParams
from sequential import Sequential
from sequential.layers import Linear, BatchNormalization, Deconvolution2D, Convolution2D
from sequential.functions import Activation, dropout, gaussian_noise, tanh, sigmoid, reshape