{
  "id": 200876,
  "title": "Newbie question: Can not load efficient net weights",
  "url": "/competitions/cassava-leaf-disease-classification/discussion/200876",
  "author_name": "",
  "post_date": "2020-12-02T08:17:45.317879Z",
  "votes": 3,
  "comment_count": 5,
  "views": 0,
  "content": "<p>I am unable to load the noisy student weights for the efficient net in Keras. <br>\nThe error is that I try to load a model with 130 layers to a model with 131.<br>\nMy code is the following:</p>\n<pre><code>   conv_base = EfficientNetB0(include_top = False, weights = \"imagenet\",\n                               input_shape = (TARGET_SIZE, TARGET_SIZE, 3))\n    conv_base.load_weights(\"../input/efficientnet-keras-noisystudent-weights-b0b7/efficientnet-b0_noisy-student_notop.h5\")\n</code></pre>",
  "messages": [
    {
      "id": "1099268",
      "postDate": "12/02/2020 08:17:45",
      "content": "<p>I am unable to load the noisy student weights for the efficient net in Keras. <br>\nThe error is that I try to load a model with 130 layers to a model with 131.<br>\nMy code is the following:</p>\n<pre><code>   conv_base = EfficientNetB0(include_top = False, weights = \"imagenet\",\n                               input_shape = (TARGET_SIZE, TARGET_SIZE, 3))\n    conv_base.load_weights(\"../input/efficientnet-keras-noisystudent-weights-b0b7/efficientnet-b0_noisy-student_notop.h5\")\n</code></pre>",
      "rawMarkdown": "I am unable to load the noisy student weights for the efficient net in Keras. \nThe error is that I try to load a model with 130 layers to a model with 131.\nMy code is the following:\n```\n   conv_base = EfficientNetB0(include_top = False, weights = \"imagenet\",\n                               input_shape = (TARGET_SIZE, TARGET_SIZE, 3))\n    conv_base.load_weights(\"../input/efficientnet-keras-noisystudent-weights-b0b7/efficientnet-b0_noisy-student_notop.h5\")\n```",
      "votes": null
    },
    {
      "id": "1099274",
      "postDate": "12/02/2020 08:23:10",
      "content": "<p>I have similar problem, but the model I used is not the same as yours. I used Vision Transformer. After I added the pre-trained weight path in the model settings, the problem was solved.</p>",
      "rawMarkdown": "I have similar problem, but the model I used is not the same as yours. I used Vision Transformer. After I added the pre-trained weight path in the model settings, the problem was solved.",
      "votes": null
    },
    {
      "id": "1099287",
      "postDate": "12/02/2020 08:33:50",
      "content": "<p>How can I do that? Is there any function other than load_weights?</p>",
      "rawMarkdown": "How can I do that? Is there any function other than load_weights?",
      "votes": null
    },
    {
      "id": "1099297",
      "postDate": "12/02/2020 08:44:06",
      "content": "<p>For the extra layer, you may need to modify the code inside the model to reduce one layer or use load_ Skip unmatched weights in weights, load_ Weights have this parameter, click open function to see</p>",
      "rawMarkdown": "For the extra layer, you may need to modify the code inside the model to reduce one layer or use load_ Skip unmatched weights in weights, load_ Weights have this parameter, click open function to see",
      "votes": null
    },
    {
      "id": "1099330",
      "postDate": "12/02/2020 09:23:35",
      "content": "<p>I found that I was using wrong weights file…<br>\nUsing the weights from \"Keras Pretrained Models\" solved the problems.</p>",
      "rawMarkdown": "I found that I was using wrong weights file...\nUsing the weights from \"Keras Pretrained Models\" solved the problems.",
      "votes": null
    },
    {
      "id": "1116261",
      "postDate": "12/17/2020 02:19:23",
      "content": "<p>I had the same problem and solved it by using load_weights(weight, by_name=True, skip_mismatch = True)</p>",
      "rawMarkdown": "I had the same problem and solved it by using load_weights(weight, by_name=True, skip_mismatch = True)",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1099274,
      "author_name": "zhangeng",
      "author_url": "",
      "post_date": "12/02/2020 08:23:10",
      "content": "<p>I have similar problem, but the model I used is not the same as yours. I used Vision Transformer. After I added the pre-trained weight path in the model settings, the problem was solved.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1099287,
      "author_name": "npan1990",
      "author_url": "",
      "post_date": "12/02/2020 08:33:50",
      "content": "<p>How can I do that? Is there any function other than load_weights?</p>",
      "votes": null,
      "replies": [
        {
          "id": 1099297,
          "author_name": "zhangeng",
          "author_url": "",
          "post_date": "12/02/2020 08:44:06",
          "content": "<p>For the extra layer, you may need to modify the code inside the model to reduce one layer or use load_ Skip unmatched weights in weights, load_ Weights have this parameter, click open function to see</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1099330,
      "author_name": "npan1990",
      "author_url": "",
      "post_date": "12/02/2020 09:23:35",
      "content": "<p>I found that I was using wrong weights file…<br>\nUsing the weights from \"Keras Pretrained Models\" solved the problems.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 1116261,
      "author_name": "luqing2",
      "author_url": "",
      "post_date": "12/17/2020 02:19:23",
      "content": "<p>I had the same problem and solved it by using load_weights(weight, by_name=True, skip_mismatch = True)</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1099268": "I am unable to load the noisy student weights for the efficient net in Keras. \nThe error is that I try to load a model with 130 layers to a model with 131.\nMy code is the following:\n```\n   conv_base = EfficientNetB0(include_top = False, weights = \"imagenet\",\n                               input_shape = (TARGET_SIZE, TARGET_SIZE, 3))\n    conv_base.load_weights(\"../input/efficientnet-keras-noisystudent-weights-b0b7/efficientnet-b0_noisy-student_notop.h5\")\n```",
    "1099274": "I have similar problem, but the model I used is not the same as yours. I used Vision Transformer. After I added the pre-trained weight path in the model settings, the problem was solved.",
    "1099287": "How can I do that? Is there any function other than load_weights?",
    "1099297": "For the extra layer, you may need to modify the code inside the model to reduce one layer or use load_ Skip unmatched weights in weights, load_ Weights have this parameter, click open function to see",
    "1099330": "I found that I was using wrong weights file...\nUsing the weights from \"Keras Pretrained Models\" solved the problems.",
    "1116261": "I had the same problem and solved it by using load_weights(weight, by_name=True, skip_mismatch = True)"
  },
  "source": "meta"
}