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

Add CNN class for MNIST in cnn.py and import it in main.py #137

Closed
wants to merge 6 commits into from

Conversation

sweep-nightly[bot]
Copy link

@sweep-nightly sweep-nightly bot commented Oct 28, 2023

Description

This PR adds a new Convolutional Neural Network (CNN) class in cnn.py to handle the MNIST dataset. The CNN class is imported into main.py to replace the existing Net class. The CNN class consists of two convolutional layers followed by two fully connected layers. The input to the model is reshaped appropriately before being passed through the model.

Summary of Changes

  • Created a new file, cnn.py, in the src directory.
  • Added the CNN class definition in cnn.py, which inherits from nn.Module and implements the forward pass of the network.
  • Modified main.py to import the CNN class from cnn.py and instantiate it instead of the Net class.
  • Reshaped the input to the model in the forward method of the CNN class to match the new architecture.

Please review and merge this PR. Thank you!

Fixes #9.


🎉 Latest improvements to Sweep:

  • Sweep can now passively improve your repository! Check out Rules to learn more.

💡 To get Sweep to edit this pull request, you can:

  • Comment below, and Sweep can edit the entire PR
  • Comment on a file, Sweep will only modify the commented file
  • Edit the original issue to get Sweep to recreate the PR from scratch

@sweep-nightly
Copy link
Author

sweep-nightly bot commented Oct 28, 2023

Sandbox Executions

  • Check src/cnn.py
Sandbox logs for https://github.com/sweepai/evals/commit/3c14c6db71bab03da368864dd53a4f60097c5254
trunk fmt src/cnn.py || exit 0 1/4 ✓
 ✔ Formatted src/cnn.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/cnn.py 2/4 ✓
 ✔ Auto-fixed src/cnn.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
if [[ $(echo "src/cnn.py" | grep 'test.*\.py$') ]]; then PYTHONPATH=. python src/cnn.py; else exit 0; fi 3/4 ✓
(nothing was outputted)
if [[ "src/cnn.py" == *test*.py ]]; then PYTHONPATH=. pytest src/cnn.py; else exit 0; fi 4/4 ✓
(nothing was outputted)
  • Check src/main.py
Sandbox logs for https://github.com/sweepai/evals/commit/6fe0dc58c6d693f6797c44858ff015abad11d8ab
trunk fmt src/main.py || exit 0 1/4 ✓
 ✔ Formatted src/main.py
Re-checking autofixed files...

 ✔ Formatted src/main.py
Re-checking autofixed files...


Checked 1 file
✔ No issues
Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures src/main.py 2/4 ✓
 ✔ Auto-fixed src/main.py
Re-checking autofixed files...


  ISSUES  
src/main.py:1:17
  1:17  high  `numpy` imported but unused                              ruff/F401
 42:5   high  Loop control variable `epoch` not used within loop body  ruff/B007
Checked 1 file
2 existing issues (2 auto-fixable)
if [[ $(echo "src/main.py" | grep 'test.*\.py$') ]]; then PYTHONPATH=. python src/main.py; else exit 0; fi 3/4 ✓
(nothing was outputted)
if [[ "src/main.py" == *test*.py ]]; then PYTHONPATH=. pytest src/main.py; else exit 0; fi 4/4 ✓
(nothing was outputted)

@sweep-nightly
Copy link
Author

sweep-nightly bot commented Oct 28, 2023

Apply Sweep Rules to your PR?

  • Apply: All docstrings and comments should be up to date.
  • Apply: Code should be properly formatted and indented.
  • Apply: Variable and function names should be descriptive and follow a consistent naming convention.
  • Apply: Imports should be organized and grouped together.
  • Apply: There should be no unused imports or variables.
  • Apply: Code should be properly commented and include docstrings for functions and classes.

@sweep-nightly
Copy link
Author

sweep-nightly bot commented Oct 28, 2023

The command:
Run pip install -r requirements.txt
yielded the following error:
##[error]Process completed with exit code 1.
Here are the logs:

Looking in links: https://download.pytorch.org/whl/torch_stable.html
Using cached annotated_types-0.6.0-py3-none-any.whl.metadata (12 kB)
Using cached anyio-3.7.1-py3-none-any.whl.metadata (4.7 kB)
Using cached astroid-3.0.1-py3-none-any.whl.metadata (4.5 kB)
Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Using cached charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
ERROR: Could not find a version that satisfies the requirement distutils (from versions: none)
ERROR: No matching distribution found for distutils

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip

1 similar comment
@sweep-nightly
Copy link
Author

sweep-nightly bot commented Oct 28, 2023

The command:
Run pip install -r requirements.txt
yielded the following error:
##[error]Process completed with exit code 1.
Here are the logs:

Looking in links: https://download.pytorch.org/whl/torch_stable.html
Using cached annotated_types-0.6.0-py3-none-any.whl.metadata (12 kB)
Using cached anyio-3.7.1-py3-none-any.whl.metadata (4.7 kB)
Using cached astroid-3.0.1-py3-none-any.whl.metadata (4.5 kB)
Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Using cached charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
ERROR: Could not find a version that satisfies the requirement distutils (from versions: none)
ERROR: No matching distribution found for distutils

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip

@sweep-nightly
Copy link
Author

sweep-nightly bot commented Oct 28, 2023

🚀 Wrote Changes

Done.

@sweep-nightly
Copy link
Author

sweep-nightly bot commented Oct 28, 2023

🚀 Wrote Changes

I wasn't able to make changes. This could be due to an unclear request or a bug in my code.
As a reminder, comments on a file only modify that file. Comments on a PR (at the bottom of the "conversation" tab) can modify the entire PR. Please try again or contact us on Discord

@sweep-nightly sweep-nightly bot closed this Oct 29, 2023
@sweep-nightly sweep-nightly bot deleted the sweep/add-cnn-class_5 branch October 29, 2023 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sweep: add a new cnn class that defines AND trains the cnn to handle mnist in cnn.py and import it to main.py
0 participants