Hallo Ich möchte VGG-Modell von Tensorflow fein tune. Ich habe zwei Fragen.Get Gewichte von Tensorflow-Modell
Wie bekomme ich die Gewichte vom Netzwerk? Die trainable_variables gibt eine leere Liste für mich zurück.
Ich benutzte existierendes Modell von hier: https://github.com/ry/tensorflow-vgg16. Ich finde die Post über Gewichte bekommen aber das funktioniert nicht für mich wegen Import_graph_def. Get the value of some weights in a model trained by TensorFlow
import tensorflow as tf
import PIL.Image
import numpy as np
with open("../vgg16.tfmodel", mode='rb') as f:
fileContent = f.read()
graph_def = tf.GraphDef()
graph_def.ParseFromString(fileContent)
images = tf.placeholder("float", [None, 224, 224, 3])
tf.import_graph_def(graph_def, input_map={ "images": images })
print("graph loaded from disk")
graph = tf.get_default_graph()
cat = np.asarray(PIL.Image.open('../cat224.jpg'))
print(cat.shape)
init = tf.initialize_all_variables()
with tf.Session(graph=graph) as sess:
print(tf.trainable_variables())
sess.run(init)
Versuchen Sie, mehrere Fragen gleichzeitig zu vermeiden. Wenn Sie keine Antwort auf eine der beiden Fragen finden, und Sie denken, dass beide wertvolle Fragen sind, können Sie beide in getrennten Beiträgen fragen. – Giewev