Coder Social home page Coder Social logo

khurramjaved96 / incremental-learning Goto Github PK

View Code? Open in Web Editor NEW
106.0 8.0 24.0 2.21 MB

Pytorch implementation of ACCV18 paper "Revisiting Distillation and Incremental Classifier Learning."

Python 100.00%
machine-learning convolutional-neural-networks pytorch incremental-learning distillation paper-implementations

incremental-learning's People

Contributors

haseebs avatar khurramjaved96 avatar paraacha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

incremental-learning's Issues

pop_val = self.all_classes.pop() IndexError: pop from empty list

Hi, I added custom dataset like below:

def pil_loader(path):
    # open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/issues/835)
    with open(path, 'rb') as f:
        img = Image.open(f)
        img = img.resize((32,32))
        img = img.convert('RGB')
        return img

class GEO(Dataset):
    '''
    :param train_path: /media/gaoya/disk/Applications/pytorch/Incremental Learning/train_dataset
    :param test_path /media/gaoya/disk/Applications/pytorch/Incremental Learning/test_dataset
    '''
    def __init__(self,train_path, test_path):
        super().__init__(classes=5, name="GEO", labels_per_class_train=500, labels_per_class_test=100)

        imgs = numpy.array([])
        self.train_transform = transforms.Compose([
            transforms.Resize(32),
            transforms.RandomHorizontalFlip(),
            transforms.ToTensor(),
            transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
             ])

        self.test_transform = transforms.Compose([
            transforms.Resize(32),
            transforms.ToTensor(),
            transforms.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
             ])

        self.train_data = datasets.ImageFolder(root=train_path, 
                                                transform=self.train_transform,
                                                loader=pil_loader)

        imgs = numpy.array([self.train_transform(pil_loader(path[0])).numpy().transpose(2,1,0) for path in self.train_data.imgs])
        # img_temp = imgs[0]
        # for k in range(1, len(imgs)):
        #     img_temp = numpy.stack((img_temp, imgs[k]))
        
        self.train_imgs = imgs
        self.train_targets = self.train_data.targets

        self.test_data = datasets.ImageFolder(root=test_path, 
                                                transform=self.test_transform,
                                                loader=pil_loader)

        self.test_imgs = numpy.array([self.test_transform(pil_loader(path[0])).numpy().transpose(2,1,0) for path in self.test_data.imgs])
        self.test_targets = self.test_data.targets

and I also have changed the code about dataset_loader( like data is dataset.train_imgs, labels is dataset.train_targets)

When I reran the file, I got error:

Traceback (most recent call last):
  File "run_experiment.py", line 224, in <module>
    my_trainer.increment_classes(class_group)
  File "H:\MachineLearning\incremental-learning-autoencoders\trainer\trainer.py", line 78, in increment_classes
    pop_val = self.all_classes.pop()
IndexError: pop from empty list

Can you tell me what's wrong with the code? My custom datasets have 5 classes (traing set is ((8476, 32, 32, 3), testing set is (1021, 32, 32, 3))

How to build a imbalanced dataset based on your code?

First, thanks so much for your work. In your code, we have to specify the argument "labels_per_class_test", but I have a imbalanced dataset, which means that the number of labels for each class is different, so what should I do?

Correction in the code

hi @khurramjaved96
There should be a small change in your code. In the trainer.py file, in the distillation loss section, the previous model giving features after passing through the softmax while the current model giving features by passing through log softmax. How we can compute the KL divergence between these two using the F.kl function?
Please check this.
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.