zoukankan      html  css  js  c++  java
  • Tensorflow 中的 placeholder

    placeholder 是 Tensorflow 中的占位符,暂时储存变量.

    Tensorflow 中用于从外部传入data的占位符, 用input= tf.placeholder()设置占位符, 然后以这种形式传输数据 sess.run(***, feed_dict={input: **}).

    注:占位符就是指暂时没用任何值的符号,待用户输入。只在运算中做一个变量的表示。类似于方程中的未知数。

    示例:

    import tensorflow as tf
    
    #在 Tensorflow 中需要定义 placeholder 的 type ,一般为 float32 形式
    input1 = tf.placeholder(tf.float32)
    input2 = tf.placeholder(tf.float32)
    
    # mul = multiply 是将input1和input2 做乘法运算,并输出为 output 
    ouput = tf.multiply(input1, input2)
    with tf.Session() as sess:
        print(sess.run(ouput, feed_dict={input1: [7.], input2: [2.]}))
    
  • 相关阅读:
    053-649
    053-648
    053-647
    053-646
    053-645
    053-644
    053-643
    053-642
    053-641
    053-640
  • 原文地址:https://www.cnblogs.com/long5683/p/12885810.html
Copyright © 2011-2022 走看看