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

how to save the loss during lora finetune #218

Open
MathamPollard opened this issue Nov 12, 2024 · 1 comment
Open

how to save the loss during lora finetune #218

MathamPollard opened this issue Nov 12, 2024 · 1 comment

Comments

@MathamPollard
Copy link

This is for bugs only

Did you already ask in the discord?

Yes/No

You verified that this is a bug and not a feature request or question by asking in the discord?

Yes/No

Describe the bug

@Poseidon-fan
Copy link

The loss_dict is in the run method of class BaseSDTrainProcess in the file jobs/process/BaseSDTrainProcess.py:

            # flush()
            ### HOOK ###
            loss_dict = self.hook_train_loop(batch_list)

You can declare a global list and record the loss history:

...
loss_history = []  # global variable


...
            # flush()
            ### HOOK ###
            loss_dict = self.hook_train_loop(batch_list)
            loss_history.append(loss_dict['loss'])

...
        ###################################################################
        ##  END TRAIN LOOP
        ###################################################################

        plt.figure(figsize=(8, 4))
        plt.plot(loss_history, marker='o', linestyle='-', label='Data')
        plt.title('Line Chart of Float List')
        plt.xlabel('step')
        plt.ylabel('loss')
        plt.grid(True)
        plt.legend()
        plt.savefig('loss.png')

        self.progress_bar.close()

...

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

2 participants