{"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/cr-sam-curvature-regularized-sharpness-aware","title":"CR-SAM: Curvature Regularized Sharpness-Aware Minimization","arxiv_id":"2312.13555","date":"2023-12-21","proceeding":null,"authors":["Tao Wu","Tie Luo","Donald C. Wunsch"],"abstract":"The capacity to generalize to future unseen data stands as one of the utmost crucial attributes of deep neural networks. Sharpness-Aware Minimization (SAM) aims to enhance the generalizability by minimizing worst-case loss using one-step gradient ascent as an approximation. However, as training progresses, the non-linearity of the loss landscape increases, rendering one-step gradient ascent less effective. On the other hand, multi-step gradient ascent will incur higher training cost. In this paper, we introduce a normalized Hessian trace to accurately measure the curvature of loss landscape on {\\em both} training and test sets. In particular, to counter excessive non-linearity of loss landscape, we propose Curvature Regularized SAM (CR-SAM), integrating the normalized Hessian trace as a SAM regularizer. Additionally, we present an efficient way to compute the trace via finite differences with parallelism. Our theoretical analysis based on PAC-Bayes bounds establishes the regularizer's efficacy in reducing generalization error. Empirical evaluation on CIFAR and ImageNet datasets shows that CR-SAM consistently enhances classification performance for ResNet and Vision Transformer (ViT) models across various datasets. Our code is available at https://github.com/TrustAIoT/CR-SAM.","url_abs":"https://arxiv.org/abs/2312.13555v2","url_pdf":"https://arxiv.org/pdf/2312.13555v2.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":"cr-sam-curvature-regularized-sharpness-aware","repo_url":"https://github.com/trustaiot/cr-sam","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[{"method_slug":"1x1-convolution","method_name":"1x1 Convolution"},{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"average-pooling","method_name":"Average Pooling"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"batch-normalization","method_name":"Batch Normalization"},{"method_slug":"bottleneck-residual-block","method_name":"Bottleneck Residual Block"},{"method_slug":"convolution","method_name":"Convolution"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"global-average-pooling","method_name":"Global Average Pooling"},{"method_slug":"kaiming-initialization","method_name":"Kaiming Initialization"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"max-pooling","method_name":"Max Pooling"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"relu","method_name":"ReLU"},{"method_slug":"residual-block","method_name":"Residual Block"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"sam","method_name":"SAM"},{"method_slug":"sharpness-aware-minimization","method_name":"Sharpness-Aware Minimization"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"transformer","method_name":"Transformer"},{"method_slug":"vision-transformer","method_name":"Vision Transformer"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2312.13555","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2312.13555"}},"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/trustaiot/cr-sam","reach":{"status":"ok"}}],"summary":{"ran":5,"ran_fixture":1,"ran_draft_wrong":1,"unverified":4},"by_repo_kind":{"official":{"samples":11,"ran":7,"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":11,"samples":[{"code_sha256_prefix":"1b6b90e1a60dc199","entry":"WRN28_10","repo":"trustaiot/cr-sam","repo_kind":"official","path":"models/wrn_28_10.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/models/wrn_28_10.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1b6b90e1a60dc199"}},{"code_sha256_prefix":"f019eaa51fe8d809","entry":"grad_norm","repo":"trustaiot/cr-sam","repo_kind":"official","path":"metrics/metrics.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/metrics/metrics.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f019eaa51fe8d809"}},{"code_sha256_prefix":"2530e16bed546c6a","entry":"group_add","repo":"trustaiot/cr-sam","repo_kind":"official","path":"metrics/hessian.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/metrics/hessian.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2530e16bed546c6a"}},{"code_sha256_prefix":"c35e05b48a3f5b73","entry":"group_product","repo":"trustaiot/cr-sam","repo_kind":"official","path":"metrics/hessian.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/metrics/hessian.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c35e05b48a3f5b73"}},{"code_sha256_prefix":"0e4f4ed57a87f93d","entry":"normalization","repo":"trustaiot/cr-sam","repo_kind":"official","path":"metrics/hessian.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/metrics/hessian.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0e4f4ed57a87f93d"}},{"code_sha256_prefix":"53613a740588d619","entry":"shear_x","repo":"trustaiot/cr-sam","repo_kind":"official","path":"utils/autoaugment.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/utils/autoaugment.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"53613a740588d619"}},{"code_sha256_prefix":"3e773c6c5bc796d4","entry":"transform_matrix_offset_center","repo":"trustaiot/cr-sam","repo_kind":"official","path":"utils/autoaugment.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/utils/autoaugment.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3e773c6c5bc796d4"}},{"code_sha256_prefix":"b179c6e8a69a7442","entry":"ResNet18","repo":"trustaiot/cr-sam","repo_kind":"official","path":"models/resnet.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/models/resnet.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b179c6e8a69a7442"}},{"code_sha256_prefix":"9e5e3e4cd9d178d9","entry":"ResNet34","repo":"trustaiot/cr-sam","repo_kind":"official","path":"models/resnet.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/models/resnet.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9e5e3e4cd9d178d9"}},{"code_sha256_prefix":"49cfb2b239af503d","entry":"ResNet50","repo":"trustaiot/cr-sam","repo_kind":"official","path":"models/resnet.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/models/resnet.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"49cfb2b239af503d"}},{"code_sha256_prefix":"c7f01b2cafbe5f80","entry":"apply_policy","repo":"trustaiot/cr-sam","repo_kind":"official","path":"utils/autoaugment.py","file_url":"https://github.com/trustaiot/cr-sam/blob/HEAD/utils/autoaugment.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c7f01b2cafbe5f80"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}