x2num.py 文件源码

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

项目:tensorboard 作者: dmlc 项目源码 文件源码
def makenp(x, modality=None):
    # if already numpy, return
    if isinstance(x, np.ndarray):
        if modality == 'IMG' and x.dtype == np.uint8:
            return x.astype(np.float32) / 255.0
        return x
    if np.isscalar(x):
        return np.array([x])
    if 'torch' in str(type(x)):
        return pytorch_np(x, modality)
    if 'chainer' in str(type(x)):
        return chainer_np(x, modality)
    if 'mxnet' in str(type(x)):
        return mxnet_np(x, modality)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号