Skip to content

Instantly share code, notes, and snippets.

View ktnyt's full-sized avatar
🐱

ktnyt ktnyt

🐱
View GitHub Profile
@ktnyt
ktnyt / naive-rae.py
Last active February 22, 2019 23:04
Naive implementation of a recursive autoencoder
import numpy as np
import theano
import theano.tensor as T
class RAE(object):
def __init__(self, input, rng, d, W=None, b=None, U=None, c=None):
dv = d
dh = d * 2
self.dv = dv
@ktnyt
ktnyt / get_userstatus
Created October 20, 2014 06:31
Gets user status for given user
use strict;
use warnings;
use utf8;
use Encode;
use Scalar::Util 'blessed';
use Net::Twitter;
my $username = shift;
@ktnyt
ktnyt / mztab_annotate.pl
Last active August 29, 2015 14:09
mzTab Annotator - picks up "opt_global_kegg" column to automatically annotate SML lines
#!/usr/bin/env perl
###############################################################################
#
# Modules
#
use strict;
use warnings;
use utf8;
use POSIX;
@ktnyt
ktnyt / polish.pl
Created December 15, 2014 04:01
Polish Notation
use strict;
use warnings;
print p([@ARGV]), "\n";
sub p {
my $e = shift;
my $s = shift @{$e};
return p($e) + p($e) if $s eq "+";
return p($e) - p($e) if $s eq "-";
@ktnyt
ktnyt / permute.pl
Created January 15, 2015 17:08
Perl Array Permutation
use strict;
use warnings;
my @list = qw(1 2 3 4);
my @p = permute([@list], []);
foreach my $s (map{join("\t", @{$_})}@p) {
printf("%s\n", $s);
}
sub permute {
@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.
@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 / 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 / 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 / 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);