Tensorflow: How to feed a placeholder variable with a tensor?

前端 未结 4 1156
南旧
南旧 2020-12-10 10:47

I have a placeholder variable that expects a batch of input images:

input_placeholder = tf.placeholder(tf.float32, [None] + image_shape, name=\'input_images         


        
4条回答
  •  再見小時候
    2020-12-10 11:04

    You can use feed_dict to feed data into non-placeholders. So, first, wire up your dataflow graph directly to your myInputTensor tensor data source (i.e. don't use a placeholder). Then when you want to run with your numpy data you can effectively mask myImportTensor with myNumpyData, like this:

    mLoss, = sess.run([loss], feed_dict={myImportTensor: myNumpyData})
    

    [I'm still trying to figure out how to do this with multiple tensor data sources however.]

提交回复
热议问题