placeholder 与variable
生活随笔
收集整理的这篇文章主要介绍了
placeholder 与variable
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
placeholder, 译为占位符,官方说法:”TensorFlow provides a placeholder operation that must be fed with data on execution.” 即必须在执行时feed值。
2. variable —变量
placeholder 实例通常用来为算法的实际输入值作占位符。例如,在MNIST例子中,定义输入和输出:
x = tf.placeholder(tf.float32, [None, 784]) #表示成员类型float32, [None, 784]是tensor的shape, None表示第一维是任意数量,784表示第二维是784维 y_ = tf.placeholder(tf.float32, [None, 10])2. variable —变量
当训练模型时,用variable来存储和更新参数。用于表示算法迭代过程中的中间参数。
variable实例化时必须有初始值。MNist中,定义w和b:
总结
以上是生活随笔为你收集整理的placeholder 与variable的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 对抗样本和对抗网络
- 下一篇: InvalidArgumentError