【发布时间】:2017-10-14 12:25:15
【问题描述】:
我正在尝试在像素分割任务中使用带有ImageGenerator 的样本加权。
- 图像和掩码是 numpy 数组 (634, 1, 64, 64)
- 掩码有 5 个类(编码为 0 到 4)
-
sample_weight是一个数组 (634, 64, 64) - 使用
.flow对具有相同seed=42和batch_size=32的2 个生成器进行数据增强 - 正在使用
sample_weight_mode='temporal'编译模型 -
Unet 模型中的最后 3 层是:
conv2d_19 (Conv2D) (None, 5, 64, 64) 325 dropout_18[0][0] conv2d_20 (Conv2D) (None, 1, 64, 64) 6 conv2d_19[0][0] activation_1 (Activation) (None, 1, 64, 64) 0 conv2d_20[0][0]
这会引发错误:
ValueError: Found a sample_weight array with shape (634, 64, 64). In order to use timestep-wise sample weighting, you should pass a 2D sample_weight array.
如果我将 sample_weight 重塑为 (634, 4096),我会得到:
ValueError: Found a sample_weight array with shape (634, 4096) for an input with shape (32, 1, 64, 64). sample_weight cannot be broadcast.
这是我对如何使用ImageGenerator 的误解还是无法处理这种特殊情况?
如果我不使用样本权重,模型会运行并且不会引发错误。
Keras 2.0.4,Theano 0.9
【问题讨论】:
标签: python machine-learning deep-learning keras theano