今天设置自定义损失函数的时候,发现tensor格式没有办法直接用.numpy(),转化成numpy格式。
解决方法:在model.compile()中,将run_eagerly设置成True。
model.compile(optimizer=opt , loss=myloss , run_eagerly=True)
问题解决。
在设置自定义损失函数时遇到Tensor无法直接转换为numpy数组的问题。通过在model.compile()中设置run_eagerly为True,可以解决这个问题,允许在eagerexecution模式下运行模型,从而能够进行Tensor到numpy的转换。
今天设置自定义损失函数的时候,发现tensor格式没有办法直接用.numpy(),转化成numpy格式。
解决方法:在model.compile()中,将run_eagerly设置成True。
model.compile(optimizer=opt , loss=myloss , run_eagerly=True)
问题解决。
1488
5606

被折叠的 条评论
为什么被折叠?
