{"id":20977055,"url":"https://github.com/githubharald/analyze_pooling","last_synced_at":"2025-06-30T10:35:11.032Z","repository":{"id":107433302,"uuid":"516498322","full_name":"githubharald/analyze_pooling","owner":"githubharald","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-21T19:40:04.000Z","size":144,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T06:13:48.863Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://harald-scheidl.medium.com/d2f5a7866135","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/githubharald.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-21T19:29:58.000Z","updated_at":"2022-07-21T19:52:25.000Z","dependencies_parsed_at":"2023-05-17T11:30:39.315Z","dependency_job_id":null,"html_url":"https://github.com/githubharald/analyze_pooling","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubharald%2Fanalyze_pooling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubharald%2Fanalyze_pooling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubharald%2Fanalyze_pooling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/githubharald%2Fanalyze_pooling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/githubharald","download_url":"https://codeload.github.com/githubharald/analyze_pooling/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243381495,"owners_count":20281978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T04:57:10.412Z","updated_at":"2025-03-13T09:38:47.519Z","avatar_url":"https://github.com/githubharald.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Analyze pooling layers\n\nThis code allows **analyzing** the **effect** of the **pooling layers** in a **CNN**.\nIt implements a simple CNN model trained to distinguish between filled rectangles (class 0) and circles (class 1).\nThe model takes a 224x224 image as input and outputs a value between 0 and 1.\n\n![img](doc/inference.png)\n\nPooling layers cause the model to be shift variant: \nshifting the input image by 1px causes the output to be different, even though CNNs are often said to be shift invariant.\n\n\n\n## Getting started\n\nAnalyze the effect of the single pooling layer in the pre-trained network:\n* Go to the folder `src/`\n* Then, execute ```python main.py --mode analyze --num_pooling_layers 1```.\n\nThis command shifts an input shape (rectangle, class 0) to be classified all around the input image and then records the prediction (should be close to 0 because of predicting class 0) for all the tested image locations. The output should look as follows:\n\n![img](doc/analysis.png)\n\nAs can be seen, depending on the position of the shape in the input image the output slightly differs. This shows that CNNs with pooling layers are not shift invariant.\n\n\n## Usage\nGeneral usage:\n```python main.py --mode {train,infer,analyze} --num_pooling_layers {0,1,2}```.\n\nParameters:\n* mode: first, train the model, then, you can either infer a few samples or analyze the effect of the pooling layers\n* num_pooling_layers: number of pooling layers in the model, either 0, 1 or 2\n\nExample to train the model:\n```python main.py --mode train --num_pooling_layers 1```.\n\nExample to infer a few samples with the trained the model:\n```python main.py --mode infer --num_pooling_layers 1```.\n\n\n## More information\nThis [article](https://harald-scheidl.medium.com/d2f5a7866135) discusses the effect and shows suggestions on how to reduce it.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithubharald%2Fanalyze_pooling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithubharald%2Fanalyze_pooling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithubharald%2Fanalyze_pooling/lists"}