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

Update CIFAR CNNTransformer example to Lightning #356

Merged
merged 89 commits into from
May 1, 2023

Conversation

wang-hlin
Copy link
Collaborator

@wang-hlin wang-hlin commented Mar 2, 2023

Description

Convert the CIFAR CNNTransformer example from PyTorch to PyTorch Lightning.
Change summary:

  • Converted trainer in cifar_cnntransformer/main.py to trainer that uses Lightning.
  • Moved PredictionHead in cifar_cnntransformer/model.py to kale.predict.class_domain_nets and renamed it to ClassNet.
  • Moved SimpleCNN in cifar_cnntransformer/model.py to kale.embed.image_cnn.
  • Created a standard classfication trainer BaseTrainer and CNNTransformerTrainer in kale.pipeline.base_trainer.
  • Updated on the README and documentation (updated the validation accuracy figure & obsertvations).
  • Updated on the collect_env link in ISSUE_TEMPLATE/bug-report.
  • Upgraded databooks to v1.3.7, fixing Databooks installation fails #362.
  • Finished corresponding functional testing.

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • In-line docstrings updated.
  • Source for documentation at docs manually updated for new API.

@xianyuanliu xianyuanliu requested review from xianyuanliu and removed request for xianyuanliu March 17, 2023 13:19
@shuo-zhou shuo-zhou added the work-in-progress Work in progress that should NOT be merged label Mar 30, 2023
@wang-hlin wang-hlin marked this pull request as draft March 30, 2023 11:43
@xianyuanliu xianyuanliu self-requested a review April 29, 2023 05:06
@xianyuanliu
Copy link
Member

xianyuanliu commented Apr 29, 2023

Haolin has finished the changes, and we are waiting for passing the tests due to the issue #371.

@xianyuanliu
Copy link
Member

xianyuanliu commented Apr 29, 2023

Or it may be time to review what the professional practice is regarding line break (e.g. via asking ChatGPT).

The line length recommended by PEP 8 style guide is 79 for Python code and 72 for docstring or comment. It comes from historical constraints of early computer terminals and displays that were limited to 80 columns. 72 characters are allowed for some indentation and whitespace. Google coding style limits it to 80. In this example, the original codes made by Raivo follow this style, so many line breaks are used.

PyKale sets 120 for code but nothing compulsory for docstring or comment. With the much more generous limits of modern displays and tools, It would be fine for academic research. The only inconvenience I have met is that when opening several files side by side in the PyCharm default setting, I need to scroll horizontally if a file line is over 88 characters. For industry applications, it would be influenced by the real-world display and equipment.

@xianyuanliu xianyuanliu requested a review from haipinglu May 1, 2023 04:52
<div align="center">
<img src="CIFAR10-ModelComparison-ValAcc-Lightning.png" alt="Editor" width="80%">
</div>
(The code example in this folder is not intended to achieve any state-of-art result, but rather to demonstrate the use of CNNTransformer.)
Copy link
Member

@haipinglu haipinglu May 1, 2023

Choose a reason for hiding this comment

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

@HaolinWang2001

  • This is quite verbose. Just say "This example is not inteneded" rather than "The code example in this folder is not indended".
  • I said "state-of-the-art" but you put "state-of-art", have you checked your changes against my suggestion? Why are you removing "the"? Have you Googled to learn or asked Xianyuan or ChatGPT if you are not sure? This is unacceptable and unnecessarily delaying the progress. Please double check unitil you can provide high-quality input consistently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changes have been made. I have double-checked that "state-of-art" is a typo, which has been corrected. Thank you for bringing this to my attention, I will take extra care to ensure that such errors do not occur again in the future.

Copy link
Member

@haipinglu haipinglu left a comment

Choose a reason for hiding this comment

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

@HaolinWang2001 Further minor changes are needed before merging. See comments above please.

# Conflicts:
#	examples/cifar_cnntransformer/README.md
@haipinglu haipinglu changed the title CIFAR CNNTransformer example to Lightning Update CIFAR CNNTransformer example to Lightning May 1, 2023
@haipinglu haipinglu enabled auto-merge May 1, 2023 14:38
@haipinglu haipinglu disabled auto-merge May 1, 2023 14:38
@haipinglu haipinglu enabled auto-merge May 1, 2023 14:38
@haipinglu haipinglu merged commit 28964f0 into pykale:main May 1, 2023
7 checks passed
This was referenced Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature/module (including request)
Projects
Status: Done
v0.2.0
In progress
Development

Successfully merging this pull request may close these issues.

Databooks installation fails
5 participants