LoginSignup
0
0

dockerで機械学習(36) with anaconda(36)「Learning TensorFlow」 By Itay Lieder, Yehezkel Resheff, Tom Hope

Last updated at Posted at 2018-10-24

1.すぐに利用したい方へ(as soon as)

「Learning TensorFlow」 By Itay Lieder, Yehezkel Resheff, Tom Hope

cat36.gif

docker

dockerを導入し、Windows, Macではdockerを起動しておいてください。
Windowsでは、BiosでIntel Virtualizationをenableにしないとdockerが起動しない場合があります。
また、セキュリティの警告などが出ることがあります。

docker run

$ docker pull kaizenjapan/anaconda-resheff

$ docker run -it -p 8888:8888 kaizenjapan/anaconda-resheff /bin/bash

以下のshell sessionでは
(base) root@f19e2f06eabb:/#は入力促進記号(comman prompt)です。実際には数字の部分が違うかもしれません。この行の#の右側を入力してください。
それ以外の行は出力です。出力にエラー、違いがあれば、コメント欄などでご連絡くださると幸いです。
それぞれの章のフォルダに移動します。

dockerの中と、dockerを起動したOSのシェルとが表示が似ている場合には、どちらで捜査しているか間違えることがあります。dockerの入力促進記号(comman prompt)に気をつけてください。

ファイル共有または複写

dockerとdockerを起動したOSでは、ファイル共有をするか、ファイル複写するかして、生成したファイルをブラウザ等表示させてください。参考文献欄にやり方のURLを記載しています。

dockerを起動したOSのディスクの整理を行う上で、どのやり方がいいか模索中です。一部の方法では、最初から共有設定にしています。

複写の場合は、dockerを起動したOS側コマンドを実行しました。お使いのdockerの番号で置き換えてください。複写したファイルをブラウザで表示し内容確認しました。

02__up_and_running/hello_world.py

