Python tensorflow 模块,sparse_concat() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用tensorflow.sparse_concat()

项目:deep-learning-keras-projects    作者:jasmeetsb    | 项目源码 | 文件源码
def concatenate(tensors, axis=-1):
    """Concatenates a list of tensors alongside the specified axis.

    # Returns
        A tensor.
    """
    if axis < 0:
        dims = ndim(tensors[0])
        if dims:
            axis = axis % dims
        else:
            axis = 0

    if py_all([is_sparse(x) for x in tensors]):
        return tf.sparse_concat(axis, tensors)
    else:
        if tf_major_version >= 1:
            return tf.concat([to_dense(x) for x in tensors], axis)
        else:
            try:
                return tf.concat_v2([to_dense(x) for x in tensors], axis)
            except AttributeError:
                return tf.concat(axis, [to_dense(x) for x in tensors])
项目:keras-customized    作者:ambrite    | 项目源码 | 文件源码
def concatenate(tensors, axis=-1):
    '''Concatenates a list of tensors alongside the specified axis.
    '''
    if axis < 0:
        dims = ndim(tensors[0])
        if dims:
            axis = axis % dims
        else:
            axis = 0

    if py_all([is_sparse(x) for x in tensors]):
        return tf.sparse_concat(axis, tensors)
    else:
        try:
            return tf.concat_v2([to_dense(x) for x in tensors], axis)
        except AttributeError:
            return tf.concat(axis, [to_dense(x) for x in tensors])
项目:keras    作者:NVIDIA    | 项目源码 | 文件源码
def concatenate(tensors, axis=-1):
    """Concatenates a list of tensors alongside the specified axis.

    # Returns
        A tensor.
    """
    if axis < 0:
        dims = ndim(tensors[0])
        if dims:
            axis = axis % dims
        else:
            axis = 0

    if py_all([is_sparse(x) for x in tensors]):
        return tf.sparse_concat(axis, tensors)
    else:
        if tf_major_version >= 1:
            return tf.concat([to_dense(x) for x in tensors], axis)
        else:
            try:
                return tf.concat_v2([to_dense(x) for x in tensors], axis)
            except AttributeError:
                return tf.concat(axis, [to_dense(x) for x in tensors])
项目:keras_superpixel_pooling    作者:parag2489    | 项目源码 | 文件源码
def concatenate(tensors, axis=-1):
    """Concatenates a list of tensors alongside the specified axis.

    # Arguments
        tensors: list of tensors to concatenate.
        axis: concatenation axis.

    # Returns
        A tensor.
    """
    if axis < 0:
        rank = ndim(tensors[0])
        if rank:
            axis %= rank
        else:
            axis = 0

    if py_all([is_sparse(x) for x in tensors]):
        return tf.sparse_concat(axis, tensors)
    else:
        return tf.concat([to_dense(x) for x in tensors], axis)
项目:keras    作者:GeekLiB    | 项目源码 | 文件源码
def concatenate(tensors, axis=-1):
    '''Concantes a list of tensors alongside the specified axis.
    '''
    if axis < 0:
        dims = ndim(tensors[0])
        if dims:
            axis = axis % dims
        else:
            axis = 0

    if py_all([is_sparse(x) for x in tensors]):
        return tf.sparse_concat(axis, tensors)
    else:
        return tf.concat(axis, [to_dense(x) for x in tensors])