def placeholder(shape=None, ndim=None, dtype=_FLOATX, sparse=False, name=None):
'''Instantiates a placeholder.
# Arguments
shape: shape of the placeholder
(integer tuple, may include None entries).
ndim: number of axes of the tensor.
At least one of {`shape`, `ndim`} must be specified.
If both are specified, `shape` is used.
dtype: placeholder type.
name: optional name string for the placeholder.
# Returns
Placeholder tensor instance.
'''
if not shape:
if ndim:
shape = tuple([None for _ in range(ndim)])
if sparse:
x = tf.sparse_placeholder(dtype, name=name)
x._dims = len(shape)
else:
x = tf.placeholder(dtype, shape=shape, name=name)
x._keras_shape = shape
x._uses_learning_phase = False
return x
评论列表
文章目录