train模型中有一个变量training=tf.placeholder(tf.bool)
在构建的神经网络中用到training,如图所示:
测试时,加载训练好的模型出现如下错误:
在测试模型中我将神经网络中的training值定义为variable类型
Key Variable not found in checkpoint
此时的training会被认为是个参数,所以会寻找它被保存的值;
在测试模型中我将神经网络中的training值直接赋值为False
raise TypeError("pred must not be a Python bool")
这个是tf.cond(pred,……)中的pred传递进去的值正是training值,被判断错误;
结论:tf.placeholder的值是不会被模型保存下来的,它是个占位符,是不会将值保存下来的;