Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got negative prediction value #63

Open
Younger330 opened this issue Nov 2, 2024 · 2 comments
Open

Got negative prediction value #63

Younger330 opened this issue Nov 2, 2024 · 2 comments

Comments

@Younger330
Copy link

Hello, I used your model for training in our Trainer, but the prediction is negative
Here is my code. Am I wrong? Or would you have any suggestions?
`images=images.unsqueeze(4)
out=umamba.forward(images)

    pred=out[0].squeeze(2)
    pred=F.log_softmax(pred,dim=1)
    #the predict is negative

`

@Younger330
Copy link
Author

Younger330 commented Nov 2, 2024

The problem is got by model.apply(InitWeights_He(1e-2)), but I dont know how it influence, maybe only used for radiological images?

Still have this question, although use the loss in nnunet

@Younger330
Copy link
Author

Here is my training code:

train_dataloader = DataLoader(train_dataset, batch_size=4, shuffle=True)



umamba=get_umamba_bot_2d_from_plans(num_input_channels=3)
umamba=umamba.cuda()


epochs = 500
umamba.train()
optimizer = torch.optim.Adam(umamba.parameters(), lr=0.001)#,weight_decay=0.005)

dc_cd_loss=DC_and_CE_loss()

for epoch in tqdm(range(epochs),desc='Epoch'):

    epoch_loss=0
    mean_cross=0
    mean_dice=0

    for images, gt in tqdm(train_dataloader):
        images=images.cuda()
        images=images
        gt=gt.cuda()
        images=images.unsqueeze(4)
        out=umamba.forward(images)
        pred=out[0]
        pred=F.log_softmax(pred,dim=1)#negative prediction wheter delete or not
        gt=gt.unsqueeze(4)

        
        loss=dc_cd_loss(pred,gt)


        
        loss.backward()
        optimizer.step()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant