{
  "id": 188671,
  "title": "Check this architecture [Transfer Learning ~ 99.95% Accuracy]",
  "url": "/competitions/digit-recognizer/discussion/188671",
  "author_name": "PyBear",
  "post_date": "2020-10-04T16:13:55.147000",
  "votes": 0,
  "comment_count": 1,
  "views": null,
  "content": "<p>I tried to use the built-in models in keras, and I found this one powerful.<br>\nResnets are very good when you want to train a deeper net. Because they prevent your algorithm from facing vanishing or exploding gradients. </p>\n<p>Change the last layers if you want; you may get even better results.</p>\n<p>pretrained_model = keras.applications.resnet50.ResNet50 (<br>\n                                       input_shape=(n_h, n_w, n_c),<br>\n                                       include_top=False, weights='imagenet' )</p>\n<p>model = keras.Sequential([<br>\n                     pretrained_model,<br>\n                     keras.layers.Flatten(),<br>\n                     keras.layers.Dense(units=50, activation='relu'),<br>\n                     keras.layers.Dense(units=10, activation='softmax')<br>\n])</p>\n<p>I hope this was helpful. If you have a better idea, please do share with us.</p>",
  "messages": [
    {
      "id": 1720640,
      "postDate": "2022-03-13T01:51:38.833Z",
      "content": "<p>Thank you for the above. Could you clarify what n_h, n_w, n_c ultimately stood for in your analysis? (as I am facing an issue with (28,28,1) - trying EfficientNet)</p>\n<p>[edit]<br>\nAfter some investigation and the help of this really good article: <a href=\"https://www.kaggle.com/saumandas/intro-to-transfer-learning-with-mnist\" target=\"_blank\">https://www.kaggle.com/saumandas/intro-to-transfer-learning-with-mnist</a><br>\nIt seems that there is an input size minimum of 32x32. I also converted to RGB in order to get 3 channels (vs 1 since mnist is greyscale).  Hopefully those were correct assumptions. The model works now.</p>",
      "rawMarkdown": "Thank you for the above. Could you clarify what n_h, n_w, n_c ultimately stood for in your analysis? (as I am facing an issue with (28,28,1) - trying EfficientNet)\n\n[edit]\nAfter some investigation and the help of this really good article: https://www.kaggle.com/saumandas/intro-to-transfer-learning-with-mnist\nIt seems that there is an input size minimum of 32x32. I also converted to RGB in order to get 3 channels (vs 1 since mnist is greyscale).  Hopefully those were correct assumptions. The model works now."
    },
    {
      "id": 1037116,
      "postDate": "2020-10-04T16:13:55.147Z",
      "content": "<p>I tried to use the built-in models in keras, and I found this one powerful.<br>\nResnets are very good when you want to train a deeper net. Because they prevent your algorithm from facing vanishing or exploding gradients. </p>\n<p>Change the last layers if you want; you may get even better results.</p>\n<p>pretrained_model = keras.applications.resnet50.ResNet50 (<br>\n                                       input_shape=(n_h, n_w, n_c),<br>\n                                       include_top=False, weights='imagenet' )</p>\n<p>model = keras.Sequential([<br>\n                     pretrained_model,<br>\n                     keras.layers.Flatten(),<br>\n                     keras.layers.Dense(units=50, activation='relu'),<br>\n                     keras.layers.Dense(units=10, activation='softmax')<br>\n])</p>\n<p>I hope this was helpful. If you have a better idea, please do share with us.</p>",
      "rawMarkdown": "I tried to use the built-in models in keras, and I found this one powerful.\nResnets are very good when you want to train a deeper net. Because they prevent your algorithm from facing vanishing or exploding gradients. \n\nChange the last layers if you want; you may get even better results.\n\npretrained_model = keras.applications.resnet50.ResNet50 (\n                                       input_shape=(n_h, n_w, n_c),\n                                       include_top=False, weights='imagenet' )\n\nmodel = keras.Sequential([\n                     pretrained_model,\n                     keras.layers.Flatten(),\n                     keras.layers.Dense(units=50, activation='relu'),\n                     keras.layers.Dense(units=10, activation='softmax')\n])\n\nI hope this was helpful. If you have a better idea, please do share with us."
    }
  ],
  "comments": [
    {
      "id": 1720640,
      "author_name": "Mariem Ayadi",
      "author_url": "",
      "post_date": "2022-03-13T01:51:38.833000",
      "content": "<p>Thank you for the above. Could you clarify what n_h, n_w, n_c ultimately stood for in your analysis? (as I am facing an issue with (28,28,1) - trying EfficientNet)</p>\n<p>[edit]<br>\nAfter some investigation and the help of this really good article: <a href=\"https://www.kaggle.com/saumandas/intro-to-transfer-learning-with-mnist\" target=\"_blank\">https://www.kaggle.com/saumandas/intro-to-transfer-learning-with-mnist</a><br>\nIt seems that there is an input size minimum of 32x32. I also converted to RGB in order to get 3 channels (vs 1 since mnist is greyscale).  Hopefully those were correct assumptions. The model works now.</p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1720640": "Thank you for the above. Could you clarify what n_h, n_w, n_c ultimately stood for in your analysis? (as I am facing an issue with (28,28,1) - trying EfficientNet)\n\n[edit]\nAfter some investigation and the help of this really good article: https://www.kaggle.com/saumandas/intro-to-transfer-learning-with-mnist\nIt seems that there is an input size minimum of 32x32. I also converted to RGB in order to get 3 channels (vs 1 since mnist is greyscale).  Hopefully those were correct assumptions. The model works now.",
    "1037116": "I tried to use the built-in models in keras, and I found this one powerful.\nResnets are very good when you want to train a deeper net. Because they prevent your algorithm from facing vanishing or exploding gradients. \n\nChange the last layers if you want; you may get even better results.\n\npretrained_model = keras.applications.resnet50.ResNet50 (\n                                       input_shape=(n_h, n_w, n_c),\n                                       include_top=False, weights='imagenet' )\n\nmodel = keras.Sequential([\n                     pretrained_model,\n                     keras.layers.Flatten(),\n                     keras.layers.Dense(units=50, activation='relu'),\n                     keras.layers.Dense(units=10, activation='softmax')\n])\n\nI hope this was helpful. If you have a better idea, please do share with us."
  }
}