caffe绘制loss和accuracy曲线

caffe绘制曲线时出现问题

1.提示数组越界的问题

绘制曲线时出现下面的问题:

Traceback (most recent call last):
  File "./plot_training_log.py.example", line 201, in 
    plot_chart(chart_type, path_to_png, path_to_logs)
  File "./plot_training_log.py.example", line 134, in plot_chart
    data = load_data(data_file, x, y)
  File "./plot_training_log.py.example", line 88, in load_data
    data[1].append(float(fields[field_idx1].strip()))
IndexError: list index out of range

解决办法是修改plot_training_log.py.example文件中的一个函数,如下:

def load_data(data_file, field_idx0, field_idx1):
    data = [[], []]
    with open(data_file, 'r') as f:
        for line in f:
            line = line.strip()
            if line[0] != '#':
                fields = line.split()
                data[0].append(float(fields[field_idx0].strip()))
                data[1].append(float(fields[field_idx1].strip()))
    return data

修改成下面的内容:

def load_data(data_file, field_idx0, field_idx1):
    data = [[], []]
    with open(data_file, 'r') as f:
        for line in f:
            line = line.strip()
            if line[0] == '#':
                num_fields = len(line.split())
            else:
                fileds = line.split()
                if len(fileds) != num_fields:
                    continue
                data[0].append(float(fileds[field_idx0].strip()))
                data[1].append(float(fileds[field_idx1].strip()))
    return data

你可能感兴趣的:(caffe绘制loss和accuracy曲线)