Machine learning 在tensorflow元图中重置输入占位符的形状
我用tensorflow训练了一个神经网络。在培训时,我明确定义了批量大小为20的输入占位符的形状,如下所示Machine learning 在tensorflow元图中重置输入占位符的形状,machine-learning,tensorflow,neural-network,deep-learning,conv-neural-network,Machine Learning,Tensorflow,Neural Network,Deep Learning,Conv Neural Network,我用tensorflow训练了一个神经网络。在培训时,我明确定义了批量大小为20的输入占位符的形状,如下所示[20224224,3]。我明确地定义了批量大小,因为e是网络中的一个split层,将None作为批量大小传递会在该层上抛出错误。是否有任何方法可以在推断时更改输入占位符的形状,以便在单个图像上进行推断?如果保存了检查点的*.meta文件,则可以将输入重置为图形 # Set the correct data type and shape; shape can be (None, 224,
[20224224,3]
。我明确地定义了批量大小,因为e是网络中的一个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)
执行此操作时会出现形状不匹配错误:形状不兼容