lightly-ai / lightly

A python library for self-supervised learning on images.
https://docs.lightly.ai/self-supervised-learning/
MIT License
3.09k stars 264 forks source link

Moco Memory bank example is error #1502

Closed ramdhan1989 closed 7 months ago

ramdhan1989 commented 7 months ago

Hi, I follow turotial for MoCo but I got this error `--------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_18352\297540911.py in 29 model.to(device) 30 ---> 31 criterion = NTXentLoss(memory_bank_size=(4096, 128)) 32 optimizer = torch.optim.SGD(model.parameters(), lr=0.06)

~\anaconda3\envs\myenv\lib\site-packages\lightly\loss\ntx_ent_loss.py in init(self, temperature, memory_bank_size, gather_distributed) 56 memory_bank_size: int = 0, 57 gather_distributed: bool = False): ---> 58 super(NTXentLoss, self).init(size=memory_bank_size) 59 self.temperature = temperature 60 self.gather_distributed = gather_distributed

~\anaconda3\envs\myenv\lib\site-packages\lightly\loss\memory_bank.py in init(self, size) 42 super(MemoryBankModule, self).init() 43 ---> 44 if size < 0: 45 msg = f'Illegal memory bank size {size}, must be non-negative.' 46 raise ValueError(msg)

TypeError: '<' not supported between instances of 'tuple' and `'int'``

guarin commented 7 months ago

Hi! Which version of lightly are you using?

The memory_bank_size argument supports tuple arguments like (4096, 128) since v1.4.25. If you have an older version, please use memory_bank_size=4096 instead.

ramdhan1989 commented 7 months ago

well noted, thank you

guarin commented 7 months ago

Closing this for now, let me know if you encounter any other issues :)