python - 将预测概率转换为二进制输出和 ResourceExhaustedError
问题描述
我定义了以下损失函数:
def dice_coef(y_true, y_pred):
y_pred = K.gather(y_pred, tf.where(y_pred>0.5))
y_true_f = K.flatten(y_true)
y_pred_f = K.flatten(y_pred)
intersect = K.sum(y_pred_f * y_true_f)
denominator = K.sum(y_pred_f) + K.sum(y_true_f)
dice_score = K.constant(2.) * intersect / (denominator + K.constant(.01))
return dice_score
由于我只希望 y_pred 为 0 和 1,因此我遵循了 stackoverflow 上的一个线程,该线程建议使用y_pred = K.gather(y_pred, tf.where(y_pred>0.5))
. 但是,我收到错误消息:
ResourceExhaustedError:分配具有形状的张量时出现 OOM [662885,4,144,144,1]
解决这个问题有什么办法吗?
解决方案
推荐阅读
- node.js - 使用 Microsoft Bot Framework 设置计时器
- python - Hsqldb 重命名具有相同父项的重复项
- r - How to summary statistics 2WA Post HOC?
- c++ - 为什么这个 for 循环条件不起作用?
- angular - 有什么方法可以在 Angular7 中将变量从一个组件更改为另一个组件?
- php - Scraping show infinte loop above php 7.0?
- android - How to save the value from intent to variable and pass it to webservice api?
- spring-websocket - Spring stomp websocket“不完整的帧,正在重置输入缓冲区......”
- android - 使用 PUT 请求执行 httpclient 时出现异常
- mysql - NaviCat 中的 MySQL 语法错误 / WP 编辑器中的 OK