Linux Apaheのインストール
Ubuntu にApache2をインストールします。目的は、pythonのCGIを作るためです。
まずは、Apacheをインストールします。
sudo
apt-get
install
apache2
ついでにDeveloperツールもインストールします。
sudo
apt-get
install
apache2-dev
今回の目的であるmod_wsgiをインストールします。
1
|
sudo pip install mod_wsgi |
動作確認するために、mod_wsgi-express start-server
で確認。
$ mod_wsgi-express start-server
Server URL : http://localhost:8000/
Server Root : /tmp/mod_wsgi-localhost:8000:1000
Server Conf : /tmp/mod_wsgi-localhost:8000:1000/httpd.conf
Error Log File : /tmp/mod_wsgi-localhost:8000:1000/error_log (warn)
Request Capacity : 5 (1 process * 5 threads)
Request Timeout : 60 (seconds)
Startup Timeout : 15 (seconds)
Queue Backlog : 100 (connections)
Queue Timeout : 45 (seconds)
Server Capacity : 20 (event/worker), 20 (prefork)
Server Backlog : 500 (connections)
Locale Setting : en_US.UTF-8
起動方法
まずは既存のApacheを停止
/etc/init.d/apache2 stop
sudo mod_wsgi-express start-server --port 80 --user fujimo --group fujimo
で起動ができました。
Pythonメモ
PythonでSSHするためには、Paramikoをインストールする必要ある。
インターネットで調べると、
でインストールと書いているが、その前に、
sudo apt-get install build-essential libssl-dev libffi-dev python-dev
pip install cryptography
を入れる必要あり。
UPtimeを表示するプログラムは、
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import getpass
import paramiko
server = "localhost"
username = "fujimoto"
password = "xxxxxx"
t = paramiko.Transport*1
try:
t.connect(username=username, password=password, hostkey=None)
except:
t.close()
raise SystemExit("Bad username or password.")
ch = t.open_channel(kind="session")
ch.exec_command("uptime")
if ch.recv_ready:
print(server + ": " + ch.recv(1000))
t.close()
*1:server, 22
行列の積のメモ
行列の(一般的な)積:
行列 に対してその積 を
ただし,
で定義する。ただし, の列数と の行数( とおく)が一致しているときのみ積 は定義される。
AIシステム
- 各コンポーネントのまとめ
- Linuxサーバ:Ubuntu
- DISK:2TBytes
- Webサーバ:Apache
- AI:Tensorflow
- DB
大まかな仕組み
- 画像収集コンポーネント(IMAGE_GUAGTHER)
GogoleのAPIを使って画像を収集するコンポ―ネントである。
- 分析コンポーネント(analyze-image)
TensorflowのAPIを利用して、画像分析、どの分類に入るかを計算する。
- 判定コンポーネント
人がApacheのWebサーバにアクセスする。
画像が出てきて、人とComputerとで判定する。
人が判定した画像は、MacheineLeagingに保管して、
再度、学習をする。
また、人が判定したものに対して、Computerが判定して、
正解をだす。
Androidのアプリケーションのアイディア
迷子アプリ
・GPSで10分おきに、場所がわかる
・決めた範囲より超えたら、メールがくる。
・チャットができる。
レストランのオーダーシステム
・自席で注文できるようにする。
オセロ
・DeepLearingを利用するオセロ
DeepLeaningシステム
・Yes,Noをどんどんためていくシステム
tensor flow tutorial
tensor flowにて、tutorialを実施
以下のプログラミングで、実行すると、
認識率84%の結果が出てきた。次のStepにも行きたい。
fujimoto@fujimoto-VirtualBox:~$ sudo python ./test2
Extracting MNIST_data/train-images-idx3-ubyte.gz
Extracting MNIST_data/train-labels-idx1-ubyte.gz
Extracting MNIST_data/t10k-images-idx3-ubyte.gz
Extracting MNIST_data/t10k-labels-idx1-ubyte.gz
0.8446
fujimoto@fujimoto-VirtualBox:~$
$ cat test2
import tensorflow.examples.tutorials.mnist.input_data
import tensorflow.examples.tutorials.mnist.input_data as input_data
import tensorflow as tf
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
sess = tf.InteractiveSession()
x = tf.placeholder("float", shape=[None, 784])
y_ = tf.placeholder("float", shape=[None, 10])
W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))
sess.run(tf.initialize_all_variables())
y = tf.nn.softmax(tf.matmul(x,W) + b)
cross_entropy = -tf.reduce_sum(y_*tf.log(y))
train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)
for i in range(30):
batch = mnist.train.next_batch(50)
train_step.run(feed_dict={x: batch[0], y_: batch[1]})
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
print accuracy.eval(feed_dict={x: mnist.test.images, y_: mnist.test.labels})
fujimoto@fujimoto-VirtualBox:~$
AIについて
最近AIを勉強中。
とりあえず、TensorFlowをインストールして、Tutorialは動かした。
今後は、
- 次のTutrialの実行
- 独自のニューラルネットワーク理論の開発
- 理論の深める
とする。
現在のチュートリアルは、
-------------------------------------------------------------------------------------------------------
import tensorflow.examples.tutorials.mnist.input_data
import tensorflow.examples.tutorials.mnist.input_data as input_data
import tensorflow as tf
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
sess = tf.InteractiveSession()
x = tf.placeholder("float", shape=[None, 784])
y_ = tf.placeholder("float", shape=[None, 10])
W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))
sess.run(tf.initialize_all_variables())
y = tf.nn.softmax(tf.matmul(x,W) + b)
cross_entropy = -tf.reduce_sum(y_*tf.log(y))
train_step = tf.train.GradientDescentOptimizer(0.01).minimize(cross_entropy)
for i in range(30):
batch = mnist.train.next_batch(50)
train_step.run(feed_dict={x: batch[0], y_: batch[1]})
correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
print accuracy.eval(feed_dict={x: mnist.test.images, y_: mnist.test.labels})