Jupyter/matplotlib > 두 개의 이미지 표시 > 두 가지 구현 (1 : 성공, 2 : 실패)
TensorFlow
운영 환경
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
두 개의 이미지를 옆으로 나란히 표시하려고합니다.
마지막 ぃ tp // m / 7, f9 / ms / 68, 222129dc657 e c54
참고 ぃ tp // 코 m / 슈퍼 사이 아쿠 진 / ms / 543053 또는 4610437112df
두 가지 방법을 시도했습니다.
code
아래에서,
showIn2D_2image_subplot_each() 방법 1.
showIn2D_2image_subplot_first() 방법 2.
in100_out100.ipynb
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
'''
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
'''
XDIM = 10
YDIM = 10
INDIM = XDIM * YDIM
def saveToCsvFile(data_1d, filename):
    wrk_1d = data_1d.reshape(1,INDIM)
    np.savetxt(filename, wrk_1d, delimiter=',')
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)
    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__':
    in_1d = np.random.rand(INDIM)
    # showIn2D(in_1d)
    out_1d = calcOutput(in_1d)
    # showIn2D(out_1d)
    showIn2D_2image_subplot_each(in_1d, out_1d)
    showIn2D_2image_subplot_first(in_1d, out_1d)
    saveToCsvFile(in_1d, 'test_in.csv')
    saveToCsvFile(out_1d, 'test_out.csv')
결과

방법 1의 결과는 표시되었고 방법 2의 결과는 표시되지 않았다.
Reference
이 문제에 관하여(Jupyter/matplotlib > 두 개의 이미지 표시 > 두 가지 구현 (1 : 성공, 2 : 실패)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/7of9/items/c5a765291336087415a3텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)