GitHub - maxbak753/Few-Shot-Learning-IMGS789: Few-Shot Learning with Prototypical Network (project for IMGS789 - Machine Learning for Difficult Data) · GitHub
https://github.com/maxbak753/Few-Shot-Learning-IMGS789 • 253 KB fetched
Open original page
GitHub - maxbak753/Few-Shot-Learning-IMGS789: Few-Shot Learning with Prototypical Network (project for IMGS789 - Machine Learning for Difficult Data) · GitHub
Skip to content
Navigation Menu
Sign in Appearance settings
* Platform
* AI CODE CREATION
* GitHub Copilot Write better code with AI
* GitHub Copilot app Direct agents from issue to merge
* MCP Registry Integrate external tools
* DEVELOPER WORKFLOWS
* Actions Automate any workflow
* Codespaces Instant dev environments
* Issues Plan and track work
* Code Review Manage code changes
* Code Quality Enforce quality at merge
* APPLICATION SECURITY
* GitHub Advanced Security Find and fix vulnerabilities
* Code security Secure your code as you build
* Secret protection Stop leaks before they start
* EXPLORE
* Why GitHub
* Documentation
* Blog
* Changelog
* Marketplace
View all features
* Solutions
* BY COMPANY SIZE
* Enterprises
* Small and medium teams
* Startups
* Nonprofits
* BY USE CASE
* App Modernization
* DevSecOps
* DevOps
* CI/CD
* View all use cases
* BY INDUSTRY
* Healthcare
* Financial services
* Manufacturing
* Government
* View all industries
View all solutions
* Resources
* EXPLORE BY TOPIC
* AI
* Software Development
* DevOps
* Security
* View all topics
* EXPLORE BY TYPE
* Customer stories
* Events & webinars
* Ebooks & reports
* Business insights
* GitHub Skills
* SUPPORT & SERVICES
* Documentation
* Customer support
* Community forum
* Trust center
* Partners
View all resources
* Open Source
* COMMUNITY
* GitHub Sponsors Fund open source developers
* PROGRAMS
* Security Lab
* Maintainer Community
* GitHub Stars
* Archive Program
* REPOSITORIES
* Topics
* Trending
* Collections
* Enterprise
* ENTERPRISE SOLUTIONS
* Enterprise platform AI-powered developer platform
* AVAILABLE ADD-ONS
* GitHub Advanced Security Enterprise-grade security features
* Copilot for Business Enterprise-grade AI features
* Premium Support Enterprise-grade 24/7 support
* Pricing
Search /
Sign in
Sign up Appearance settings
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
maxbak753
/
Few-Shot-Learning-IMGS789
Public
*
Notifications
You must be signed in to change notification settings
*
Fork
0
*
Star
0
*
Code
*
Issues
0
*
Pull requests
0
*
Actions
*
Projects
*
Security and quality
0
*
Insights
Additional navigation options
*
Code
*
Issues
*
Pull requests
*
Actions
*
Projects
*
Security and quality
*
Insights
main
Branches Tags
Go to file
Code Open more actions menu
Latest commit
History
11 Commits
11 Commits
Folders and files
Name Name Last commit message
Last commit date
images
images
IMGS 789 Project Paper.pdf
IMGS 789 Project Paper.pdf
IMGS789_Project.py
IMGS789_Project.py
README.md
README.md
View all files
Repository files navigation
*
* README
More items
Few-Shot Learning with a Prototypical Network
Project for IMGS789 - Machine Learning for Difficult Data
Project Paper Link
Overview
Few-shot learning is a machine learning technique used when new classes need to be added to a classifier, and there is limited data available for the new classes. In this project, I aim to investigate two scenarios: when there are five samples (shots) per class and when only a single sample exists for each class.
To perform few-shot learning, there are many methods, but here I use a prototypical network. A prototypical network works by learning a latent space embedding that makes it possible to do a simple nearest-neighbor classification to predict the outputs. It works by splitting the training data into support and query sets, embedding the support set in the latent space, computing the average value of each class to use as a prototype, then comparing to the query data with the support prototypes and classifying the data as belonging to the closest class by some distance metric.
Implementation
For my implementation I primarily used the PyTorch Python library with the Omniglot dataset. I chose a simple euclidean distance metric to classify the data. I used 10 epochs with 100 episodes of support-query training per epoch, and the ADAM optimizer. I chose 5-way 1-shot learning and 5-way 5-shot learning with 15 query samples per episode. The final test evaluation was also done with 5 classes, but with 1000 test iterations to increase the reliability of the results.
My convolutional neural network consists of 3 sets of convolution layer → max-pooling layer → ReLU, followed by average pooling, and then a linear fully connected layer to get the final embeddings. I originally started with LeNet, added an additional convolutional layer, then modified the end layer to only do embedding.
Results
Overall, the model seemed to perform well, with an average accuracy of 94.47% and a fairly small standard deviation of 5.02%, for 5-shot learning. However, 1-shot learning performed worse, with 85.81% accuracy with a larger 9.82% standard deviation. The Matthews Correlation Coefficient had a similar pattern with a value of 0.8305 for 1-shot and 0.9325 for 5-shot. The results are depicted in table #1.
Figure #1: Training Loss (1-Shot)
Figure #2: Training Loss (5-shot)
Table #1: Results for 1-shot and 5-shot learning
References
[1] IBM, “What is Few-Shot Learning?,” IBM Think. [Online]. Available: https://www.ibm.com/think/topics/few-shot-learning . [Accessed: Jul. 6, 2026].
[2] PyTorch Contributors, “Torchvision Datasets,” PyTorch Documentation. [Online]. Available: https://docs.pytorch.org/vision/stable/datasets.html . [Accessed: Jul. 6, 2026].
[3] H. Gharoun, F. Momenifar, F. Chen, and A. H. Gandomi, “Meta-learning Approaches for Few-Shot Learning: A Survey of Recent Advances,” ACM Computing Surveys, vol. 56, no. 12, pp. 294:1–294:41, 2024. doi: 10.1145/3659943.
[4] M. Ali, “Prototypical Networks for Few-Shot Learning in PyTorch,” CodeGenes Blog. [Online]. Available: https://www.codegenes.net/blog/prototypical-networks-for-fewshot-learning-pytorch/ . [Accessed: Jul. 6, 2026].
[5] M. Grandini, E. Bagli, and G. Visani, “Metrics for Multi-Class Classification: An Overview,” arXiv preprint arXiv:2008.05756, 2020. [Online]. Available: https://arxiv.org/abs/2008.05756 . [Accessed: Jul. 6, 2026].
[6] B. M. Lake, “Omniglot: A Dataset for One-Shot Learning,” GitHub repository. [Online]. Available: https://github.com/brendenlake/omniglot . [Accessed: Jul. 6, 2026].
About
Few-Shot Learning with Prototypical Network (project for IMGS789 - Machine Learning for Difficult Data)
Resources
Readme
Activity
Stars
0 stars
Watchers
0 watching
Forks
0 forks
Report repository
Releases
Packages
Contributors
Languages
Footer
(c) 2026 GitHub, Inc.
Footer navigation
*
Terms
*
Privacy
*
Security
*
Status
*
Community
*
Docs
*
Contact
*
Manage cookies
*
Do not share my personal information
You can’t perform that action at this time.
Links found on this page
- Skip to content [direct]
- Sign in [direct]
- GitHub Copilot Write better code with AI [direct]
- GitHub Copilot app Direct agents from issue to merge [direct]
- MCP Registry Integrate external tools [direct]
- Actions Automate any workflow [direct]
- Codespaces Instant dev environments [direct]
- Issues Plan and track work [direct]
- Code Review Manage code changes [direct]
- Code Quality Enforce quality at merge [direct]
- GitHub Advanced Security Find and fix vulnerabilities [direct]
- Code security Secure your code as you build [direct]
- Secret protection Stop leaks before they start [direct]
- Why GitHub [direct]
- Documentation [direct]
- Blog [direct]
- Changelog [direct]
- Marketplace [direct]
- View all features [direct]
- Enterprises [direct]
- Small and medium teams [direct]
- Startups [direct]
- Nonprofits [direct]
- App Modernization [direct]
- DevSecOps [direct]
- DevOps [direct]
- CI/CD [direct]
- View all use cases [direct]
- Healthcare [direct]
- Financial services [direct]
- Manufacturing [direct]
- Government [direct]
- View all industries [direct]
- View all solutions [direct]
- AI [direct]
- Software Development [direct]
- DevOps [direct]
- Security [direct]
- View all topics [direct]
- Customer stories [direct]
- Events & webinars [direct]
- Ebooks & reports [direct]
- Business insights [direct]
- GitHub Skills [direct]
- Customer support [direct]
- Community forum [direct]
- Trust center [direct]
- Partners [direct]
- View all resources [direct]
- GitHub Sponsors Fund open source developers [direct]
- Security Lab [direct]
- Maintainer Community [direct]
- GitHub Stars [direct]
- Archive Program [direct]
- Topics [direct]
- Trending [direct]
- Collections [direct]
- Copilot for Business Enterprise-grade AI features [direct]
- Premium Support Enterprise-grade 24/7 support [direct]
- Pricing [direct]
- Sign up [direct]
- maxbak753 [direct]
- Notifications [direct]
- Issues
0 [direct]
- Pull requests
0 [direct]
- Actions [direct]
- Projects [direct]
- Security and quality
0 [direct]
- Insights [direct]
- Branches [direct]
- Tags [direct]
- 11 Commits [direct]
- images [direct]
- IMGS 789 Project Paper.pdf [direct]
- IMGS789_Project.py [direct]
- README.md [direct]
- https://www.ibm.com/think/topics/few-shot-learning [direct]
- https://docs.pytorch.org/vision/stable/datasets.html [direct]
- https://www.codegenes.net/blog/prototypical-networks-for-fewshot-learning-pytorch/ [direct]
- https://arxiv.org/abs/2008.05756 [direct]