我在张量流中训练了一个神经网络。在培训时,我明确定义了输入占位符的形状,其批量大小为20,例如[20,224,224,3]。我明确定义了批处理大小,因为您是网络中的split层,并且当批处理大小引发错误时传递了None。有什么方法可以在推理时更改输入占位符的形状,以便可以对单个图像进行推理?

最佳答案

如果您具有* .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)

关于machine-learning - 在 tensorflow 元图中重置输入占位符的形状,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45607589/

10-12 19:28