ge-xing / Diff-UNet

Diff-UNet: A Diffusion Embedded Network for Volumetric Segmentation. (using diffusion for 3D medical image segmentation)
Apache License 2.0
149 stars 21 forks source link

in fucntion training_step, why x_start = (x_start) * 2 - 1 #26

Open cqlouis opened 12 months ago

cqlouis commented 12 months ago
def training_step(self, batch):
        image, label = self.get_input(batch)
        x_start = label

        x_start = (x_start) * 2 - 1

why x_start = (x_start)*2 -1 ?

Can I use x_start directly, instead of two times and minus1?

920232796 commented 12 months ago

Yes, it's ok. This operator makes x_start in [-1, 1] range, bacause the diffusion model's input is usually in [-1, 1].

cqlouis commented 12 months ago

Yes, it's ok. This operator makes x_start in [-1, 1] range, bacause the diffusion model's input is usually in [-1, 1].

Thanks for your quick reply.

Another question: I was wondering if there should be some modification in the rest of coding on the condition of making x_start in [-1, 1] or not.

In Chinese: 把x_start 转化为[-1,1]和不转换,直接使用其值在[0,1],这两种情况,在代码上,是不是有什么地方需要做对应的修改?

920232796 commented 11 months ago

No. You can train the model directly, and this operator only has a little change on the validation results.

cqlouis commented 11 months ago

No. You can train the model directly, and this operator only has a little change on the validation results.

Thanks!