This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ベース(合成先)画像のピクセル値を取得 | |
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 | |
// 合成結果のピクセル値の初期値をベース画像と同じものに設定 | |
// これを反復法で書き換えていく |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Custom segmentation for long entries | |
日本経済新聞,日本 経済 新聞,ニホン ケイザイ シンブン,カスタム名詞 | |
関西国際空港,関西 国際 空港,カンサイ コクサイ クウコウ,テスト名詞 | |
# Custom reading for sumo wrestler | |
朝青龍,朝青龍,アサショウリュウ,カスタム人名 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
"""USAGE: %(program)s WIKI_XML_DUMP OUTPUT_PREFIX | |
""" | |
import logging | |
import os.path | |
import sys | |
import gensim.corpora.wikicorpus as wikicorpus |
OlderNewer