codecamp

TensorFlow占位符:tf.placeholder

tf.placeholder 函数
placeholder(
    dtype,
    shape=None,
    name=None
)

定义在:tensorflow/python/ops/array_ops.py

请参阅指南:输入和读取器>占位符

插入一个张量的占位符,这个张量将一直被提供.

注意:如果计算,该张量将产生一个错误,其值必须使用 feed_dict 可选参数来进行 session . run()、Tensor.eval() 或 oper.run().

例如:

x = tf.placeholder(tf.float32, shape=(1024, 1024))
y = tf.matmul(x, x)

with tf.Session() as sess:
  print(sess.run(y))  # ERROR: will fail because x was not fed.

  rand_array = np.random.rand(1024, 1024)
  print(sess.run(y, feed_dict={x: rand_array}))  # Will succeed.

参数:

  • dtype:要输入的张量中元素的类型.
  • shape:要输入的张量的形状(可选).如果未指定形状,则可以输入任何形状的张量.
  • name:操作的名称(可选).

返回:

一个可能被用作提供一个值的句柄的张量,但不直接计算.

解析Example原型:tf.parse_single_example
TensorFlow函数:tf.parse_example
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }