{
  "id": 98194,
  "title": "Kernel getting extremely low accuracy (trained on 150 epochs!)",
  "url": "/competitions/aptos2019-blindness-detection/discussion/98194",
  "author_name": "",
  "post_date": "2019-07-01T22:58:44.972099Z",
  "votes": 1,
  "comment_count": 4,
  "views": 0,
  "content": "<p>I don't know if its because my model isn't complex enough, or I am underfitting (I train on 150 epochs!), but my accuracy seems too low for the model (0.14). I use ImageDataGenerator for augmentation, too. I would be grateful if someone could help me out!</p>\n\n<p>My Kernel: <a href=\"https://www.kaggle.com/arjunrao2000/baseline-keras-model\">https://www.kaggle.com/arjunrao2000/baseline-keras-model</a></p>",
  "messages": [
    {
      "id": "566215",
      "postDate": "07/01/2019 22:58:44",
      "content": "<p>I don't know if its because my model isn't complex enough, or I am underfitting (I train on 150 epochs!), but my accuracy seems too low for the model (0.14). I use ImageDataGenerator for augmentation, too. I would be grateful if someone could help me out!</p>\n\n<p>My Kernel: <a href=\"https://www.kaggle.com/arjunrao2000/baseline-keras-model\">https://www.kaggle.com/arjunrao2000/baseline-keras-model</a></p>",
      "rawMarkdown": "I don't know if its because my model isn't complex enough, or I am underfitting (I train on 150 epochs!), but my accuracy seems too low for the model (0.14). I use ImageDataGenerator for augmentation, too. I would be grateful if someone could help me out!\n\nMy Kernel: [https://www.kaggle.com/arjunrao2000/baseline-keras-model](https://www.kaggle.com/arjunrao2000/baseline-keras-model)",
      "votes": null
    },
    {
      "id": "566331",
      "postDate": "07/02/2019 04:15:21",
      "content": "<p>Your model is not learning anything useful. You have two choices --do more to prevent over-fitting (handling drop-out properly, for example). You could also try to use transfer learning. That is, take a pre-trained model and use it as the first layers of a neural net classifier. Also, make sure that your data augmentations make sense.</p>",
      "rawMarkdown": "Your model is not learning anything useful. You have two choices --do more to prevent over-fitting (handling drop-out properly, for example). You could also try to use transfer learning. That is, take a pre-trained model and use it as the first layers of a neural net classifier. Also, make sure that your data augmentations make sense.",
      "votes": null
    },
    {
      "id": "566449",
      "postDate": "07/02/2019 07:15:48",
      "content": "<p>After glancing your code , I found something unusual : \n<code>python\ntrain_generator = train_datagen.flow_from_dataframe(\n    dataframe = train_df,\n    directory = train_dir,\n    validation_split = 0.2,\n    x_col = 'id_code',\n    y_col = 'diagnosis',\n    target_size = (32,32),\n    class_mode = 'categorical',\n    batch_size = 32,\n    subset = 'training'\n)\n</code>\nSo here you are using categorical target variable implies target is one hot encoded. But when you are creating the model \n<code>python\nmodel.add(Flatten())\nmodel.add(Dense(512,activation = 'relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(5,activation = 'sigmoid'))\n</code>\nI think you should use <code>softmax</code> not <code>sigmoid</code>. Other suggestions are , </p>\n\n<ul>\n<li>you are resizing the images to <code>(32,32)</code> which is very less (because we are given images which are shapes in like 2000's ),  </li>\n<li>as bryan suggested use pretrained models which may boost your accuracy. \n<ul><li>Your kernel got <code>0.14</code> public score and <code>0.14</code> is not accuracy , its cohens kappa. Try to incorporate kappa score on validation in your code. </li></ul></li>\n</ul>\n\n<p>I am not that good with keras , so may be some opinions are wrong. </p>",
      "rawMarkdown": "After glancing your code , I found something unusual : \n```python\ntrain_generator = train_datagen.flow_from_dataframe(\n    dataframe = train_df,\n    directory = train_dir,\n    validation_split = 0.2,\n    x_col = 'id_code',\n    y_col = 'diagnosis',\n    target_size = (32,32),\n    class_mode = 'categorical',\n    batch_size = 32,\n    subset = 'training'\n)\n```\nSo here you are using categorical target variable implies target is one hot encoded. But when you are creating the model \n```python\nmodel.add(Flatten())\nmodel.add(Dense(512,activation = 'relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(5,activation = 'sigmoid'))\n```\nI think you should use `softmax` not `sigmoid`. Other suggestions are , \n\n- you are resizing the images to `(32,32)` which is very less (because we are given images which are shapes in like 2000's ),  \n- as bryan suggested use pretrained models which may boost your accuracy. \n - Your kernel got `0.14` public score and `0.14` is not accuracy , its cohens kappa. Try to incorporate kappa score on validation in your code. \n\n\nI am not that good with keras , so may be some opinions are wrong.",
      "votes": null
    },
    {
      "id": "568789",
      "postDate": "07/05/2019 12:48:40",
      "content": "<p>Thank you so much! Really helpful advice!</p>",
      "rawMarkdown": "Thank you so much! Really helpful advice!",
      "votes": null
    },
    {
      "id": "568790",
      "postDate": "07/05/2019 12:49:10",
      "content": "<p>This is great! I'll definitely try a pre-trained model. Any suggestions for this competition?</p>",
      "rawMarkdown": "This is great! I'll definitely try a pre-trained model. Any suggestions for this competition?",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 566331,
      "author_name": "puremath86",
      "author_url": "",
      "post_date": "07/02/2019 04:15:21",
      "content": "<p>Your model is not learning anything useful. You have two choices --do more to prevent over-fitting (handling drop-out properly, for example). You could also try to use transfer learning. That is, take a pre-trained model and use it as the first layers of a neural net classifier. Also, make sure that your data augmentations make sense.</p>",
      "votes": null,
      "replies": [
        {
          "id": 568790,
          "author_name": "arjunrao2000",
          "author_url": "",
          "post_date": "07/05/2019 12:49:10",
          "content": "<p>This is great! I'll definitely try a pre-trained model. Any suggestions for this competition?</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 566449,
      "author_name": "suchith0312",
      "author_url": "",
      "post_date": "07/02/2019 07:15:48",
      "content": "<p>After glancing your code , I found something unusual : \n<code>python\ntrain_generator = train_datagen.flow_from_dataframe(\n    dataframe = train_df,\n    directory = train_dir,\n    validation_split = 0.2,\n    x_col = 'id_code',\n    y_col = 'diagnosis',\n    target_size = (32,32),\n    class_mode = 'categorical',\n    batch_size = 32,\n    subset = 'training'\n)\n</code>\nSo here you are using categorical target variable implies target is one hot encoded. But when you are creating the model \n<code>python\nmodel.add(Flatten())\nmodel.add(Dense(512,activation = 'relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(5,activation = 'sigmoid'))\n</code>\nI think you should use <code>softmax</code> not <code>sigmoid</code>. Other suggestions are , </p>\n\n<ul>\n<li>you are resizing the images to <code>(32,32)</code> which is very less (because we are given images which are shapes in like 2000's ),  </li>\n<li>as bryan suggested use pretrained models which may boost your accuracy. \n<ul><li>Your kernel got <code>0.14</code> public score and <code>0.14</code> is not accuracy , its cohens kappa. Try to incorporate kappa score on validation in your code. </li></ul></li>\n</ul>\n\n<p>I am not that good with keras , so may be some opinions are wrong. </p>",
      "votes": null,
      "replies": [
        {
          "id": 568789,
          "author_name": "arjunrao2000",
          "author_url": "",
          "post_date": "07/05/2019 12:48:40",
          "content": "<p>Thank you so much! Really helpful advice!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "566215": "I don't know if its because my model isn't complex enough, or I am underfitting (I train on 150 epochs!), but my accuracy seems too low for the model (0.14). I use ImageDataGenerator for augmentation, too. I would be grateful if someone could help me out!\n\nMy Kernel: [https://www.kaggle.com/arjunrao2000/baseline-keras-model](https://www.kaggle.com/arjunrao2000/baseline-keras-model)",
    "566331": "Your model is not learning anything useful. You have two choices --do more to prevent over-fitting (handling drop-out properly, for example). You could also try to use transfer learning. That is, take a pre-trained model and use it as the first layers of a neural net classifier. Also, make sure that your data augmentations make sense.",
    "566449": "After glancing your code , I found something unusual : \n```python\ntrain_generator = train_datagen.flow_from_dataframe(\n    dataframe = train_df,\n    directory = train_dir,\n    validation_split = 0.2,\n    x_col = 'id_code',\n    y_col = 'diagnosis',\n    target_size = (32,32),\n    class_mode = 'categorical',\n    batch_size = 32,\n    subset = 'training'\n)\n```\nSo here you are using categorical target variable implies target is one hot encoded. But when you are creating the model \n```python\nmodel.add(Flatten())\nmodel.add(Dense(512,activation = 'relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(5,activation = 'sigmoid'))\n```\nI think you should use `softmax` not `sigmoid`. Other suggestions are , \n\n- you are resizing the images to `(32,32)` which is very less (because we are given images which are shapes in like 2000's ),  \n- as bryan suggested use pretrained models which may boost your accuracy. \n - Your kernel got `0.14` public score and `0.14` is not accuracy , its cohens kappa. Try to incorporate kappa score on validation in your code. \n\n\nI am not that good with keras , so may be some opinions are wrong.",
    "568789": "Thank you so much! Really helpful advice!",
    "568790": "This is great! I'll definitely try a pre-trained model. Any suggestions for this competition?"
  },
  "source": "meta"
}