LoginSignup
0
0

More than 5 years have passed since last update.

Jupyter / matplotlib > 15x15のデータ > 拡大表示されるようだ / TensorFlowで input:100, output:100のネットワークでの学習を検討 v0.1

Last updated at Posted at 2017-01-14
動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4

TensorFlowを使って、input:100, output:100程度のネットワークの学習をしようかと検討中。

学習用データとして、入力データを「反転する」処理を実装してみた。

Jupyterのコード

in100_out100.ipynb
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm

'''
v0.1 Jan. 14, 2017
  - add calcOutput()
  - add showIn2D()
  - show 1d in 2d format
'''

'''
codingrule:PEP8
'''

XDIM = 15
YDIM = 15


def calcOutput(in_1d):
    len_1d = XDIM * YDIM
    out_1d = [0.0] * len_1d
    for idx in range(0, in_1d.size):
        out_1d[idx] = in_1d[len_1d - idx - 1]
    return out_1d


def showIn2D(data_1d):
    # print(data_1d)
    data_2d = np.reshape(data_1d, (XDIM, YDIM))
    plt.imshow(data_2d, extent=(0, XDIM, 0, YDIM), cmap=cm.gist_rainbow)
    plt.show()

if __name__ == '__main__':
    in_1d = np.random.rand(XDIM*YDIM)
    showIn2D(in_1d)
    out_1d = calcOutput(in_1d)
    showIn2D(out_1d)

結果 (15x15)

入力ノードが(15x15 = 225)の場合。
縦横方向に自動的に拡大表示されるようだ。これは便利。

qiita.png

結果 (1000x1000)

入力ノードが(1000x1000 = 1million)の場合。

qiita.png

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