Not.hdl
// This file is part of www.nand2tetris.org // and the book "The Elements of Computing Systems" // by Nisan and Schocken, MIT Press. // File name: projects/01/Not.hdl /** * Not gate: * out = not in */ CHIP Not { IN in; OUT out; PARTS: Nand(a=in, b=in, out=out); }
And.hdl
// This file is part of www.nand2tetris.org // and the book "The Elements of Computing Systems" // by Nisan and Schocken, MIT Press. // File name: projects/01/And.hdl /** * And gate: * out = 1 if (a == 1 and b == 1) * 0 otherwise */ CHIP And { IN a, b; OUT out; PARTS: Nand(a=a, b=b, out=x); Not(in=x, out=out); }
c getopt
#include <stdio.h> #include <unistd.h> int main(int argc, char *argv[]) { char *delivery = ""; int thick = 0; int count = 0; char ch; while ((ch = getopt(argc, argv, "d:t")) != EOF) switch (ch) { case 'd': delivery = optarg; break; case 't': thick = 1; break; default: fprintf(stderr, "Unknown option: '%s'\n", optarg); return 1; } argc -= optind; argv += optind; if (thick) puts("Thick crust."); if (delivery[0]) printf("To be delivered %s.\n", delivery); puts("Ingredients:"); for (count = 0; count < argc; count++) puts(argv[count]); return 0; }
対話システム
- 作者: 中野幹生,船越孝太郎,中野有紀子,駒谷和範,奥村学
- 出版社/メーカー: コロナ社
- 発売日: 2015/01/01
- メディア: 単行本
- この商品を含むブログを見る
iOS webapiからのデータ取得
iOS - Web APIの叩き方いろいろ - Qiita
iOS7から追加されたNSURLSessionを使うパターン。や、NSURLConnectionをつかうパターンとか。
- (void)viewDidLoad { [super viewDidLoad]; NSURLSessionConfiguration *urlSessionConfiguration; urlSessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *urlSession = [NSURLSession sessionWithConfiguration:urlSessionConfiguration]; NSURL *url = [NSURL URLWithString:kEventUrl]; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; NSURLSessionDataTask *urlSessionDataTask; urlSessionDataTask = [urlSession dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { _events = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil]; dispatch_async(dispatch_get_main_queue(), ^{ [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [self.tableView reloadData]; }); }]; [urlSessionDataTask resume]; }
inter-arteq :: interaction between art and technology » Blog Archive » iOSでWebAPIからJSONを取得
これもNSURLConnectionを使うパターン。
Pylearn2 インストール方法
LinuxへのPylearn2のインストール方法。(対象はubuntu)
1. python、git、pipのインストール
aptデータベースの更新
sudo apt-get update
gitをインストール
sudo apt-get install -y --force-yes git
pythonをインストール
sudo apt-get install -y --force-yes python
2. Python各種パッケージのインストール
開発系パッケージ、matplot(plot用)、NumPy(数値計算)、SciPy(科学技術計算)、などをインストール。
sudo apt-get install -y --force-yes python-all-dev libblas-dev libblas3 liblapack-dev liblapack3 liblapacke liblapacke-dev python-matplotlib python-matplotlib-data sudo apt-get install -y --force-yes python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
3. Python Imaging Library (PIL) のインストール
PILは画像データを扱うためのpythonライブラリ。
sudo apt-get install python-dev libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev sudo apt-get build-dep python-imaging pip install git+git://github.com/python-imaging/Pillow.git
4. その他のパッケージをpipでインストール
theano(数値計算用ライブラリ)、PyYAML、など。
sudo pip install theano sudo pip install PyYAML sudo pip uninstall pydot pyparsing sudo pip install pyparsing==1.5.7 sudo pip install pydot
5. pylearn2本体のインストール
git clone git://github.com/lisa-lab/pylearn2.git cd pylearn2 # sudo python setup.py install # /usr/ にインストールする場合 python setup.py install --home=~ # 自分のホームディレクトリにインストールする場合
6. PATHの設定
cp ~/.bashrc ~/.bashrc_bak echo export PYLEARN2_DATA_PATH=$cwd/data >> ~/.bashrc echo export PATH=$cwd/pylearn2/pylearn2/scripts:$PATH >> ~/.bashrc # TODO: escape "$PATH" as raw string echo export PYLEARN2_VIEWER_COMMAND="eog --new-instance" >> ~/.bashrc
7. チュートリアル用データのダウンロード
cifar10。画像クラスのデータセット。
cd data mkdir cifar10 cd cifar10 wget http://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz tar xvfz cifar-10-python.tar.gz
ここまで設定するとcifar10を使ったチュートリアルが動く。
CIFER-10のチュートリアル
$ cd ~/pylearn2/pylearn2/scripts/tutorials/grbm_smd $ python make_dataset.py (実行済み) $ train.py cifar_grbm_smd.yaml # 学習 (2分ほどかかる) $ show_weights.py --out=weights.png cifar_grbm_smd.pkl $ print_monitor.py cifar_grbm_smd.pkl
cifer10
学習結果(隠れ層ユニット数=30)