1

我训练了张量流中的神经网络。在培训时,我明确定义了批量大小为20的输入占位符的形状,如[20,224,224,3]。我明确定义了批处理大小,因为它是网络中的split图层,并且由于批处理大小错误而导致None。有什么方法可以在推理时改变输入占位符的形状,以便我可以对单个图像进行推理?在张量流图中重置输入占位符的形状

回答

3

如果您有保存检查点的* .meta文件,则可以将输入重置为图形。

# Set the correct data type and shape; shape can be (None, 224, 224, 3) also 
new_placeholder = tf.placeholder(tf.float32, shape=(1, 224, 224, 3), name='inputs_new_name') 
# here you need to state the name of the placeholder you used in your original input placeholder 

saver = tf.import_graph_def(path/to/.meta, input_map={"original_inputs_placeholder_name:0": new_placeholder}) 
saver.restore(/path/to/your_checkpoint) 
+0

这样做时出现形状不匹配错误:形状不兼容 – rambossa

相关问题