imdb3.py 文件源码

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

项目:lstm_tensorflow_imdb 作者: AaronZhouQian 项目源码 文件源码
def binary_one_hot(x):
    try:
        if type(x).__module__ == np.__name__:
            dim0 = x.shape[0]
        elif isinstance(x, list):
            dim0 = len(x)
        else:
            raise TypeError
    except TypeError:
        print("Expecting input type to be one of {list, numpy.ndarray}. Received %s" % type(x))

    dim1 = 2
    output = np.zeros((dim0, dim1))
    for i in range(dim0):
        output[i, x[i]] = 1
    return output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号