2201_75600134 2023-02-03 19:26 采纳率: 100%
浏览 39
已结题

keyError: loss

用SegNet做裂缝识别,第一次epoch正常运行,第二次epoch刚开始就报错

这是报错内容

379/379 [==============================] - 2858s 8s/step - loss: 0.2259 - accuracy: 0.9275 - val_loss: 0.6390 - val_accuracy: 0.5219
Epoch 2/30

  1/379 [..............................] - ETA: 1sTraceback (most recent call last):
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 767, in on_epoch
    yield epoch_logs
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 342, in fit
    total_epochs=epochs)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 128, in run_one_epoch
    batch_outs = execution_function(iterator)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2_utils.py", line 98, in execution_function
    distributed_function(input_fn))
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 568, in __call__
    result = self._call(*args, **kwds)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\eager\def_function.py", line 599, in _call
    return self._stateless_fn(*args, **kwds)  # pylint: disable=not-callable
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\eager\function.py", line 2363, in __call__
    return graph_function._filtered_call(args, kwargs)  # pylint: disable=protected-access
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\eager\function.py", line 1611, in _filtered_call
    self.captured_inputs)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\eager\function.py", line 1692, in _call_flat
    ctx, args, cancellation_manager=cancellation_manager))
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\eager\function.py", line 545, in call
    ctx=ctx)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\eager\execute.py", line 67, in quick_execute
    six.raise_from(core._status_to_exception(e.code, message), None)
  File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.UnknownError:  IndexError: list index out of range
Traceback (most recent call last):

  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\ops\script_ops.py", line 236, in __call__
    ret = func(*args)

  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\data\ops\dataset_ops.py", line 789, in generator_py_func
    values = next(generator_state.get_iterator(iterator_id))

  File "C:\Users\Administrator\Desktop\python学习\SegNet\Semantic-segmentation-master\mySegNet\train+validation.py", line 134, in generate_arrays_from_file
    train_x_name = lines[read_line].split(';')[0]

IndexError: list index out of range


     [[{{node PyFunc}}]]
     [[IteratorGetNext]] [Op:__inference_distributed_function_3148]

Function call stack:
distributed_function


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\python学习\SegNet\Semantic-segmentation-master\mySegNet\train+validation.py", line 221, in <module>
    main()
  File "C:\Users\Administrator\Desktop\python学习\SegNet\Semantic-segmentation-master\mySegNet\train+validation.py", line 208, in main
    initial_epoch=0)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\util\deprecation.py", line 324, in new_func
    return func(*args, **kwargs)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 1306, in fit_generator
    initial_epoch=initial_epoch)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 819, in fit
    use_multiprocessing=use_multiprocessing)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 397, in fit
    prefix='val_')
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py", line 771, in on_epoch
    self.callbacks.on_epoch_end(epoch, epoch_logs)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\callbacks.py", line 302, in on_epoch_end
    callback.on_epoch_end(epoch, logs)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\callbacks.py", line 992, in on_epoch_end
    self._save_model(epoch=epoch, logs=logs)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\callbacks.py", line 1011, in _save_model
    filepath = self._get_file_path(epoch, logs)
  File "D:\Anaconda\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_core\python\keras\callbacks.py", line 1055, in _get_file_path
    return self.filepath.format(epoch=epoch + 1, **logs)
KeyError: 'loss'

Process finished with exit code 1



  • 写回答

2条回答 默认 最新

  • 流比 2023-02-03 22:01
    关注

    看起来是一个 IndexError: list index out of range 错误,意味示在读取数据时访问了一个超出列表范围的位置。在代码中,特别是在 generate_arrays_from_file 函数中,需要检查索引是否超出范围。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 2月12日
  • 已采纳回答 2月4日
  • 创建了问题 2月3日

悬赏问题

  • ¥15 C++ 菜单窗口独立出来,可以随意移动放大缩小。
  • ¥15 java代码写在记事本上后在cmd上运行时无报错但又没生成文件
  • ¥15 关于#python#的问题:在跑ldsc数据整理的时候一直抱这种错误,要么--out识别不了参数,要么--merge-alleles识别不了参数(操作系统-linux)
  • ¥15 PPOCRLabel
  • ¥15 混合键合键合机对准标识
  • ¥100 现在不懂的是如何将当前的相机中的照片,作为纹理贴图,映射到扫描出的模型上
  • ¥15 目标跟踪,计算机视觉
  • ¥15 魔霸ROG7 pro,win11.息屏后会显示黑屏,如图,如何解决?(关键词-重新启动)
  • ¥15 有没有人知道这是哪里出了问题啊?要怎么改呀?
  • ¥200 C++表格文件处理-悬赏