(base) root@3bf1f723168d:/# cd Oreilly-Learning-TensorFlow/
(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow# ls
02__up_and_running     04__convolutional_neural_networks  06__word_embeddings_and_rnns	08__queues_threads	    10__serving  README.md
03__tensorflow_basics  05__text_and_visualizations	  07__abstractions		09__distributed_tensorflow  LICENSE
(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow# cd 02__up_and_running/
(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/02__up_and_running# ls
hello_world.py	softmax.py
(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/02__up_and_running# python hello_world.py 
2018-10-24 00:47:57.398820: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-10-24 00:47:57.514008: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
b'Hello World!'

02__up_and_running/softmax.py

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/02__up_and_running# python softmax.py 
WARNING:tensorflow:From softmax.py:10: read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Please write your own downloading logic.
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py:252: _internal_retry.<locals>.wrap.<locals>.wrapped_fn (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Please use urllib or similar directly.
Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:262: extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:267: extract_labels (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-labels-idx1-ubyte.gz
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:110: dense_to_one_hot (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.one_hot on tensors.
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting /tmp/data/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting /tmp/data/t10k-labels-idx1-ubyte.gz
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:290: DataSet.__init__ (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From softmax.py:19: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See `tf.nn.softmax_cross_entropy_with_logits_v2`.

2018-10-24 00:51:18.610937: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-10-24 00:51:18.611455: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
Accuracy: 91.81%

04__convolutional_neural_networks/cifar_cnn.py

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/04__convolutional_neural_networks# python cifar_cnn.py 
Traceback (most recent call last):
  File "cifar_cnn.py", line 180, in <module>
    create_cifar_image()
  File "cifar_cnn.py", line 170, in create_cifar_image
    d = CifarDataManager()
  File "cifar_cnn.py", line 72, in __init__
    self.train = CifarLoader(["data_batch_{}".format(i) for i in range(1, 6)])\
  File "cifar_cnn.py", line 50, in load
    data = [unpickle(f) for f in self._source]
  File "cifar_cnn.py", line 50, in <listcomp>
    data = [unpickle(f) for f in self._source]
  File "cifar_cnn.py", line 21, in unpickle
    with open(os.path.join(DATA_PATH, file), 'rb') as fo:
FileNotFoundError: [Errno 2] No such file or directory: 'path/to/CIFAR10/data_batch_1'

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow# find / -name CIFAR10 -print
(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow# find / -name data_batch_1 -print
/root/.keras/datasets/cifar-10-batches-py/data_batch_1
(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow# vi cifar_cnn.py

フォルダ名を/root/.keras/datasets/cifar-10-batches-py/ に書き換え。

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/04__convolutional_neural_networks# python cifar_cnn.py 
Number of train images: 50000
Number of train labels: 50000
Number of test images: 10000
Number of test labels: 10000
/opt/conda/lib/python3.6/site-packages/matplotlib/figure.py:448: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
  % get_backend())
WARNING:tensorflow:From cifar_cnn.py:103: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See `tf.nn.softmax_cross_entropy_with_logits_v2`.

2018-10-24 01:12:56.946973: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-10-24 01:12:57.506830: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
Accuracy: 10.45%
^CTraceback (most recent call last):
  File "cifar_cnn.py", line 183, in <module>
^C  File "cifar_cnn.py", line 121, in run_simple_net
    sess.run(train_step, feed_dict={x: batch[0], y_: batch[1], keep_prob: 0.5})
  File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 887, in run
    run_metadata_ptr)
  File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1110, in _run
    feed_dict_tensor, options, run_metadata)
  File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1286, in _do_run
    run_metadata)
  File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1292, in _do_call
    return fn(*args)
  File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1277, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1367, in _call_tf_sessionrun
    run_metadata)
KeyboardInterrupt
^C

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/04__convolutional_neural_networks# vi cifar_cnn.py

showをコメントに。

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/04__convolutional_neural_networks# python cifar_cnn.py 
Number of train images: 50000
Number of train labels: 50000
Number of test images: 10000
Number of test labels: 10000
Traceback (most recent call last):
  File "cifar_cnn.py", line 183, in <module>
    create_cifar_image()
  File "cifar_cnn.py", line 179, in create_cifar_image
    display_cifar(images, 10)
  File "cifar_cnn.py", line 39, in display_cifar
    fig.save('img.png')
AttributeError: 'Figure' object has no attribute 'save'

誤:save
正:save fig

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/04__convolutional_neural_networks# python cifar_cnn.py 
Number of train images: 50000
Number of train labels: 50000
Number of test images: 10000
Number of test labels: 10000
WARNING:tensorflow:From cifar_cnn.py:108: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See `tf.nn.softmax_cross_entropy_with_logits_v2`.

2018-10-24 02:22:22.040269: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-10-24 02:22:22.308028: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
Accuracy: 9.57%
Accuracy: 40.66%
Accuracy: 47.27%
Accuracy: 51.6%
Accuracy: 56.59%
Accuracy: 56.63%
Accuracy: 60.34%
Accuracy: 61.64%
Accuracy: 64.52%
Accuracy: 63.11%
Accuracy: 66.11%
Accuracy: 63.63%
Accuracy: 67.95%
Accuracy: 67.07%
Accuracy: 67.79%
Accuracy: 67.67%
Accuracy: 67.9%
Accuracy: 69.19%
Accuracy: 70.59%
Accuracy: 70.13%
Accuracy: 71.7%
Accuracy: 70.19%
Accuracy: 72.39%
Accuracy: 71.47%
中断

04__convolutional_neural_networks/mnist_cnn.py

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/04__convolutional_neural_networks# python mnist_cnn.py 
WARNING:tensorflow:From mnist_cnn.py:12: read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Please write your own downloading logic.
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:262: extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-images-idx3-ubyte.gz
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:267: extract_labels (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-labels-idx1-ubyte.gz
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:110: dense_to_one_hot (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.one_hot on tensors.
Extracting /tmp/data/t10k-images-idx3-ubyte.gz
Extracting /tmp/data/t10k-labels-idx1-ubyte.gz
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:290: DataSet.__init__ (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From mnist_cnn.py:32: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See `tf.nn.softmax_cross_entropy_with_logits_v2`.

2018-10-24 03:45:21.445719: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-10-24 03:45:21.485369: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
step 0, training accuracy 0.07999999821186066
step 100, training accuracy 0.7799999713897705
step 200, training accuracy 0.9399999976158142
step 300, training accuracy 0.9399999976158142
step 400, training accuracy 0.9399999976158142
step 500, training accuracy 0.9399999976158142
step 600, training accuracy 0.9399999976158142
step 700, training accuracy 0.9200000166893005
step 800, training accuracy 0.9599999785423279
step 900, training accuracy 0.9399999976158142
step 1000, training accuracy 0.9800000190734863
step 1100, training accuracy 0.9800000190734863
step 1200, training accuracy 0.9200000166893005
step 1300, training accuracy 0.9599999785423279
step 1400, training accuracy 0.9200000166893005
step 1500, training accuracy 0.9800000190734863
step 1600, training accuracy 0.9800000190734863
step 1700, training accuracy 0.9800000190734863
step 1800, training accuracy 0.9800000190734863
step 1900, training accuracy 0.9599999785423279
step 2000, training accuracy 0.9800000190734863
step 2100, training accuracy 1.0
step 2200, training accuracy 0.9599999785423279
step 2300, training accuracy 0.9599999785423279
step 2400, training accuracy 1.0
step 2500, training accuracy 0.9800000190734863
step 2600, training accuracy 0.9599999785423279
step 2700, training accuracy 0.9800000190734863
step 2800, training accuracy 0.9800000190734863
step 2900, training accuracy 0.9800000190734863
step 3000, training accuracy 1.0
step 3100, training accuracy 0.9800000190734863
step 3200, training accuracy 0.9800000190734863
step 3300, training accuracy 0.9800000190734863
step 3400, training accuracy 0.9599999785423279
step 3500, training accuracy 0.9800000190734863
step 3600, training accuracy 1.0
step 3700, training accuracy 0.9800000190734863
step 3800, training accuracy 0.9800000190734863
step 3900, training accuracy 0.9599999785423279
step 4000, training accuracy 1.0
step 4100, training accuracy 1.0
step 4200, training accuracy 0.9599999785423279
step 4300, training accuracy 1.0
step 4400, training accuracy 0.9800000190734863
step 4500, training accuracy 1.0
step 4600, training accuracy 1.0
step 4700, training accuracy 0.9800000190734863
step 4800, training accuracy 1.0
step 4900, training accuracy 1.0
test accuracy: 0.9863001108169556

##05__text_and_visualizations/BasicRNNCell.py

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/05__text_and_visualizations# python BasicRNNCell.py 
WARNING:tensorflow:From BasicRNNCell.py:10: read_data_sets (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:260: maybe_download (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Please write your own downloading logic.
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:262: extract_images (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-images-idx3-ubyte.gz
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:267: extract_labels (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.data to implement this functionality.
Extracting /tmp/data/train-labels-idx1-ubyte.gz
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:110: dense_to_one_hot (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use tf.one_hot on tensors.
Extracting /tmp/data/t10k-images-idx3-ubyte.gz
Extracting /tmp/data/t10k-labels-idx1-ubyte.gz
WARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py:290: DataSet.__init__ (from tensorflow.contrib.learn.python.learn.datasets.mnist) is deprecated and will be removed in a future version.
Instructions for updating:
Please use alternatives such as official/mnist/dataset.py from tensorflow/models.
WARNING:tensorflow:From BasicRNNCell.py:39: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See `tf.nn.softmax_cross_entropy_with_logits_v2`.

2018-10-24 03:56:40.715171: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-10-24 03:56:40.715772: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
Iter 0, Minibatch Loss= 2.298717, Training Accuracy= 10.93750
Iter 1000, Minibatch Loss= 0.204645, Training Accuracy= 95.31250
Iter 2000, Minibatch Loss= 0.106676, Training Accuracy= 97.65625
Iter 3000, Minibatch Loss= 0.161620, Training Accuracy= 96.87500
Testing Accuracy: 93.75

##05__text_and_visualizations/LSTM_supervised_embeddings.py

(base) root@3bf1f723168d:/Oreilly-Learning-TensorFlow/05__text_and_visualizations# python LSTM_supervised_embeddings.py 
WARNING:tensorflow:From LSTM_supervised_embeddings.py:105: BasicLSTMCell.__init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.
Instructions for updating:
This class is deprecated, please use tf.nn.rnn_cell.LSTMCell, which supports all the feature this cell currently has. Please replace the existing code with tf.nn.rnn_cell.LSTMCell(name='basic_lstm_cell').
WARNING:tensorflow:From LSTM_supervised_embeddings.py:123: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:

Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.

See `tf.nn.softmax_cross_entropy_with_logits_v2`.

2018-10-24 03:59:11.038313: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-10-24 03:59:11.039770: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
Accuracy at 0: 36.71875
Accuracy at 100: 100.00000
Accuracy at 200: 100.00000
Accuracy at 300: 100.00000
Accuracy at 400: 100.00000
Accuracy at 500: 100.00000
Accuracy at 600: 100.00000
Accuracy at 700: 100.00000
Accuracy at 800: 100.00000
Accuracy at 900: 100.00000
Test batch accuracy 0: 100.00000
Test batch accuracy 1: 100.00000
Test batch accuracy 2: 100.00000
Test batch accuracy 3: 100.00000
Test batch accuracy 4: 100.00000

Jupyter Notebook

# jupyter notebook --ip=0.0.0.0 --allow-root
[I 00:53:42.766 NotebookApp] JupyterLab extension loaded from /opt/conda/lib/python3.6/site-packages/jupyterlab
[I 00:53:42.768 NotebookApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 00:53:42.869 NotebookApp] Serving notebooks from local directory: /Oreilly-Learning-TensorFlow
[I 00:53:42.870 NotebookApp] The Jupyter Notebook is running at:
[I 00:53:42.870 NotebookApp] http://(3bf1f723168d or 127.0.0.1):8888/?token=59f9aea81386c391383ce20469943f0c5dcbd6e858b9c379
[I 00:53:42.870 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 00:53:42.871 NotebookApp] No web browser found: could not locate runnable browser.
[C 00:53:42.871 NotebookApp] 
    

ブラウザで
localhost:8888
を開く

68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f35313432332f37633462643761652d326138302d636435322d653839372d3438336630633230323637662e706e67.png

token=59f9aea81386c391383ce20469943f0c5dcbd6e858b9c379
の=の右側の数字をコピペする。

ju36-1.png

#2. dockerを自力で構築する方へ

ここから下は、上記のpullしていただいたdockerをどういう方針で、どういう手順で作ったかを記録します。
上記のdockerを利用する上での参考資料です。本の続きを実行する上では必要ありません。
自力でdocker/anacondaを構築する場合の手順になります。
dockerfileを作る方法ではありません。ごめんなさい。

docker

ubuntu, debianなどのLinuxを、linux, windows, mac osから共通に利用できる仕組み。
利用するOSの設定を変更せずに利用できるのがよい。
同じ仕様で、大量の人が利用することができる。
ソフトウェアの開発元が公式に対応しているものと、利用者が便利に仕立てたものの両方が利用可能である。今回は、公式に配布しているものを、自分で仕立てて、他の人にも利用できるようにする。

python

DeepLearningの実習をPhthonで行って来た。
pythonを使う理由は、多くの機械学習の仕組みがpythonで利用できることと、Rなどの統計解析の仕組みもpythonから容易に利用できることがある。

anaconda

pythonには、2と3という版の違いと、配布方法の違いなどがある。
Anacondaでpython3をこの1年半利用してきた。
Anacondaを利用した理由は、統計解析のライブラリと、JupyterNotebookが初めから入っているからである。
##docker公式配布

ubuntu, debianなどのOSの公式配布,gcc, anacondaなどの言語の公式配布などがある。
これらを利用し、docker-hubに登録することにより、公式配布の質の確認と、変更権を含む幅広い情報の共有ができる。dockerが公式配布するものではなく、それぞれのソフト提供者の公式配布という意味。

docker pull

docker公式配布の利用は、URLからpullすることで実現する。

docker Anaconda

anacondaが公式配布しているものを利用。

$  docker pull kaizenjapan/anaconda-keras
Using default tag: latest
latest: Pulling from continuumio/anaconda3
Digest: sha256:e07b9ca98ac1eeb1179dbf0e0bbcebd87701f8654878d6d8ce164d71746964d1
Status: Image is up to date for continuumio/anaconda3:latest

$ docker run -it -p 8888:8888 continuumio/anaconda3 /bin/bash

実際にはkeras, tensorflow を利用していた他のpushをpull

apt

(base) root@d8857ae56e69:/# apt update

(base) root@d8857ae56e69:/# apt install -y procps

(base) root@d8857ae56e69:/# apt install -y vim

(base) root@d8857ae56e69:/# apt install -y apt-utils

(base) root@d8857ae56e69:/# apt install sudo

ソース git

(base) root@f19e2f06eabb:/# git clone https://github.com/Hezi-Resheff/Oreilly-Learning-TensorFlow

conda

(base) root@f19e2f06eabb:/d# conda update --prefix /opt/conda anaconda

pip

(base) root@f19e2f06eabb:/d# pip install --upgrade pip

docker hubへの登録

$ docker ps
CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                    NAMES
caef766a99ff        continuumio/anaconda3   "/usr/bin/tini -- /b…"   10 hours ago        Up 10 hours         0.0.0.0:8888->8888/tcp   sleepy_bassi

$ docker commit caef766a99ff kaizenjapan/anaconda-resheff

$ docker push kaizenjapan/anaconda-resheff

参考資料(reference)

なぜdockerで機械学習するか 書籍・ソース一覧作成中 (目標100)
https://qiita.com/kaizen_nagoya/items/ddd12477544bf5ba85e2

dockerで機械学習(1) with anaconda(1)「ゼロから作るDeep Learning - Pythonで学ぶディープラーニングの理論と実装」斎藤 康毅 著
https://qiita.com/kaizen_nagoya/items/a7e94ef6dca128d035ab

dockerで機械学習(2)with anaconda(2)「ゼロから作るDeep Learning2自然言語処理編」斎藤 康毅 著
https://qiita.com/kaizen_nagoya/items/3b80dfc76933cea522c6

dockerで機械学習(3)with anaconda(3)「直感Deep Learning」Antonio Gulli、Sujit Pal 第1章,第2章
https://qiita.com/kaizen_nagoya/items/483ae708c71c88419c32

dockerで機械学習(71) 環境構築(1) docker どっかーら、どーやってもエラーばっかり。
https://qiita.com/kaizen_nagoya/items/690d806a4760d9b9e040

dockerで機械学習(72) 環境構築(2) Docker for Windows
https://qiita.com/kaizen_nagoya/items/c4daa5cf52e9f0c2c002

dockerで機械学習(73) 環境構築(3) docker/linux/macos bash スクリプト, ms-dos batchファイル
https://qiita.com/kaizen_nagoya/items/3f7b39110b7f303a5558

dockerで機械学習(74) 環境構築(4) R 難関いくつ?
https://qiita.com/kaizen_nagoya/items/5fb44773bc38574bcf1c

dockerで機械学習(75)環境構築(5)docker関連ファイルの管理
https://qiita.com/kaizen_nagoya/items/4f03df9a42c923087b5d

OpenCVをPythonで動かそうとしてlibGL.soが無いって言われたけど解決した。
https://qiita.com/toshitanian/items/5da24c0c0bd473d514c8

サーバサイドにおけるmatplotlibによる作図Tips
https://qiita.com/TomokIshii/items/3a26ee4453f535a69e9e

Dockerでホストとコンテナ間でのファイルコピー
https://qiita.com/gologo13/items/7e4e404af80377b48fd5

Docker for Mac でファイル共有を利用する
https://qiita.com/seijimomoto/items/1992d68de8baa7e29bb5

「名古屋のIoTは名古屋のOSで」Dockerをどっかーらどうやって使えばいいんでしょう。TOPPERS/FMP on RaspberryPi with Macintosh編 5つの関門
https://qiita.com/kaizen_nagoya/items/9c46c6da8ceb64d2d7af

64bitCPUへの道 and/or 64歳の決意
https://qiita.com/kaizen_nagoya/items/cfb5ffa24ded23ab3f60

ゼロから作るDeepLearning2自然言語処理編 読書会の進め方(例)
https://qiita.com/kaizen_nagoya/items/025eb3f701b36209302e

Ubuntu 16.04 LTS で NVIDIA Docker を使ってみる
https://blog.amedama.jp/entry/2017/04/03/235901

文書履歴(document history)

ver. 0.10 初稿 20181024

最後までおよみいただきありがとうございました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0