Skip to content

Instantly share code, notes, and snippets.

View takuti's full-sized avatar
🏃‍♂️
𓈒 𓂂𓏸𓋪‪

Takuya Kitazawa takuti

🏃‍♂️
𓈒 𓂂𓏸𓋪‪
View GitHub Profile
@takuti
takuti / Poisson-Image-Blending.m
Last active August 26, 2020 23:40
Implementation of Poisson Image Blending in Objective-C. See: http://qiita.com/takuti/items/b5f8a3466ce3e2af14b3
// ベース(合成先)画像のピクセル値を取得
UIImage *baseImage = [UIImage imageNamed:@"hand1-150x150.png"];
CGImageRef baseCGImage = baseImage.CGImage;
size_t baseBytesPerRow = CGImageGetBytesPerRow(baseCGImage);
CGDataProviderRef baseDataProvider = CGImageGetDataProvider(baseCGImage);
CFDataRef baseData = CGDataProviderCopyData(baseDataProvider);
UInt8 *basePixels = (UInt8*)CFDataGetBytePtr(baseData); // f*_p
// 合成結果のピクセル値の初期値をベース画像と同じものに設定
// これを反復法で書き換えていく
# coding: utf-8
import base64
import Image
import sys
""" This is a simple steganography script
Base64-encoded message will be hidden in a image file
"""
@takuti
takuti / back_propagation.py
Last active January 9, 2022 16:27
Back propagation neural network for Iris data set (4 input nodes, and 3 output nodes)
# coding: utf-8
import numpy as np
import numpy.linalg as ln
classes = ['Iris-setosa', 'Iris-versicolor', 'Iris-virginica']
def sigmoid(u):
return 1. / (1. + np.e ** -u)
# coding: utf-8
""" Usage
$ ./IBM_Model1.py ${english_filename} ${japanese_filename}
NOTE: prefix for filenames 'kftt-alignments/data/' will be automatically added
"""
# Reference: http://www.statmt.org/book/slides/04-word-based-models.pdf
@takuti
takuti / collaborative_filtering.py
Last active January 20, 2016 09:54
Collaborative Filtering for row items in a given N-by-M matrix
import numpy as np
class CF:
"""Collaborative filtering for row items in a given N-by-M matrix
"""
def __init__(self, mat):
self.mat = mat
self.N, self.M = mat.shape
import java.util.*;
class WriteTree {
public static void write(int n) {
int bottom_n = (int) Math.pow(2, n);
int digits = String.valueOf(bottom_n).length();
int w = bottom_n * digits - 1;
int p = 0;
String v = "1";
import random
class MontyHall:
def __init__(self):
pass
def is_won(self, action='stay'):
doors = [1, 2, 3]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 4 in line 1.
# Custom segmentation for long entries
日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞
関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,テスト名詞
# Custom reading for sumo wrestler
朝青龍,朝青龍,アサショウリュウ,カスタム人名
@takuti
takuti / jawikicorpus.py
Last active May 27, 2019 02:49 — forked from yuku/jawikicorpus.py
gensimに日本語Wikipediaを取り込むためのスクリプト
# coding: utf-8
"""USAGE: %(program)s WIKI_XML_DUMP OUTPUT_PREFIX
"""
import logging
import os.path
import sys
import gensim.corpora.wikicorpus as wikicorpus