theano_backend.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:odin_old 作者: trungnt13 项目源码 文件源码
def placeholder(shape=None, ndim=None, dtype=_FLOATX, name=None):
    '''Instantiate an input data placeholder variable.
    '''
    if shape is None and ndim is None:
        raise Exception('Specify either a shape or ndim value.')
    if shape is not None:
        ndim = len(shape)
    broadcast = (False,) * ndim

    # ====== Modify add name prefix ====== #
    global _PLACEHOLDER_ID
    name_prefix = 'ID.%02d.' % _PLACEHOLDER_ID
    _PLACEHOLDER_ID += 1
    if name is None:
        name = ''
    name = name_prefix + name
    placeholder = T.TensorType(dtype, broadcast)(name)
    # store the predefined shape of placeholder
    _PLACEHOLDER_SHAPE[name] = \
        [None for _ in range(ndim)] if shape is None else shape
    return placeholder
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号