[API] TensorBoard: Usage


5 steps of using TensorBoard

1.   From TF graph, decide which tensors you want to log

with tf.variable_scope('layer1') as scope:

tf.summary.image('input', x_image, 3)

tf.summary.histogram("layer", L1)

tf.summary.scalar("loss", cost)

2.     Merge all summaries

summary = tf.summary.merge_all()

3.     Create writer and add graph

# Create summary writer

writer = tf.summary.FileWriter(TB_SUMMARY_DIR)

writer.add_graph(sess.graph)

4.     Run summary merge and add_summary

s, _ = sess.run([summary, optimizer], feed_dict=feed_dict)

writer.add_summary(s, global_step=global_step)

5.     Launch TensorBoard

tensorboard --logdir=/tmp/mnist_logs

 

The Visualizations

1.     From TF graph, decide which tensors you want to log

Image Input

# Image input

x_image = tf.reshape(X, [-1, 28, 28, 1])

tf.summary.image('input', x_image, 3)

 

W209 一 OSual


Histogram (multi-dimensional tensors) 

with tf.variable_scope('layer1') as scope:

   W1 = tf.get_variable("W", shape=[784, 512])

   b1 = tf.Variable(tf.random_normal([512]))

   L1 = tf.nn.relu(tf.matmul(X, W1) + b1)

   L1 = tf.nn.dropout(L1, keep_prob=keep_prob)

   tf.summary.histogram("X", X)

   tf.summary.histogram("weights", W1)

   tf.summary.histogram("bias", b1)

   tf.summary.histogram("layer", L1)

 

layer2/layer 
layer2/weights

Scalar tensors

tf.summary.scalar("loss", cost)


 

Add scope for better hierarchy

with tf.variable_scope('layer1') as scope:

  W1 = tf.get_variable("W", shape=[784, 512],...

  b1 = tf.Variable(tf.random_normal([512]))

  L1 = tf.nn.relu(tf.matmul(X, W1) + b1)

  L1 = tf.nn.dropout(L1, keep_prob=keep_prob)

  tf.summary.histogram("X", X)

  tf.summary.histogram("weights", W1)

  tf.summary.histogram("bias", b1)

  tf.summary.histogram("layer", L1)

with tf.variable_scope('layer2') as scope:

   ...

with tf.variable_scope('layer3') as scope:

   ...

with tf.variable_scope('layer4') as scope:

   ...

with tf.variable_scope('layer5') as scope:


layer2 
layerl

 

2.     Merge summaries and

3.     Create writer after creating session

# Summary

summary = tf.summary.merge_all()

# initialize

sess = tf.Session()

sess.run(tf.global_variables_initializer())

# Create summary writer

writer = tf.summary.FileWriter(TB_SUMMARY_DIR)

writer.add_graph(sess.graph)

 

4.     Run merged summary and write (add summary)

s, _ = sess.run([summary, optimizer], feed_dict=feed_dict)

writer.add_summary(s, global_step=global_step)

global_step += 1

 

5.     Launch tensorboard (local)

$ tensorboard logdir=/tmp/mnist_logs

Starting TensorBoard b'41' on port 6006

(You can navigate to http://127.0.0.1:6006)

 

6.     Multiple runs

tensorboard logdir=/tmp/mnist_logs/run1

writer = tf.summary.FileWriter(/tmp/mnist_logs/run1)

tensorboard logdir=/tmp/mnist_logs/run2

writer = tf.summary.FileWriter(/tmp/mnist_logs/run1)

tensorboard logdir=/tmp/mnist_logs

 

 

이 포스팅은 머신러닝/딥러닝 오픈소스 Tensorflow 개발을 위한 선행학습으로 "모두를 위한 머신러닝/딥러닝 강의" TensorBoard 대한 학습노트입니다.

Posted by 이성윤

[Part4. Unit 41] 

패턴 231(I don't care) ~ 233(Would you care for)


패턴 231 I don't care

1. 우리가 어디를 가든 신경 안 써.
★ I don't care where we go.

2. 난 네가 어떻게 생각하든 신경 안 써.
★ I don't care what you think.

3. 난 그것에 대해 신경 안 써.
★ I don't care about that

4. 무슨 일이 일어나든 관심 없어.
★ I don't care what happens.

5. 넌 너희의 변명에 관심 없어

★ I don't care to hear your excuses.

패턴 232 He cares about

1. 그는 널 좋아해.
★ He cares about you.

2. 그는 자기 가족을 좋아해.
★ He cares about his family.

3. 그는 자기 직업을 좋아해
★ He cares about his job.

4. 그는 네가 어떻게 생각하는지 염려해.
★ He cares about what you think.

5. 그 사람은 네 의견을 염려하고 있어.

★ He cares about your opinion.

패턴 233 Would you care for

1. 담요 한 장 더 드릴까요?
★ Would you care for another blanket?

2. 음료수 드릴까요?
★ Would you care for a drink?

3. 스낵 드릴까요?
★ Would you care for a snack?

4. 잡지 드릴까요?
★ Would you care for a magazine?

5. 여행 가실래요?

★ Would you care for a tour? 


이 포스팅은 영어회화 핵심패턴 233 교재의 Unit 41(패턴 231 ~ 패턴 233)대한 학습노트입니다.

Posted by 이성윤

[Part4. Unit 40] 

패턴 227(I am so glad) ~ 230(I'm afraid, but)


패턴 227 I am so glad

1. 다 끝나서 정말 좋다.
★ I am so glad that is over.

2. 우리 휴가를 가게 되어서 정말 좋아요.
★ I am so glad we are taking a vacation.

3. 당신이 맘에 들어하니 저도 좋습니다
★ I am so glad you like it. 

4. 네가 직장을 잡아서 나도 기뻐.
★ I am so glad you got the job.

5. 네가 올 수 있어서 참 좋다.

★ I am so glad you could come. 

패턴 228 I'm afraid of

1. 난 쥐가 싫어.
★ I'm afraid of mice.

2. 난 뱀이라면 질색이야.
★ I'm afraid of snakes.

3. 난 어둠이 싫어.
★ I'm afraid of the dark.

4. 천둥, 번개가 치는 폭풍우는 정말 두려워.
★ I'm afraid of thunderstorms.

5. 전 거미라면 질색이에요.

★ I'm afraid of spiders.

패턴 229 Don't be afraid of

1. 그를 겁내지 마세요.
★ Don't be afraid of him.

2. 거절당하는 것에 겁먹지 말아요.
★ Don't be afraid of rejection.

3. 실패를 두려워하지 말아요
★ Don't be afraid of failure.

4. 절 두려워하지 마세요.
★ Don't be afraid of me.

5. 제 개를 겁내지 마세요.

★ Don't be afraid of my dog.

패턴 230 I'm afraid, but

1. 겁은 나지만 어쨌든 해볼 겁니다.
★ I'm afraid, but I'm going to try anyway.

2. 겁은 나지만 다른 선택이 없어요
★ I'm afraid, but I have no other choice

3. 두렵지만 어쨌든 갈 겁니다.
★ I'm afraid, but I'm going to go anyway.

4. 두렵지만 사실을 말할 거에요
★ I'm afraid, but I will still tell him the truth.

5. 두렵지만 위험을 감수할랍니다.

★ I'm afraid, but I meed to take risks.


이 포스팅은 영어회화 핵심패턴 233 교재의 Unit 40(패턴 227 ~ 패턴 230)대한 학습노트입니다.

Posted by 이성윤