Skip to content

Instantly share code, notes, and snippets.

View ktnyt's full-sized avatar
💫

ktnyt ktnyt

💫
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / genbankn_batch_downloader.pl
Created June 22, 2015 07:31
Batch download GENBANK entries via TogoWS.
#!/usr/bin/env perl
use strict;
use warnings;
my $base = "togows.dbcls.jp/entry/nucleotide";
my ($prefix, $from_id, $to_id) = (@ARGV);
if($from_id > $to_id) {
($from_id, $to_id) = ($to_id, $from_id);
@ktnyt
ktnyt / brica_chainer_sda.py
Last active October 3, 2015 11:20
Implementation of stacked denoising autoencoder using BriCA1 and Chainer.
import argparse
import numpy as np
from sklearn.datasets import fetch_mldata
from chainer import Variable, FunctionSet, optimizers, cuda
import chainer.functions as F
import brica1
class Perceptron():
def __init__(self, n_in, n_out, use_cuda=False):
self.model = FunctionSet(
@ktnyt
ktnyt / chainer_mnist_autoencoder.py
Last active March 15, 2016 18:56
Chainer implementation of MNIST classification with Denoising Autoencoders. `utils` from here: https://gist.github.com/kiyukuta/6170759. You may need to change line 32 from utils.py to `image.astype(numpy.uint8).`
import argparse
import numpy as np
from sklearn.datasets import fetch_mldata
from chainer import Variable, FunctionSet, optimizers, cuda
import chainer.functions as F
#import utils
parser = argparse.ArgumentParser(description='Chainer example: MNIST')
parser.add_argument('--gpu', '-g', default=-1, type=int,
help='GPU ID (negative value indicates CPU)')
@ktnyt
ktnyt / chainer_xor
Created June 10, 2015 08:14
Minimum Chainer implementation of 3-Layer Perceptron for solving XOR
#!/usr/bin/env python
import numpy as np
from chainer import cuda, Function, FunctionSet, gradient_check, Variable, optimizers
import chainer.functions as F
x_train = np.array([
[[0., 0.]],
[[0., 1.]],
[[1., 0.]],
[[1., 1.]]
@ktnyt
ktnyt / iqstat.c
Last active April 5, 2018 03:07
Iteractive qstat viewer $ gcc -o iqstat -O3 -lncurses iqstat.c
/******************************************************************************
** iqstat - Interactive qstat viewer
**
** Created by kotone on 2015/01/16.
** Copyright (c) 2015 Kotone Itaya. All rights reserved.
**
** iqstat is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.