KZKY memo

自分用メモ.

Comparison between Multiprocessing and Multithreading in Python

Comparison between Multiprocessing and Multithreading in Python See github.com

GAN: Generative Adversarial Network

前からやってたかったのでGANをやってみた.GANGANの学習は非常難しいのが率直な感想.生成画像がかなりブラー.

Python Shared Memory

データリードがボトルネックになる時があるので,IPC経由でデータを渡す場合とSharedMemory経由でデータを渡す場合で比較してみた.Shared Memory for Data Storage

SSL Ladder Network

Semi-Supervised LearningにおけるLadder Networkを実装した.Permuration-Invariant MNISTで,100ラベルで98%の正答率が出たので,大体再現出来たと言える.SSL Ladder Network References Rasmus, A., Valpola, H., Honkala, M., Berglund, M., & Raiko, T…

Cython with nogil

Cythonでgilを外せるので外したときにどれくらい高速化されるのかを見てみた.Cython with nogilThread + Cython (nogil)が一番良いと思う.

Cython基本

Cythonでできるのこと .pyxをcコードにする Cythonの変数にcの型をもたせられる C/C++ APIの利用 要するに,pythonぽく書けるので生産性が高くて,高速化も可能. Installation pip install cython Hello World こことここに書いてみた. コンパイル方法 2通…

Chainer (1.12.0)をさわってみた

わけあって,Chainerを触らなくてはならなくなった,再び触ってみた. Installation 環境 Chainer: 1.12 OS: Ubuntu15.04 CUDA: 7.5 Compiler: cpp-4.9, g++-4.9, gcc-4.9, cc-4.9 cudnn: v5 CUDA7.5の場合,gcc4.9を使わないとならないようなので注意. ま…

TensorFlow: Save and Restore Graph/Variable

TensorflowのSaverでsave/restoreされるのは,MetaGarph/Variableなどの情報.graphだけを永続化したい場合は,tf.train.write_graph/tf.import_graph_defを使う.同じグラフを常に使う場合,単なるチェックポイントからの復帰は,これのみで可能. Save and…

Docker Engine

今更ながら,Dockerを触ってみた. なぜDockerなのか 一言で言うと,CI/CD (継続的インテグ/継続的ディリバリ)が簡単になるため. Getting Started やっぱり本家のGetting Startedをやるのが,基本を理解するのに一番わかり易い. ここでやるのは,Machine, …

Computational Graphの実装概要

TF, CNTK, Theano, Caffe, Chainer等,巷にDNNライブラリはあふれている.DNNライブラリとはいかないまでも,自分でComputational Graphを実装してみたいと前から思っていたので,書いてみた.インターフェイスとしてすら,まだ全部出来ているわけではない.…

mコマンドを触ってみた

mコマンド(mcmd)というものが耳に入ったのでひと通り触ってみた. 数億件くらいのCSVデータを効率的に集計処理できる mコマンドとは join, uniq, sort, count, sum, aveなどの集計処理に使える in/outのフォーマットはCSV パイプが使えるので,他のunixコマ…

Dygraphs メモ

基本 Tutorialに書いてあることがすべて html <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/dygraph/1.1.1/dygraph-combined.js"></script> js g2 = new Dygraph( document.getElementById("graphdiv2"), "temperatures.csv", // CSV 形式ならfileでなくてもOK {} // options ); csvの指定にfile:///が使えないことに注意 csvがhttpスキーマ…

TensorFlow: Sequence-to-Sequence Models

sequence 2 sequenceの学習の話.この記事を書いている時点で,TFのversionは,0.6.データのダウンロード cd tensorflow/models/rnn/translate python translate.py --data_dir [your_data_directory] で,English to Frenchのデータセットのダウンロードが…

TensorFlow: Python API: Transformation

記事を書いている時点では,v6.0なので注意 Casting tf.string_to_number tf.to_double tf.to_float tf.to_bfloat16 tf.to_int32 tf.to_int64 tf.cast 特に言及なし.sample codes Shapes and Shaping tf.shape tf.size tf.rank tf.reshape tf.squeeze tf.ex…

TensorFlow: Python API: Constants Sequences and Random Values

記事を書いている時点では,v6.0なので注意 Constant Value Tensors tf.zeros tf.zeros_like tf.ones tf.ones_like tf.fill tf.constant 特に注意点なしsample code Sequences tf.linspace tf.range 特に注意点なしsample code Random Tensors tf.random_nor…

TensorFlow: Python API: Math

