텐서보드(tensorboard) 사용법 정리
본 글은 텐서보드(tensorboard) 사용법에 대한 내용을 싣고 있다.
Python에서 Tensorflow로 Deeplearning 어플을 구현하고 테스트할 때, 구현한 코드가 정말 원하는 방향으로 동작하는지 구분하기 어려운 경우가 많았다. 그나마 tensorflow를 사용해 tensor들의 값의 변화, 입출력 이미지 변화 그리고, 그래프 등을 볼 수 있어 분석에 도움이 되었다.
Tensorboard 사용법.
1. import tensorflow as tf
2. 로그를 남기고 싶은 tensor를 선택한다.
ex)
tf.summary.image('input_image', tf.reshape(X,[-1,28,28,1])
tf.summary.scalar(‘cost’, cost)
tf.summary.histogram(‘weight’, W)
3. 위 2에서 선택한 summary를 merge한다.
ex)
summary_op = tf.summary.merge_all()
4. File writer를 생성
ex)
sess = tf.Session()
summary_writer = tf.summary.FileWriter('mnist_autoencoder_logs/',graph_def=sess.graph_def)
5. 3에서 mearge한 summary를 실행하고, 4에서 생성한 file writer에 add_summary한다.
Ex)
s,_ = sess.run([summary_op, eval_op], feed_dict = feed_dict)
summary_writer.add_summary(s,global_step=global_step)
6. Tensorboard 실행한다.
tensorboard --logdir=<logs 위치>
7. 브라우저에서 http://localhost:6006 실행하여 로그를 본다.
8. 더 자세한 사항은 tensorflow 페이지를 참조
댓글
댓글 쓰기