TensorFlow에서 input : 100, output : 100 네트워크에서 학습 고려 v0.2 > csv 파일 출력 추가

7083 단어 borgWarp#migrated
운영 환경
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

v0.2


  • csv 파일 출력 추가
  • 관련하여 calcOutput ()을 numpy.array에서 출력하도록 변경


  • 참고 : ぃ tp // m / richi 40 / ms / 6b3 a f6f4b00d62d 8 1

    code



    Jupyter 코드

    in100_out100.ipynb
    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm
    
    '''
    v0.2 Jan. 14, 2017
      - sa() 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
    
    
    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()
    
    if __name__ == '__main__':
        in_1d = np.random.rand(INDIM)
        showIn2D(in_1d)
        out_1d = calcOutput(in_1d)
        showIn2D(out_1d)
        saveToCsvFile(in_1d, 'test_in.csv')
        saveToCsvFile(out_1d, 'test_out.csv')
    

    결과




    $ cut -c 1-200 test_in.csv 
    3.757247572810928915e-04,2.261566444672071796e-01,5.665968126413482020e-01,5.869499141590118763e-01,6.474665738698877071e-01,8.782973384764291014e-01,9.808027016657328012e-01,9.172719111087710431e-01,
    
    $ cut -c 2300-2500 test_out.csv 
    ,9.172719111087710431e-01,9.808027016657328012e-01,8.782973384764291014e-01,6.474665738698877071e-01,5.869499141590118763e-01,5.665968126413482020e-01,2.261566444672071796e-01,3.757247572810928915e-04
    

    좋은 웹페이지 즐겨찾기