Closed JoeyChallita closed 1 year ago
Hello, I've not found the cos similarity distance inside the code like you. You have closed the issue, can you share the answer ?
Hello Theo, it has been some time since I've worked on this but I'll try to help you as much as I can. If I remember correctly, the code doesn't include the cosine simularity at all. In fact, the memory is updated implicitly through the tr_optimizer in the training loop. So the parameter is updated based on MSE loss plus the EntropyLossEncap which has nothing to do with cosine similarity.
Personal note: I found this model to be useless for my task and the paper misleading. In most real case anomaly detection cases, you would have a classification model that can classify multiple classes and you'll be trying to detect an anomaly (a sample belonging to unseen classes). However, in this code repo (and its paper) they tested their model in the opposite direction. They trained the classification model on one class only , and then treated all other classes as anomalies. Thus the memory module can only hold one class ( one digit in MNIST for example) and push all other classes to it.
I cannot seem to find the part where the memory content is updated based on cosine simularities. It seems weird that the self.weight is updated through the reset_parameters and nothing else. Is this part omitted from your code or what?