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

[Fix] Replace value.numpy()[0] with float(value) #2686

Merged
merged 2 commits into from
Nov 1, 2022

Conversation

juncaipeng
Copy link
Collaborator

To support 0 dim Tensor, replace value.numpy()[0] with float(value) when the shape of value is [1]

Copy link
Collaborator

@shiyutang shiyutang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -177,8 +177,8 @@ def train(self,
labels_src)

loss_src_seg = loss_src_seg_main + loss_src_seg_aux
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file checked

Comment on lines 162 to 166
# TODO use a function to record, print lossetc

avg_loss += loss.numpy()[0]
avg_loss += float(loss)
mdice += np.mean(per_channel_dice) * 100

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked

Comment on lines 143 to 145
model.clear_gradients()
avg_loss += loss.numpy()[0]
avg_loss += float(loss)
mdice += np.mean(per_channel_dice) * 100
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked

Copy link
Collaborator

@wuyefeilin wuyefeilin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@juncaipeng juncaipeng merged commit 4a2f396 into PaddlePaddle:develop Nov 1, 2022
@juncaipeng juncaipeng deleted the support_0_dim branch November 1, 2022 09:01
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

Successfully merging this pull request may close these issues.

3 participants