{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/sega-semantic-guided-attention-on-visual","title":"SEGA: Semantic Guided Attention on Visual Prototype for Few-Shot Learning","arxiv_id":"2111.04316","date":"2021-11-08","proceeding":null,"authors":["Fengyuan Yang","Ruiping Wang","Xilin Chen"],"abstract":"Teaching machines to recognize a new category based on few training samples especially only one remains challenging owing to the incomprehensive understanding of the novel category caused by the lack of data. However, human can learn new classes quickly even given few samples since human can tell what discriminative features should be focused on about each category based on both the visual and semantic prior knowledge. To better utilize those prior knowledge, we propose the SEmantic Guided Attention (SEGA) mechanism where the semantic knowledge is used to guide the visual perception in a top-down manner about what visual features should be paid attention to when distinguishing a category from the others. As a result, the embedding of the novel class even with few samples can be more discriminative. Concretely, a feature extractor is trained to embed few images of each novel class into a visual prototype with the help of transferring visual prior knowledge from base classes. Then we learn a network that maps semantic knowledge to category-specific attention vectors which will be used to perform feature selection to enhance the visual prototypes. Extensive experiments on miniImageNet, tieredImageNet, CIFAR-FS, and CUB indicate that our semantic guided attention realizes anticipated function and outperforms state-of-the-art results.","url_abs":"https://arxiv.org/abs/2111.04316v1","url_pdf":"https://arxiv.org/pdf/2111.04316v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"sega-semantic-guided-attention-on-visual","repo_url":"https://github.com/martayang/sega","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"few-shot-learning","task_name":"Few-Shot Learning"},{"task_slug":"feature-selection","task_name":"feature selection"}],"methods":[{"method_slug":"feature-selection","method_name":"Feature Selection"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2111.04316","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2111.04316"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/martayang/sega","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_fixture":1,"ran_draft_wrong":2,"unverified":5},"by_repo_kind":{"official":{"samples":8,"ran":3,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"6134727f9d286287","entry":"computeGramMatrix","repo":"martayang/sega","repo_kind":"official","path":"models/classification_heads.py","file_url":"https://github.com/martayang/sega/blob/HEAD/models/classification_heads.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6134727f9d286287"}},{"code_sha256_prefix":"fac5364e2f53c6db","entry":"conv3x3","repo":"martayang/sega","repo_kind":"official","path":"models/ResNet12_embedding.py","file_url":"https://github.com/martayang/sega/blob/HEAD/models/ResNet12_embedding.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fac5364e2f53c6db"}},{"code_sha256_prefix":"7c64c35be7f02395","entry":"one_hot","repo":"martayang/sega","repo_kind":"official","path":"models/classification_heads.py","file_url":"https://github.com/martayang/sega/blob/HEAD/models/classification_heads.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7c64c35be7f02395"}},{"code_sha256_prefix":"f6837706155e074e","entry":"CosineClassfier","repo":"martayang/sega","repo_kind":"official","path":"models/classification_heads.py","file_url":"https://github.com/martayang/sega/blob/HEAD/models/classification_heads.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f6837706155e074e"}},{"code_sha256_prefix":"a4fe8a5c6d9aaebd","entry":"conv4","repo":"martayang/sega","repo_kind":"official","path":"models/ConvNet_embedding.py","file_url":"https://github.com/martayang/sega/blob/HEAD/models/ConvNet_embedding.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a4fe8a5c6d9aaebd"}},{"code_sha256_prefix":"fb61241b42c06d73","entry":"count_accuracy","repo":"martayang/sega","repo_kind":"official","path":"utils.py","file_url":"https://github.com/martayang/sega/blob/HEAD/utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fb61241b42c06d73"}},{"code_sha256_prefix":"50e8bcc64ea44002","entry":"get_dataset","repo":"martayang/sega","repo_kind":"official","path":"testcode.py","file_url":"https://github.com/martayang/sega/blob/HEAD/testcode.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"50e8bcc64ea44002"}},{"code_sha256_prefix":"31f209be17e127f2","entry":"get_dataset","repo":"martayang/sega","repo_kind":"official","path":"traincode.py","file_url":"https://github.com/martayang/sega/blob/HEAD/traincode.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"31f209be17e127f2"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}