首页 > 解决方案 > ValueError:无法将字符串转换为浮点数 - 在 google colab 中

问题描述

得到如下所示的错误。“ValueError:无法将字符串转换为浮点数:”

该文件有数字

0.57273,0.677385,1.87446,2.06253,3.33843,5.47434,7.88282,3.52778,9.77052,9.16828



def read_anchors(anchors_path):
    with open(anchors_path) as f:
        anchors = f.readline()
        anchors = [float(x) for x in anchors.split(',')]
        anchors = np.array(anchors).reshape(-1, 2)
    return anchors



!wget  http://upscfever.com/upsc-fever/en/data/deeplearning4/images/yolo_anchors.txt  -P drive/app
anchors = read_anchors("drive/app/yolo_anchors.txt")

标签: python

解决方案


推荐阅读