Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the useage of self.count #18

Open
TAY-985 opened this issue Nov 13, 2021 · 3 comments
Open

the useage of self.count #18

TAY-985 opened this issue Nov 13, 2021 · 3 comments

Comments

@TAY-985
Copy link

TAY-985 commented Nov 13, 2021

hello,
in train.py and test() function , they all call the function save_results() , i can not understand self.count very well . What is the role of self.count ?What to use it for?thanks for your answer

1636772132(1)

1636772167(1)

@JonghwanMun
Copy link
Owner

The class "Accumulator" collects the results (e.g., [email protected]) of individual instances and return their averaged value.
So, value means score of metric while count denotes the number of instances (or the number of iterations).
Therefore, when calling add function, the count is set to 1.

Please refer the get_average function in src/utils/accumulator.py file.

@TAY-985
Copy link
Author

TAY-985 commented Nov 13, 2021

but self.counter[k].add(v/nb,1); in v/nb ,average operation has been performed。in my debugging,while in each net testing , i found self.count=1;so it's just return v/nb when calling get_average function?
1636793726(1)
1636793752(1)
1636793792(1)
1636793824(1)

@JonghwanMun
Copy link
Owner

At each iteration of test time, the value (i.e., score) is computed as averaged one for the batch (\i.e., v/nb) and count is added by 1 for the iteration.
Then, after processing all the iterations, the values are divided by the number of iterations (i.e. self.count).

For example, consider three iterations with values of [3,4,5] (=v/nb).
At first iteration, self.value = 3 / self.count = 1.
At second iteration, self.value = 7 (=3+4) / self.count = 2 (=1+1).
At third iteration, self.value = 12 (=3+4+5) / self.count = 3 (=1+1+1).
Finally, get_average function returns 4 (=12 / 3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants