네트워크 구조를 파악하기 위해서는 네트워크의 그래프를 tensorboard로 보면서 파악하는 것이 직관적이다.
따라서 tensorboard에 그래프를 출력하기 위해서 학습시에 모델을 저장할 때 그래프도 저장을 한다.
graph = tf.get_default_graph()
...
# Saving the network
if epoch % 10 == 0:
print('Saving the model...')
saver.save(self.sess, 'checkpoints/model', epoch)
# Build the summary operation based on the TF collection of Summaries.
summary_op = tf.summary.merge_all()
summary_writer = tf.summary.FileWriter(os.path.join('checkpoints/'), graph)
이와 같이 graph를 저장하면 tensorboard에서 호출해서 볼수 있다.
tensorboard 사용법은 아래와 같다
tensorboard --logdir=./log
저장된 모델이 있는 폴더를 경로로 명령어를 입력하면
TensorBoard 1.12.2 at http://VICLAB245:6006 (Press CTRL+C to quit)
이런 결과가 나오고 이 주소를 인터넷 (크롬 추천) 주소 창에 치면 tensorboard 화면으로 넘어간다.