-
Notifications
You must be signed in to change notification settings - Fork 218
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
[Feature]Modification of the finetune mechanism #177
Merged
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
16af829
modify finetune mechanism; add enums.py and decorators.py to avoid us…
DavdGao 06d9f33
format the code
DavdGao d317a73
bug fix
DavdGao 8f4d813
delete wasted parameters
DavdGao 734d841
Merge remote-tracking branch 'origin/master' into feature/finetune
DavdGao 704b2f1
bug fix
DavdGao fa2dca3
bug fix
DavdGao 92cf184
bug fix
DavdGao afb4618
bug fix for ditto
DavdGao eb32d29
minor change for check_data_split
DavdGao 4d13a30
bug fix
DavdGao 9e632a5
bug fix for pFedMe
DavdGao 263930b
bug fix for pFedMe
DavdGao 3dc6dee
Merge remote-tracking branch 'origin/master' into feature/finetune
DavdGao 7498021
Merge remote-tracking branch 'origin/master' into feature/finetune
DavdGao 057648d
bug fix
DavdGao caa08c0
re-call unittest
DavdGao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def use_diff(func): | ||
def wrapper(self, *args, **kwargs): | ||
if self.cfg.federate.use_diff: | ||
# TODO: any issue for subclasses? | ||
before_metric = self.evaluate(target_data_split_name='val') | ||
|
||
num_samples_train, model_para, result_metric = func( | ||
self, *args, **kwargs) | ||
|
||
if self.cfg.federate.use_diff: | ||
# TODO: any issue for subclasses? | ||
after_metric = self.evaluate(target_data_split_name='val') | ||
result_metric['val_total'] = before_metric['val_total'] | ||
result_metric['val_avg_loss_before'] = before_metric[ | ||
'val_avg_loss'] | ||
result_metric['val_avg_loss_after'] = after_metric['val_avg_loss'] | ||
|
||
return num_samples_train, model_para, result_metric | ||
|
||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class MODE: | ||
""" | ||
|
||
Note: | ||
Currently StrEnum cannot be imported with the environment `sys.version_info < (3, 11)`, so we simply create a | ||
MODE class here. | ||
""" | ||
TRAIN = 'train' | ||
TEST = 'test' | ||
VAL = 'val' | ||
FINETUNE = 'finetune' | ||
|
||
|
||
class TRIGGER: | ||
ON_FIT_START = 'on_fit_start' | ||
ON_EPOCH_START = 'on_epoch_start' | ||
ON_BATCH_START = 'on_batch_start' | ||
ON_BATCH_FORWARD = 'on_batch_forward' | ||
ON_BATCH_BACKWARD = 'on_batch_backward' | ||
ON_BATCH_END = 'on_batch_end' | ||
ON_EPOCH_END = 'on_epoch_end' | ||
ON_FIT_END = 'on_fit_end' | ||
|
||
@classmethod | ||
def contains(cls, item): | ||
return item in [ | ||
"on_fit_start", | ||
"on_epoch_start", | ||
"on_batch_start", | ||
"on_batch_forward", | ||
"on_batch_backward", | ||
"on_batch_end", | ||
"on_epoch_end", | ||
"on_fit_end" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rayrayraykk Please help me check this modification. Make sure it is consistent with my original implementation. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part looks good to me.