Tensorflow 세부 정보 - Tensorboard 시각화 - 소개

1574 단어

일단 기초적인 걸로.


주의, 주의, 여기는 비록 매우 기초적이지만 코드는 주의해야 한다. 1. writer부터 뒤쪽이 틀리면 2, writer를 직접 연결할 수 있다.close, 즉 다음과 같은 작업을 수행할 수 있습니다.
writer = tf.summary.FileWriter("./log", graph=g)
writer.close()
import tensorflow as tf

g = tf.Graph()
with g.as_default():
    input1 = tf.get_variable("input1", shape=[3], dtype=tf.float32, initializer=tf.constant_initializer([1.0, 2.0, 3.0]))
    input2 = tf.get_variable("input2", shape=[3], dtype=tf.float32, initializer=tf.constant_initializer([1.0, 2.0, 3.0]))
    with tf.name_scope("add_reault"):
        output = tf.add_n([input1, input2], name="add")

writer = tf.summary.FileWriter("./log", graph=g)
with tf.Session(graph=g) as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(output))
writer.close()

네임스페이스 작업


마지막 두 개의 명칭 방식을 주의하십시오. 1, tf.get_variable는 tf를 받지 않습니다.name_scope의 영향 2, 꼴찌 두 번째 출력은 a/Variable:0 3, tf.Variable ()는 tf.variable_scope()의 영향도 withtf.name_scope("a"):의 영향
import tensorflow as tf

with tf.variable_scope("foo"):
    a = tf.get_variable("bar", [1])
    print(a.name)

with tf.variable_scope("bar"):
    b = tf.get_variable("bar", [1])
    print(b.name)

with tf.name_scope("a"):
    a = tf.Variable([1])
    print(a.name)
    a = tf.get_variable("b", [1])
    print(a.name)

with tf.variable_scope("b",):
    tf.get_variable("b", [1])

좋은 웹페이지 즐겨찾기