我是张力流的新手。 我正在尝试将pool5图层输出连接到我的模型
预训练模型:
with open("vggface16.tfmodel", mode='rb') as f:
fileContent = f.read()
graph_def = tf.GraphDef()
graph_def.ParseFromString(fileContent)
x_tf = tf.placeholder(tf.float32, shape=[None, 32,32,3],name="raw_images_mh")
x_tf_1=tf.image.resize_images(x_tf,224,224)
y_tf = tf.placeholder(tf.int32, shape=[None,],name="turth_y_mh")
feature_x=tf.import_graph_def(graph_def,name='vggface', input_map={ "images": x_tf_1 },return_elements=["pool5:0"])
我的模特:
newsaver=tf.train.import_meta_graph('PretensorWhimh.ckpt.meta')
newsaver.restore(sess,'PretensorWhimh.ckpt')
graph = tf.get_default_graph()
pool5=graph.get_tensor_by_name("feature_x:0")
results=graph.get_tensor_by_name("fintune_whimh/measure/predict/ArgMax:0")
我可以使用两次运行来获得结果:
pool_x=sess.run(feature_x, feed_dict={x_tf:frames[arr[:10]]})[0]
sess.run(results, feed_dict={pool5:pool_x}