ej0cl6 / deep-active-learning

Deep Active Learning
MIT License
783 stars 182 forks source link

Confusion about network constructor #9

Closed UnpureRationalist closed 2 years ago

UnpureRationalist commented 2 years ago

It seems that each time I call the function Net.train(self, data), a new network with new initial parameters will be constructed.(As the code shown in https://github.com/ej0cl6/deep-active-learning/blob/563723356421bc7d82e3496700265992cf7fcb06/nets.py#L17) As I know, the network's parameters are trained continuously after each query in Active Learning settings, instead of constructing a new network and training from scratch. So the constructor of class Net maybe like:

class Net:
    def __init__(self, net, params, device):
        self.net = net
        self.params = params
        self.device = device
        self.clf = self.net().to(self.device)    # add

    def train(self, data):
        n_epoch = self.params['n_epoch']
        # self.clf = self.net().to(self.device)    # remove
        self.clf.train()
        optimizer = optim.SGD(self.clf.parameters(), **self.params['optimizer_args'])

I'm a beginner in Deep Active Learning, so the content above maybe just my misunderstanding about Deep Active Learning. Looking forward to your reply. Thank you.

ej0cl6 commented 2 years ago

I personally think either way is fine, re-training a new model or continue fine-tuning the previous one. They have their own pros and cons. I choose to re-train a new model for balancing the importance of every labeled instance.

You can modify it according to your need.

UnpureRationalist commented 2 years ago

Thank you for your reply. I have understood the purpose of your current implement.

I use DAL in computer vision, the datasets are large in most cases and the training cost is expensive, so I asked the question. I will rethink the pros and cons of the two implements and make final decision.

Finally, thank you for your efforts in this repository.