Skip to content
A novel method for few shot learning
Jupyter Notebook Python
Branch: master
Clone or download
Latest commit 42430c7 Aug 8, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Aug 1, 2019
LICENSE Initial commit Aug 1, 2019
README.md added blog link Aug 8, 2019
__init__.py Prototypical Network code Aug 1, 2019
floyd.yml Renamed floydhub.yml to floyd.yml Aug 1, 2019
helper2.png Prototypical Network code Aug 1, 2019
img1.png Prototypical Network code Aug 1, 2019
img2.png
main.py Prototypical Network code Aug 1, 2019
omniglot.jpg Prototypical Network code Aug 1, 2019
preprocessing.py Prototypical Network code Aug 1, 2019
protonet.pt Prototypical Network code Aug 1, 2019
prototypical-net.ipynb Prototypical Network code Aug 1, 2019
prototypicalNet.py Prototypical Network code Aug 1, 2019
requirements.txt Prototypical Network code Aug 1, 2019

README.md

Prototypical Networks

Run on FloydHub

Artificial Intelligence is the new electricity - Andrew NG

The change occurred in our life after the expeditious growth in AI and deep learning, in particular, is a solid example of this. The research is booming at unprecedented speed and lives of thousands of people have been improved. If AI is the new electricity then definitely data is the new coal. But recently we’ve seen hazardous depletion in the amount of coal in our environment. This resulted in the development of new technologies which needed a fraction of coal or even no coal at all. Similarly, there are many applications in artificial intelligence where we only have meager data or even no data at all. Hence, we need new techniques to perform well in them. Such problems resulted in the growth of a very popular field, the field of N-shot learning.

To know about it more, go to my blog at N-Shot Learning: Learning More with Less Data.

To check out how this works, go to my notebook at kaggle

Basic Idea behind prototypical Network How prototypical Network works

Dataset

Omniglot Dataset

The network was trained on the Omniglot dataset. The Omniglot data set is designed for developing more human-like learning algorithms. It contains 1623 different handwritten characters from 50 different alphabets.

How to use the Module

First install all the necessary dependencies

pip3 install -r requirements.txt
  • Download the dataset and save it in the directory
  • To train, test and save your own model first import the PrototypicalNet module
from prototypicalNet import PrototypicalNet, train_step, test_step, load_weights
# Initializing prototypical net
protonet = PrototypicalNet(use_gpu)

You can use a pretrained model

# Using Pretrained Model
protonet = load_weights('./protonet.pt', protonet, use_gpu)

Or simply train one by yourself

# Set training iterations and display period
    num_episode = 16000
    frame_size = 1000
    trainx = trainx.permute(0, 3, 1, 2)
    testx = testx.permute(0, 3, 1, 2)

    # Initializing prototypical net
    protonet = PrototypicalNet(use_gpu)
    # Training loop
    frame_loss = 0
    frame_acc = 0
    for i in range(num_episode):
        loss, acc = train_step(protonet, trainx, trainy, 5, 60, 5)
        frame_loss += loss.data
        frame_acc += acc.data
        if((i+1) % frame_size == 0):
            print("Frame Number:", ((i+1) // frame_size), 'Frame Loss: ', frame_loss.data.cpu().numpy().tolist() /
                  frame_size, 'Frame Accuracy:', (frame_acc.data.cpu().numpy().tolist() * 100) / frame_size)
            frame_loss = 0
            frame_acc = 0

To know more checkout this

Want to use a customized model?

No worries, simply download the code and make suitable changes here

Project Manager

Heet Sankesara

You can’t perform that action at this time.