öffnen tensorflow Grafik aus Datei

Ich versuche, tensorflow für Studium und ich don ' T undestand, wie Sie zu öffnen und verwenden Sie die gespeicherten früh in die Datei my-graph mit Typ tf.Graph. So etwas wie dieses:

import tensorflow as tf

my_graph = tf.Graph()

with g.as_default():
    x = tf.Variable(0)
    b = tf.constant(-5)
    k = tf.constant(2)

    y = k*x + b

tf.train.write_graph(my_graph, '.', 'graph.pbtxt')

f = open('graph.pbtxt', "r")

# Do something with "f" to get my saved graph and use it below in
# tf.Session(graph=...) instead of dots

with tf.Session(graph=...) as sess:
    tf.initialize_all_variables().run()

    y1 = sess.run(y, feed_dict={x: 5})
    y2 = sess.run(y, feed_dict={x: 10})
    print(y1, y2)
Ich war auf der Suche für diese. Und dieser link hat mir geholfen github.com/irfansharif/tensorflow/blob/master/converter.py im Grunde haben wir die Verwendung text_format.Zusammenführen von google protobuf-Paket zu konvertieren pbtxt-Datei, um eine Datei graphdef
Hier ist das ausführliche Beispiel mit der neuesten tensorflow version 1.7 stackoverflow.com/a/52222383/5904928

InformationsquelleAutor Sergey | 2016-10-28

Schreibe einen Kommentar