基本element-wise.記事を書いている時点では,v6.0なので注意 Arithmetic Operators tf.add tf.sub tf.mul tf.div tf.truediv tf.floordiv tf.mod 特に注意点はなし.sample codes Basic Math Functions tf.add_n tf.abs tf.neg tf.sign tf.inv tf.square t…

Theano: Scan Op

現時点でTheano(0.7.0).いまさらながら,scan opをちゃんと見てみることにした.scan opのいいところは,variable length input/outputに対応できること,および,loopの中に,symbolに対してconditionを付けられること.基本的に,このページを順に見てい…

Celery with Multiprocessing and SQLAlchemy

celeryでMultiprocessingをするときにどういう挙動をするのか気になったので,調査. 1. 普通にMultiprocessing 2. SQLAlchemyでsessionを作ってから,Multiprocessing を検証する.1のコードはここ 2のコードはここ 普通にMultiprocessing AssertionError: …

TensorFlow: Control Dependency

Contol Dependencyをさわってみた結論からいうと,cpu上でやるif, thenみたいな細かいflow制御というより,あるTensorと別のあるTensorの値をelement-wiseで比較して,大きい方をとるみたいな感じで使う. サンプル #!/usr/bin/env python import numpy as n…

TensorFlow: tf.get_colleciton()とtf.add_to_collection()

なぞのメソッドtf.get_collection()とtf.get_to_collection()を調べた.API時には, tf.Graph.get_collection(name, scope=None)Returns a list of values in the collection with the given name. Args: key: The key for the collection. For example, the…

TensorFlow: Graphをもう少し理解

Graphをもう少し理解する. Default graph Create another graph in this thread (main thread) Graph in multi thread Write graph as protbuf to disk Read graph from disk and to Graph の5通りのサンプル.チェックポイントからの復帰はやってない.チェ…

TensorFlow: Recurrent Neural Networks

Introduction まず,LSTM articleを読んだほうがいい.わかりやすいので読んだほうがいい.rnn_cell.pyを見ると, BasicRNNCell: 普通のRNN BasicLSTMCell: peep-holeがないLSTM LSTMCell: peep-holeがあるLSTM. さらに,cell clippingとprojection layerがo…

TensorFlow: Vector Representations of Words

word2vec modelの例.word embeddingsていう単語のベクトル表現に使用するembedding matrixを学習で求めるモデル. Highlights WordをVectorとして表現したい動機 modelの直感的解釈とどうやって訓練するか TFでどうやってやるか Scaleさせるやり方 Motivati…

TensorFlow: Convolutional Neural Networks

Overview CIFAR10を使ってCNNおよびmulti-gpuでCNNをするサンプル. CIFAR10データセットは,32x32pixelのカラー 画像で,クラスは10クラスある.大体まとめると. #classes 10 #samples/class 6000 #train samples 50000 #test samples 10000 Goals DNNのア…

TensorFlow: Deep MNIST for Experts

ここではinteractive sessionでCNNを書くチュートリアル. Setup Load MNIST Data git clone https://github.com/tensorflow/tensorflow.git してきて,ここに移動. cd tensorflow/tensorflow/examples/tutorials/mnist こんな感じでmnistデータを読み込み …

Tensor Flow: How To

この記事を書いている時点では,0.6.0が最新なので,それを参考にまとめている. Variables: Creation, Initializing, Saving, and Restoring Variableはin-memory buffferだからtrainingが終わっったら,永続化させてevalutionとかしたい. The tf.Variable…

Python: ZeroMQ2

基本パターン req/res: server/client (server-client blocking, a client can connect to many servers) pub/sub: broadcast (non reliable publish) push/pull: loadbalancing は以前やった kzky.hatenablog.com ので,Intermediaries and Proxiesを学べば…

Python: ZeroMQ

基本 メッセージパッシングフレームワーク or メッセージキューフレームワークの一種. これらはOSSでいっぱいあり,メッセージブローカーがあるbrokerd, メッセージブローカーがいないbrokerlessに大まかに分類される.ZeroMQはbrokerlessに分類される.ア…

Python: TCP Server

基本 Cのsokcet programmingとほとんど同じ Server側 create socket bind socket to (host, port) socket listens with qsize socket accepts connection socket recv msg from a client socket send msg to a client Client側 create socket socket connect…

Python: Manager

基本 何ができるか Manager は別のプロセス間で共有されるデータの作成方法を提供します。マネージャオブジェクトは 共有オブジェクト を管理するサーバプロセスを制御します。他のプロセスはプロキシ経由で共有オブジェクトへアクセスすることができます。 …