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

Bug Fix: Convert tensors to scalars for plotting compatibility #909

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

utsavrai
Copy link

Convert Tensor Outputs to Scalars Before Storing in Results

Description:

This commit adjusts the train function to explicitly convert loss and accuracy metrics from PyTorch tensors to Python scalars. This change is implemented right after obtaining the results from train_step and test_step functions. If the metric is a tensor, it is converted to a float using the .item() method, ensuring it is not a tensor residing on the GPU. This prevents TypeError issues when attempting to convert CUDA tensors to NumPy arrays during plotting. The change simplifies downstream data handling and visualization, making our code more robust and easier to maintain.

@utsavrai utsavrai changed the title Convert tensors to scalars for plotting compatibility Bug Fix: Convert tensors to scalars for plotting compatibility May 5, 2024
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.

None yet

1 participant