在训练您的模型(运行train.py时)将eager模式设置为True时,训练正常没有报错。但是选择为非eager模式是,设置为False时报错了
提示是进入这步时报错:
ValueError: slice index -1 of dimension 0 out of bounds. for 'loss/yolo_loss_loss/strided_slice' (op: 'StridedSlice') with input shapes: [0], [1], [1], [1] and with computed input tensors: input[1] = <-1>, input[2] = <0>, input[3] = <1>.
感觉是loss损失函数有问题,但关于tensorflow2定义自己的损失函数一致不太明白,如何写自己的损失函数,是否有严格格式规定(比如形参是true,和predict两个),并且要和model.fit中传入的训练数据要对应。
解决问题,理解如何在tensorflow2中灵活定义自己的损失函数