多类语义切分(UNet++)

2024-05-17 07:01:00 发布

您现在位置:Python中文网/ 问答频道 /正文


我正在尝试使用Unet++进行语义分割。你知道吗

shape: [N, H, W] i.e: [16, 256, 256]

target shape: [N, 1, H, W] i.e: [16, 1, 256, 256]

output shape: [N, 1, H, W] i.e: [16, 1, 256, 256]

loss function: BCEWithLogitsLoss

我已经用this model architecture深度监督训练了我的模型。两个班都很好用。你知道吗

现在我试着用这个训练过的模型来上三节课。你知道吗

我已经将遮罩像素值转换为相应的类值。 因此,新的目标形状变成[N, H, W] i.e: [16, 256, 256]

现在我不明白我怎么能在3个类中使用相同的模型。在模型架构中,输出通道=1,这是固定的。你知道吗

我试过了

class_number = 3
model.final1.out_channels = class_number
model.final2.out_channels = class_number
model.final3.out_channels = class_number
model.final4.out_channels = class_number

但它似乎仍然会生成[16, 1, 256, 256]的输出,我希望得到[16, 3, 256, 256]

我是新来的。非常感谢您的建议。
谢谢。你知道吗


Tags: 模型numbertargetunetoutputmodel语义function