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

# 1.すぐに利用したい方へ(as soon as)
「Learning TensorFlow」 By Itay Lieder, Yehezkel Resheff, Tom Hope

![cat36.gif](https://qiita-image-store.s3.amazonaws.com/0/51423/badc0621-1e98-96f7-6707-3023a8c571c2.gif)
http://shop.oreilly.com/product/0636920063698.do

## 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
を開く

<img width="453" alt="68747470733a2f2f71696974612d696d6167652d73746f72652e73332e616d617a6f6e6177732e636f6d2f302f35313432332f37633462643761652d326138302d636435322d653839372d3438336630633230323637662e706e67.png" src="https://qiita-image-store.s3.amazonaws.com/0/51423/2e78630b-be3b-13c8-f80a-7388fc6f6643.png">

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

![ju36-1.png](https://qiita-image-store.s3.amazonaws.com/0/51423/c042156a-4351-ceb3-6037-1c4789a1f610.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と３という版の違いと、配布方法の違いなどがある。
Anacondaでpython3をこの１年半利用してきた。
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

```shell-session
(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編 ５つの関門
https://qiita.com/kaizen_nagoya/items/9c46c6da8ceb64d2d7af

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

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

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

# 関連資料
' @kazuo_reve 私が効果を確認した「小川メソッド」
https://qiita.com/kazuo_reve/items/a3ea1d9171deeccc04da

' @kazuo_reve 新人の方によく展開している有益な情報
https://qiita.com/kazuo_reve/items/d1a3f0ee48e24bba38f1

' @kazuo_reve Vモデルについて勘違いしていたと思ったこと
https://qiita.com/kazuo_reve/items/46fddb094563bd9b2e1e
## 自己記事一覧
プログラマが知っていると良い「公序良俗」
https://qiita.com/kaizen_nagoya/items/9fe7c0dfac2fbd77a945

逆も真：社会人が最初に確かめるとよいこと。OSEK(69)、Ethernet(59)
https://qiita.com/kaizen_nagoya/items/39afe4a728a31b903ddc

「何を」よりも「誰を」。１０年後のために今見習いたい人たち
https://qiita.com/kaizen_nagoya/items/8045978b16eb49d572b2

Qiitaの記事に３段階または５段階で到達するための方法
https://qiita.com/kaizen_nagoya/items/6e9298296852325adc5e

物理記事　上位100
https://qiita.com/kaizen_nagoya/items/66e90fe31fbe3facc6ff

量子(0) 計算機, 量子力学 
https://qiita.com/kaizen_nagoya/items/1cd954cb0eed92879fd4

数学関連記事１００
https://qiita.com/kaizen_nagoya/items/d8dadb49a6397e854c6d

統計(0)一覧
https://qiita.com/kaizen_nagoya/items/80d3b221807e53e88aba

図(0) state, sequence and timing. UML and お絵描き 
https://qiita.com/kaizen_nagoya/items/60440a882146aeee9e8f

品質一覧 
https://qiita.com/kaizen_nagoya/items/2b99b8e9db6d94b2e971

言語・文学記事　１００
https://qiita.com/kaizen_nagoya/items/42d58d5ef7fb53c407d6

医工連携関連記事一覧
https://qiita.com/kaizen_nagoya/items/6ab51c12ba51bc260a82

自動車　記事　１００
https://qiita.com/kaizen_nagoya/items/f7f0b9ab36569ad409c5

通信記事１００
https://qiita.com/kaizen_nagoya/items/1d67de5e1cd207b05ef7

日本語（０）一欄
https://qiita.com/kaizen_nagoya/items/7498dcfa3a9ba7fd1e68

英語(0) 一覧
https://qiita.com/kaizen_nagoya/items/680e3f5cbf9430486c7d

転職(0)一覧
https://qiita.com/kaizen_nagoya/items/f77520d378d33451d6fe

仮説（0）一覧（目標100現在40）
https://qiita.com/kaizen_nagoya/items/f000506fe1837b3590df

音楽　一覧(0) 
https://qiita.com/kaizen_nagoya/items/b6e5f42bbfe3bbe40f5d

「@kazuo_reve 新人の方によく展開している有益な情報」確認一覧 
https://qiita.com/kaizen_nagoya/items/b9380888d1e5a042646b

Qiita(0)Qiita関連記事一覧（自分）
https://qiita.com/kaizen_nagoya/items/58db5fbf036b28e9dfa6

鉄道（０）鉄道のシステム考察はてっちゃんがてつだってくれる
https://qiita.com/kaizen_nagoya/items/26bda595f341a27901a0

安全（0）安全工学シンポジウムに向けて: 21
https://qiita.com/kaizen_nagoya/items/c5d78f3def8195cb2409

一覧の一覧( The directory of directories of mine.) Qiita(100)
https://qiita.com/kaizen_nagoya/items/7eb0e006543886138f39

Ethernet 記事一覧　Ethernet(0)
https://qiita.com/kaizen_nagoya/items/88d35e99f74aefc98794

Wireshark 一覧 wireshark(0)、Ethernet(48) 
https://qiita.com/kaizen_nagoya/items/fbed841f61875c4731d0

線網（Wi-Fi）空中線(antenna)(0) 記事一覧(118/300目標)
https://qiita.com/kaizen_nagoya/items/5e5464ac2b24bd4cd001

OSEK OS設計の基礎　OSEK(100)
https://qiita.com/kaizen_nagoya/items/7528a22a14242d2d58a3

Error一覧 error(0)
https://qiita.com/kaizen_nagoya/items/48b6cbc8d68eae2c42b8

++ Support(0)　
https://qiita.com/kaizen_nagoya/items/8720d26f762369a80514

Coding(0) Rules, C, Secure, MISRA and so on
https://qiita.com/kaizen_nagoya/items/400725644a8a0e90fbb0

coding (101) 一覧を作成し始めた。omake:最近のQiitaで表示しない5つの事象
https://qiita.com/kaizen_nagoya/items/20667f09f19598aedb68

プログラマによる、プログラマのための、統計(0)と確率のプログラミングとその後
https://qiita.com/kaizen_nagoya/items/6e9897eb641268766909

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

言語処理100本ノックをdockerで。python覚えるのに最適。:10+12
https://qiita.com/kaizen_nagoya/items/7e7eb7c543e0c18438c4

プログラムちょい替え（0）一覧:4件
https://qiita.com/kaizen_nagoya/items/296d87ef4bfd516bc394

Python(0)記事をまとめたい。
https://qiita.com/kaizen_nagoya/items/088c57d70ab6904ebb53

官公庁・学校・公的団体（NPOを含む）システムの課題、官（０）
https://qiita.com/kaizen_nagoya/items/04ee6eaf7ec13d3af4c3

「はじめての」シリーズ　 ベクタージャパン　
https://qiita.com/kaizen_nagoya/items/2e41634f6e21a3cf74eb

AUTOSAR(0)Qiita記事一覧, OSEK(75)
https://qiita.com/kaizen_nagoya/items/89c07961b59a8754c869

プログラマが知っていると良い「公序良俗」
https://qiita.com/kaizen_nagoya/items/9fe7c0dfac2fbd77a945

LaTeX(0) 一覧　
https://qiita.com/kaizen_nagoya/items/e3f7dafacab58c499792

自動制御、制御工学一覧（０）
https://qiita.com/kaizen_nagoya/items/7767a4e19a6ae1479e6b

Rust(0) 一覧　
https://qiita.com/kaizen_nagoya/items/5e8bb080ba6ca0281927

100以上いいねをいただいた記事16選
https://qiita.com/kaizen_nagoya/items/f8d958d9084ffbd15d2a

小川清最終講義、最終講義（再）計画, Ethernet(100) 英語(100) 安全(100)
https://qiita.com/kaizen_nagoya/items/e2df642e3951e35e6a53

＜この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。＞
This article is an individual impression based on my individual experience. It has nothing to do with the organization or business to which I currently belong.
### 文書履歴(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.