TensorFlow에서 input : 100, output : 100 네트워크 학습을 고려 v0.5 > 백업 기능/100 패턴 출력
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
v0.1 ぃ tp // m / 7, f9 / ms / 8b43357b, 1f1b, 4b
TensorFlow를 사용하여 input : 100, output : 100 정도의 네트워크 학습을 할까 검토 중.
v0.5
구현 내용
code
Jupyter 코드
in100_out100.ipynb
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import os
'''
v0.5 Feb. 06, 2017
- add [FILENAME_*_CSV],[FILENAME_*_BAK]
- output to csv with append mode
v0.4 Jan. 21, 2017
- set size of figures
v0.3 Jan. 21, 2017
- show 2 images in one figure
v0.2 Jan. 14, 2017
- calcOutput() return in numpy.array
- add saveToCsvFile()
v0.1 Jan. 14, 2017
- add calcOutput()
- add showIn2D()
- show 1d in 2d format
'''
'''
codingrule:PEP8
'''
XDIM = 10
YDIM = 10
INDIM = XDIM * YDIM
FILENAME_IN_CSV = 'test_in.csv'
FILENAME_OUT_CSV = 'test_out.csv'
FILENAME_IN_BAK = 'test_in.bak'
FILENAME_OUT_BAK = 'test_out.bak'
def saveToCsvFile(data_1d, filename):
wrk_1d = data_1d.reshape(1, INDIM)
# np.savetxt(filename, wrk_1d, delimiter=',')
with open(filename, 'a') as fd:
np.savetxt(fd, wrk_1d)
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 np.array(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()
def showIn2D_2image_subplot_each(data1_1d, data2_1d):
data1_2d = np.reshape(data1_1d, (XDIM, YDIM))
data2_2d = np.reshape(data2_1d, (XDIM, YDIM))
fig1 = plt.figure(1)
fig1.set_size_inches(3.14, 3.14)
plt.subplot(121)
plt.title('input node')
plt.imshow(data1_2d, extent=(0, XDIM, 0, YDIM), cmap=cm.gist_rainbow)
plt.subplot(122)
plt.title('output node')
plt.imshow(data2_2d, extent=(0, XDIM, 0, YDIM), cmap=cm.gist_rainbow)
plt.show()
def showIn2D_2image_subplot_first(data1_1d, data2_1d):
data1_2d = np.reshape(data1_1d, (XDIM, YDIM))
data2_2d = np.reshape(data2_1d, (XDIM, YDIM))
fig, (axL, axR) = plt.subplots(ncols=2, figsize=(10, 4))
axL.imshow(data1_2d, extent=(0, XDIM, 0, YDIM), cmap=cm.gist_rainbow)
axL.grid(True)
axR.imshow(data2_2d, extent=(0, XDIM, 0, YDIM), cmap=cm.gist_rainbow)
axR.grid(True)
fig.show()
if __name__ == '__main__':
# backup the original csv files
if os.path.exists(FILENAME_IN_CSV):
os.rename(FILENAME_IN_CSV, FILENAME_IN_BAK)
if os.path.exists(FILENAME_OUT_CSV):
os.rename(FILENAME_OUT_CSV, FILENAME_OUT_BAK)
# append csv
NUM_FILEOUT = 100
NUM_DISPLAY = 5
for loop in range(NUM_FILEOUT):
in_1d = np.random.rand(INDIM)
out_1d = calcOutput(in_1d)
saveToCsvFile(in_1d, FILENAME_IN_CSV)
saveToCsvFile(out_1d, FILENAME_OUT_CSV)
if loop < NUM_DISPLAY:
showIn2D_2image_subplot_each(in_1d, out_1d)
showIn2D_2image_subplot_first(in_1d, out_1d)
결과
input node의 내용을 180도 회전한 output node를 출력. 노드 수를 변경해, 노드수 증대시의 Deep Learning 학습의 요령을 잡는다 (to get the hang of it).
5개만 이미지 표시.
test_in.csv와 test_out.csv가 생성된다.
(백업 파일 test_in.bak 및 test_out.bak)
Reference
이 문제에 관하여(TensorFlow에서 input : 100, output : 100 네트워크 학습을 고려 v0.5 > 백업 기능/100 패턴 출력), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/7of9/items/e82451a71f017db03749텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)