Skip to content

Instantly share code, notes, and snippets.

@amobiny
Last active June 10, 2018 04:48
Show Gist options
  • Select an option

  • Save amobiny/557e6c8a3fe0dc954cd9a7d26c6661e5 to your computer and use it in GitHub Desktop.

Select an option

Save amobiny/557e6c8a3fe0dc954cd9a7d26c6661e5 to your computer and use it in GitHub Desktop.

Revisions

  1. amobiny revised this gist Jun 10, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions 04.py
    Original file line number Diff line number Diff line change
    @@ -16,5 +16,4 @@
    summary = sess.run(first_summary)
    # ____step 4:____ add the summary to the writer (i.e. to the event file)
    writer.add_summary(summary, step)
    print('Done with writing the scalar summary')

    print('Done with writing the scalar summary')
  2. amobiny revised this gist Jun 10, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions 04.py
    Original file line number Diff line number Diff line change
    @@ -17,5 +17,4 @@
    # ____step 4:____ add the summary to the writer (i.e. to the event file)
    writer.add_summary(summary, step)
    print('Done with writing the scalar summary')

    Done with writing the scalar summary

  3. amobiny created this gist Jun 10, 2018.
    21 changes: 21 additions & 0 deletions 04.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    import tensorflow as tf
    tf.reset_default_graph() # To clear the defined variables and operations of the previous cell
    # create the scalar variable
    x_scalar = tf.get_variable('x_scalar', shape=[], initializer=tf.truncated_normal_initializer(mean=0, stddev=1))
    # ____step 1:____ create the scalar summary
    first_summary = tf.summary.scalar(name='My_first_scalar_summary', tensor=x_scalar)
    init = tf.global_variables_initializer()
    # launch the graph in a session
    with tf.Session() as sess:
    # ____step 2:____ creating the writer inside the session
    writer = tf.summary.FileWriter('./graphs', sess.graph)
    for step in range(100):
    # loop over several initializations of the variable
    sess.run(init)
    # ____step 3:____ evaluate the scalar summary
    summary = sess.run(first_summary)
    # ____step 4:____ add the summary to the writer (i.e. to the event file)
    writer.add_summary(summary, step)
    print('Done with writing the scalar summary')

    Done with writing the scalar summary