Skip to content

Instantly share code, notes, and snippets.

View ktnyt's full-sized avatar
🐱

ktnyt ktnyt

🐱
View GitHub Profile
@ktnyt
ktnyt / chainer_ca.py
Last active August 10, 2020 17:41
Refactored code for a Convolutional Autoencoder implemented with Chainer.
import argparse
import numpy as np
from chainer import Variable, FunctionSet, optimizers, cuda
import chainer.functions as F
import cv2
import random
import cPickle as pickle
import sys
class ConvolutionalAutoencoder(FunctionSet):
@ktnyt
ktnyt / conv_dae.py
Last active August 29, 2015 14:24
FunctionSet model for Chainer based Convolutional Denoising Autoencoder
class ConvolutionalAutoencoder(FunctionSet):
def __init__(self, n_in, n_out, ksize, stride=1, pad=0, wscale=1, bias=0, nobias=False):
super(ConvolutionalAutoencoder, self).__init__(
encode=F.Convolution2D(n_in, n_out, ksize, stride=stride, pad=pad, wscale=wscale, bias=bias, nobias=nobias),
decode=F.Convolution2D(n_out, n_in, ksize, stride=stride, pad=pad, wscale=wscale, bias=bias, nobias=nobias)
)
def forward(self, x_data, train=True):
x = Variable(x_data)
t = Variable(x_data)
@ktnyt
ktnyt / brica_svm.py
Created July 3, 2015 09:59
Linear SVM Component Implementation with BriCA
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt
from sklearn import svm, datasets
import brica1
# SVM Component Definition
@ktnyt
ktnyt / brica_chainer_sda.py
Created August 17, 2015 05:53
BriCA + Chainer based simple SDA implementation
import numpy as np
from chainer import Variable, FunctionSet, optimizers
import chainer.functions as F
import data
import brica1
class SLP(FunctionSet):
def __init__(self, n_input, n_output):
super(SLP, self).__init__(
@ktnyt
ktnyt / pickleTinyImageNet.py
Last active November 3, 2017 08:32
Create a pickle of numpy arrays for Tiny ImageNet dataset training images.
#!/usr/bin/env python
import numpy as np
from PIL import Image
import six.moves.cPickle as pickle
wnids = map(lambda x: x.strip(), open('wnids.txt').readlines())
data = {}
data['train'] = {}
data['train']['data'] = np.ndarray(shape=(100000, 3, 64, 64), dtype=np.uint8)
@ktnyt
ktnyt / treasure_hunt_generator.sh
Last active October 14, 2015 05:23
Self explanatory
#!/bin/sh
if [ -d treasure_hunt ]
then
rm -r treasure_hunt
fi
mkdir treasure_hunt
echo 'Aye aye mate! Welcome to the treasure hunt!' >> treasure_hunt/README
@ktnyt
ktnyt / shor.py
Created December 25, 2015 04:53
Simulation of Shor's Algorithm
import numpy as np
import matplotlib.pyplot as plt
def Hadamard(n):
def Hn(H=np.array([[1, 1], [1, -1]], dtype=np.complex64), n=n):
if n > 1:
return Hn(H=np.kron(np.array([[1, 1], [1, -1]], dtype=np.complex64), H), n=n-1)
return H
return Hn(n=n)
@ktnyt
ktnyt / WindowCamera.js
Last active May 7, 2016 19:47
A three.js camera for capturing a view through a static window.
THREE.WindowCamera = function(width, height, far) {
THREE.Camera.call(this);
this.type = 'WindowCamera';
this.width = width;
this.height = height;
this.far = far !== undefined ? far : 2000;
this.updateProjectionMatrix();
};
@ktnyt
ktnyt / HFComponent.py
Last active March 9, 2016 08:24
Hippocampal Formation Mock
import brica1
from CA1Component import CA1Component
from CA3Component import CA3Component
from DGComponent import DGComponent
from ECComponent import ECComponent
class HFComponent(brica1.ComponentSet):
def __init__(self, params):
super(HFComponent, self).__init__()
@ktnyt
ktnyt / kanazawa.md
Last active March 15, 2016 02:10 — forked from tonets/kanazawa.md
BH15.15向け金沢案内

#BH15.15向け金沢案内 @tonetsの主観です.行ったこと無い店も含まれています.

#飲み屋 ##金沢駅周辺

  • table nana
  • ランタン
  • オルガン
  • ゆめり
  • くろ屋